Here is how I read the MBR:
Code: Select all
Disk_basic:
.loadSecondStage:
pusha
mov dl, [BOOT_DRIVE] ; Put boot drive into DL. It should not leave
; for the duration of this function, for convenience.
mov si, 0x1be + 0x7c00 ; Address for start of MBR (which does not
; overwrite any part of the boot sector,
; I made sure of it).
.loadSecondStage.nextMBR:
mov al, [si + 4] ; Get the system ID from the MBR.
mov bl, al
call Print.byte
cmp al, 0xee ; Check if the id is 0xee.
je .loadSecondStage.efiMBR
cmp al, 0xef ; Otherwise, check if it is 0xef.
je .loadSecondStage.efiGPT
cmp si, 0x1fe + 0x7e00 ; Check if we are past the last MBR entry.
jge .loadSecondStage.errMBR
add si, 0x40 ; Otherwise, check the next entry.
jmp .loadSecondStage.nextMBR
Code: Select all
0x7dbe: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7dc6: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7dce: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7dd6: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7dde: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7de6: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7dee: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x7df6: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Code: Select all
000001be: 0000 0200 eeff ffff 0100 0000 ffff 0300
000001ce: 0000 0000 0000 0000 0000 0000 0000 0000
000001de: 0000 0000 0000 0000 0000 0000 0000 0000
000001ee: 0000 0000 0000 0000 0000 0000 0000 0000
https://github.com/ljtpetersen/jpos