NASM - Load code from USB Drive
        Posted  
        
            by 
                new123456
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by new123456
        
        
        
        Published on 2011-01-16T03:13:44Z
        Indexed on 
            2011/01/16
            3:53 UTC
        
        
        Read the original article
        Hit count: 327
        
Hola,
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.
© Stack Overflow or respective owner