mbr: make use of BPB includes
This commit is contained in:
parent
6d1befb49f
commit
404825387b
25
boot/mbr.asm
25
boot/mbr.asm
@ -1,20 +1,17 @@
|
||||
; FDC fields in VBR
|
||||
%define bps (bs + 0x0B)
|
||||
%define md (bs + 0x15)
|
||||
%define spt (bs + 0x18)
|
||||
%define nos (bs + 0x1A)
|
||||
%define po (bs + 0x1C)
|
||||
|
||||
; blah dont judge me, i miss 8080
|
||||
%macro retnz 0
|
||||
jz short ($+3)
|
||||
jz short ($+2+1)
|
||||
ret
|
||||
%endmacro
|
||||
%macro callc 1
|
||||
jnc short ($+5)
|
||||
jnc short ($+2+3)
|
||||
call %1
|
||||
%endmacro
|
||||
|
||||
%include "inc/bpb.asm"
|
||||
|
||||
%define bpb bs+0x0B
|
||||
|
||||
cpu 8086
|
||||
org 0x0600
|
||||
bs: equ 0x7C00
|
||||
@ -75,11 +72,11 @@ main: ; find active partition
|
||||
|
||||
; FAT bpb has "bytes per sector" at this place
|
||||
; we support only 512 byte sectors anyways
|
||||
cmp word [bps], 512
|
||||
cmp word [bpb+bpb_ss], 512
|
||||
jne chain
|
||||
|
||||
; Media descriptor byte is never smaller than 0xF0
|
||||
cmp byte [md], 0xF0
|
||||
cmp byte [bpb+bpb_md], 0xF0
|
||||
jc chain
|
||||
|
||||
; ask BIOS what our disk geometry is
|
||||
@ -95,17 +92,17 @@ main: ; find active partition
|
||||
; update sectors per track
|
||||
xor ax, ax
|
||||
mov al, cl
|
||||
mov [spt], ax
|
||||
mov [bpb+bpb_spt], ax
|
||||
|
||||
; update number of sides
|
||||
xor ax, ax
|
||||
mov al, dh
|
||||
mov [nos], ax
|
||||
mov [bpb+bpb_nos], ax
|
||||
|
||||
; update partition offset
|
||||
push si
|
||||
add si, 0x08
|
||||
mov di, po
|
||||
mov di, bpb+bpb_po
|
||||
movsw
|
||||
movsw
|
||||
pop si
|
||||
|
Loading…
Reference in New Issue
Block a user