Reputation: 1395
I wrote a basic Assembly bootloader to clear the screen and print X
:
[BITS 16]
[ORG 0x7c00]
main:
mov ax, 0x03
int 10h
mov ah, 0x0E
mov al, 'X'
int 10h
jmp $
times 510 - ($-$$) db 0
DW 0xAA55
Now what I need to do is to create a file on the hard drive. I know that I can do it easily with DOS interrupts using this code:
outputfile db "myfile.txt"
outhandle db ?
mov dx, offset outputfile
mov cx, 0
mov ah, 3Ch
int 21h
mov outhandle, ax
But I didn't find anything about files operations using BIOS interrupts.
Is this possible?
Upvotes: 1
Views: 380
Reputation: 71526
The idea behind the BIOS interrupt calls is to abstract gory details of specific peripherals. So instead of having to know how to spin a motor move a head, etc, there are high level bios calls, not unlike calls to drivers or system calls in an operating system, you have these calls to read this write that.
Filesystems and other similar things are at the next higher level/layer. The BIOS calls with respect to hard drives help you read a sector, write a sector kind of thing but file systems are high level and you have to implement that in your code. (or make system calls to an operating system).
If you want to simply experiment with reading and writing then you can just do that without a file system because at this level its just bits/bytes/sectors not file systems. You could simply write sectors N thru M then read them back or read them in random order, etc to get a feel that they are there. Or you can use an operating system to create a filesystem and create files then use the BIOS calls to read the file system infrastructure (depends on filesystem) and try to find the files and follow the directory information to gather the individual parts of that file across sectors. And use that information in combination with whatever quality information you can find online for that specific file system type and compare notes and perhaps develop a filesystem library of your own from there.
If this is a roll your own thing then you may choose not to have a filesystem at all, just keep track of data on that media however you wish.
Note that there are free DOS implementations in which you can borrow their code for those dos calls, or learn from or whatever. Likewise there may still be third party implementations you can find, of which some would be open source.
And as mentioned in a comment depending on your overall goals there are newer solutions that replace direct BIOS/DOS for booting a PC. The expectation there is a similar model/functionality just newer and more in tune with modern processors rather than something developed on the 8088/86.
Upvotes: 5