From 404825387b7a5449fb1ab2d1b7188fd66b9a9354 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Thu, 30 Apr 2020 20:22:14 +0200 Subject: [PATCH] mbr: make use of BPB includes --- boot/mbr.asm | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/boot/mbr.asm b/boot/mbr.asm index 5db6217..6655e48 100644 --- a/boot/mbr.asm +++ b/boot/mbr.asm @@ -1,19 +1,16 @@ -; 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) + ; blah dont judge me, i miss 8080 + %macro retnz 0 + jz short ($+2+1) ret -%endmacro -%macro callc 1 - jnc short ($+5) + %endmacro + %macro callc 1 + jnc short ($+2+3) call %1 -%endmacro + %endmacro + + %include "inc/bpb.asm" + + %define bpb bs+0x0B cpu 8086 org 0x0600 @@ -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