Assembly Language Help (alang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
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
                                    -♦-