(This tutorial was originally written in 2004 and featured in http://asm.inightmare.org/)
This tutorial covers basic file Input and Output in DOS.
The first thing you can do is create a file:
mov ah, 3Ch ; DOS create file |
Well that’s pretty simple. Carry flag is set if error has occured. Now if we have file, we of course want to open it:
mov ah, 0x3Dh |
If file exists, it’s handle is returned in AX, ff file doesn’t exist Carry Flag is set. Now we can read from our file:
mov ah, 0x3F |
If read is successful AX contains number of bytes red, if reading failed as always Carry Flag is set. Now writing:
mov ah, 0x40 |
If write is successful CF is clear and AX contains number of bytes written, else CF is set and AX contains an error code. After we did what we want, we can close the file:
mov ah, 0x3E |
And deleting files for the dessert:
mov ah, 41h |
Those are the basics you need to know. Good luck!