Assembly Language Help (alang.hlp) (Table of Contents; Topic list)
ReadFile
 Map                                       Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
;* ReadFile - Read from open file to specified buffer. See the CopyFile
;* procedure for another example of using DOS Function 3Fh to read files.
;*
;* Shows:   DOS Function - 3Fh (Read File or Device)
;*
;* Params:  Handle - File handle
;*          Len - Number of bytes to read
;*          Pbuff - Pointer to buffer
;*
;* Return:  Short integer with number of bytes read, or 0 if read error
 
ReadFile PROC USES ds di,
        Handle:WORD, Len:WORD, Pbuff:PBYTE
 
        LoadPtr ds, dx, Pbuff           ; Point DS:DX to buffer
        mov     di, dx                  ; Keep string offset in DI
        mov     bx, Handle              ; BX = handle
        mov     cx, Len                 ; CX = number of bytes to read
        mov     ah, 3Fh                 ; Request DOS read
        int     21h                     ; Read File
        .IF     carry?
        sub     ax, ax                  ; Set error code
        .ENDIF
        ret
 
ReadFile ENDP
                                    -♦-