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.
OpenFile
 Map                                       Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
;* OpenFile - Opens specified file for reading or writing. See the CopyFile
;* procedure for another example of using DOS Function 3Dh to open files.
;*
;* Shows:   DOS Function - 3Dh (Open File)
;*
;* Params:  Access - Access code:  0 = read    1 = write    2 = read/write
;*          Fspec - Pointer to ASCIIZ file specification
;*
;* Return:  Short integer with file handle or -1 for error
 
OpenFile PROC USES ds,
        Access:WORD, Fspec:PBYTE
 
        LoadPtr ds, dx, Fspec           ; Point DS:DX to file spec
        mov     ax, Access              ; AL = access code
        mov     ah, 3Dh                 ; AH = function number
        int     21h                     ; Open file
        .IF     carry?
        mov     ax, -1                  ; Set error code
        .ENDIF
        ret
 
OpenFile ENDP
                                    -♦-