I'm working with a friend of mine on a simple bootloader, with no pretense of it becoming anything usable. After writing the on-screen input and output functions we moved on to writing the functions to read a sector from disk, and this is where the first problems arose. I state that both on qemu and bochs everything works fine. The same thing I can not say for the physical hardware, where I encounter the error 0x0001, which means Invalid Command.
However, I didn't find much information about this error. It seems to me that it could mean that I got some argument wrong, but I printed out all the logs on screen and didn't find any strange values that would justify this behavior.
I am booting from a flash drive. I thought that might be a problem, too (since it's not an actual floppy), but if the BIOS can load the bootsector it should have no problem loading the next sector as well.
However, here is the code for the read_sector function:
read_sector:
start_f
pusha
mov (drive_number), %dl # drive number is stored from the main function into a global variable
mov $0x03, %si # try three times
1:
mov $0x0201, %ax
int $disk_int
jnc end
dec %si
jz 2f
xor %ah, %ah
int $disk_int
jmp 1b
2:
movzx %ah, %dx
call printh # print error code
end:
popa
end_f
And here is the caller function (dl = 0):
# ...
mov $0x0002, %cx
xor %dh, %dh
mov $0x7e00, %bx
call read_sector
# ...
What could we be doing wrong?