I'm working on my little toy os. And now I'm trying to load a few sectors after the first sector on my boot disk containing a little bootfs (custom format). The idea is that this way I can write different boot loaders for different media and just drop this data after the boot loader (or maybe even in the fs itself) and then let the second stage (in the bootfs) just parse the ram and load the kernel, this way it doesn't have to touch any drives and can be totally independent of the media it is loaded from. After the kernel is loaded it can load his disk drivers and access the drive as a normal drive. Now back to my question, I write a little piece of asm code just to load a single sector into memory. But now I have no idea if it worked and I got the feeling it didn't work (because the first four bytes should be 'xefs' but when I try to print those chars to the screen nothing shows up). Now I'm horrible when it comes to asm so the code might be totally wrong. What I try to achieve is this. AX contains the sector to load, next I try to extract the head, track and sector number from this and then load this sector at the desired location 0x1000:0x0. Here is the code:
Code: Select all
;;rest floppy drive
fdReset:
mov ah, 0
mov dl, 0
int 0x13
jc fdReset
ret
;;read a sector from the disk
;;es:bx address to read to
;;ax sector to read
fdRead:
;;select head
mov dh, 0
cmp ax, 1440
jl fdRead_headset
sub ax, 1440
mov dh, 1
fdRead_headset:
mov cx, ax
mov al, 80
div cx
mov ch, al
mov cl, ah
inc ch
inc cl
mov ah, 0x02
mov al, 0
mov dl, 0
int 0x13
ret
And here is the code that calls that code
Code: Select all
;;rest floppy drive
call fdReset
;;read xefs headers
mov ax, 0x1000
mov es, ax
mov bx, 0
mov ax, 1
call fdRead
Thanks in advance