Day 18
Creating/Deleting Files
See title, code code...
Creating
A file is created with Function 3Ch of DOS Services Interrupt 21h. Here's some code to create
a file called "elmo.txt":
;;---CODE START---;;
mov ah,3Ch
mov cx,0 ; no special file attributes
mov dx,offset filename
int 21h
mov ah,4Ch
int 21h
filename db "elmo.txt",0
;;---CODE END---;;
Note that instead of exiting the program like is done above, you could take the file handle which is
returned in AX by Functin 3Ch and write to your newly created file (created files are opened for writing).
Deleting
Deleting is identical and is Function 41h. This will delete the file
created by the previous program:
;;---CODE START---;;
mov ah,41h ; different function this time.
mov dx,offset filename
int 21h
mov ah,4Ch
int 21h
filename db "elmo.txt",0
;;---CODE END---;;
This is easy, isn't it?
This Day In Review
I hope you're doing okay and not super crashing your comp!
Until Next Time,
- Mike H a.k.a GbaGuy
Intro - Day 19
Patater GBAGuy Mirror
Contact