(This tutorial was originally written in 2004 and featured in http://asm.inightmare.org/)
mov ah, 0x1A |
Simple, DX stores pointer to new DTA table. How does that DTA thing look like? Like that:
| OFFSET | SIZE | MEANING |
|---|---|---|
| 0 | 23 bytes | Data that only DOS needs |
| 0x15 | Byte | File attribute |
| 0x16 | Word | File creation/modification time |
| 0x18 | Word | File creation/modification date |
| 0x1A | DWord | File size |
| 0x1E | 13 Bytes | File name terminated with zero |
Now, we have our table set up, we can find the first file.
mov ah, 0x4E |
It’s pretty simple. DX stores pointer to search query (DOS dir argument) terminated with zero. Like:
db “*.*”, 0x0 |
Carry flag is set if file wasn’t found. If file was found DTA table is filled with files attributes. For all other files we want to find we use other call:
mov ah, 0x4F |
If no more files found Carry Flag is set after the call, if file is found DTA table is filled with it’s attributes. That’s it. Grab the source to see how everything looks. Have fun!
NASM Source code - here