问题
Would any assembly gurus know the argument (register dl) that signifies the first USB drive?
I'm working through a couple of NASM tutorials, and would like to get a physical boot (I can get a clean one with qemu).
This is the section of code that loads the "kernel" data from disk:
loadkernel:
mov si, LMSG ;; 'Loading kernel',13,10,0
call prints ;; ex puts()
mov dl, 0x00 ;; The disk to load from
mov ah, 0x02 ;; Read operation
mov al, 0x01 ;; Sectors to read
mov ch, 0x00 ;; Track
mov cl, 0x02 ;; Sector
mov dh, 0x00 ;; Head
mov bx, 0x2000 ;; Buffer end
mov es, bx
mov bx, 0x0000 ;; Buffer start
int 0x13
jc loadkernel
mov ax, 0x2000
mov ds, ax
jmp 0x2000:0x00
If it makes any difference, I'm running a stock Dell Inspiron 15 BIOS.
Apparently, the correct value for me is 0x80.
The BIOS loads the hard drives and labels them starting at 0x80 according to this answer.
My particular BIOS decides to load the USB drive up as the first, for some reason, so I can boot from there.
回答1:
The simple answer is that the correct value for dl
is in dl
.
The happy answer is that the dl
value with int 13h, ah=8
GET DRIVE PARAMETERS returns the geometry to use and allows the FAT12 floppy disk image code to run from any BIOS/version that can boot from a USB flash drive.
See my post here: USB Booting Secrets
来源:https://stackoverflow.com/questions/4703595/nasm-load-code-from-usb-drive