Programmering - Assembler - INT - INT21 - File with Handle

 

INT 21, 3C : Create File with Handle
AH = 3Ch
CX = attributes : any combination of:
   = 0000h : ATTR_NORMAL
   = 0001h : ATTR_READONLY
   = 0002h : ATTR_HIDDEN
   = 0004h : ATTR_SYSTEM
   = 0008h : ATTR_VOLUME
   = 0020h : ATTR_ARCHIVE
DS:DX -> filename : zero term. ascii string
CF = 0 : no error
  AX = handle
CF = 1 : error
  AX = 3 : ERROR_PATH_NOT_FOUND
     = 4 : ERROR_TOO_MANY_OPEN_FILES
     = 5 : ERROR_ACCESS_DENIED

 

 

>4300 : Get File Attributes
>4301 : Set File Attributes
>5A : Create Temporary File
>5B : Create New File
>6C : Extended Open/Create

 

Create the file "test.txt" - filename is in the data segment
filename  db "test.txt", 0  ;zero-term. string
handle    dw 0
;-------------------
    mov dx, offset filename
    mov cx, 0  ;ATTR_NORMAL
    mov ah, 3Ch
    int 21h
    jc error_handler
    mov handle, ax

 

INT 21, 3D : Open File with Handle
   

 

 

INT 21, 3E : Close File with Handle