Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Use LBA.
- use_lba:
- ; Get the drive parameters.
- mov ah, 0x48
- mov si, 0x1000 ; This is where stage2 will be parse,
- ; but we won't need this data by then.
- mov dl, [device] ; Use the BIOS device.
- int 0x13
- cmp ah, 0
- je lba_ctd ; Success.
- ; Error... Print the error bytes and hang the machine.
- mov al, ah
- call puterr
- jmp hang
- lba_ctd:
- ; Find the LBA of the active partition
- mov bx, 0x7dbe ; Address of partition table in memory
- ; (0x7c00 + 446).
- .ptable_loop:
- mov ah, [bx] ; Partition status byte.
- cmp ah, 0x80
- je .bootable_found ; Found bootable partition.
- add bx, 16 ; Next entry.
- jmp .ptable_loop
- .bootable_found:
- mov ax, [bx + 0x0c]
- mov [dap.offset], ax
- ; Get the number of bytes per block
- mov ax, [si + 0x18]
- ; Calculate the number of blocks to read (STAGE2_BYTES / block size).
- push ax
- mov ax, STAGE2_BYTES
- pop bx
- div bx
- mov [dap.block_count], ax
- ; Now we can actually perform the read.
- mov ah, 0x42 ; Extended read.
- mov dl, [device] ; Use the BIOS device.
- mov si, dap ; DS:SI = Disk Address Packet (DAP)
- int 0x13
- cmp ah, 0
- je parse ; Success.
- ; Error... Print the error bytes and hang the machine.
- mov al, ah
- call puterr
- jmp hang
Advertisement
Add Comment
Please, Sign In to add comment