From 4d0db2c94e8f2d89994e84b5495a3f5e32b12f01 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 14 Mar 2021 22:12:34 -0700 Subject: fix a benign bug so far I'd been assuming that the image would be identical if it worked, but I need to actually validate this at each step: ./translate life.mu && qemu-system-i386 disk.img && diff disk.img 0 The plan is to keep the binary identical until I finish translating boot.subx. Then I can remove obsolete padding. --- boot.subx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'boot.subx') diff --git a/boot.subx b/boot.subx index 01274f45..0c525b68 100644 --- a/boot.subx +++ b/boot.subx @@ -55,17 +55,17 @@ # initialize segment registers b8/copy-to-ax 0/imm16 - 8e/seg<- 3/mod/direct 3/rm32/ds 0/r32/ax - 8e/seg<- 3/mod/direct 0/rm32/es 0/r32/ax - 8e/seg<- 3/mod/direct 4/rm32/fs 0/r32/ax - 8e/seg<- 3/mod/direct 5/rm32/gs 0/r32/ax + 8e/seg-> 3/mod/direct 0/rm32/ax 3/rm32/ds + 8e/seg-> 3/mod/direct 0/rm32/ax 0/rm32/es + 8e/seg-> 3/mod/direct 0/rm32/ax 4/rm32/fs + 8e/seg-> 3/mod/direct 0/rm32/ax 5/rm32/gs # initialize stack to 0x00070000 # We don't read or write the stack before we get to 32-bit mode, but BIOS # calls do. We need to move the stack in case BIOS initializes it to some # low address that we want to write code into. b8/copy-to-ax 0x7000/imm16 - 8e/seg<- 3/mod/direct 2/rm32/ss 0/r32/ax + 8e/seg-> 3/mod/direct 0/rm32/ax 2/rm32/ss bc/copy-to-esp 0/imm16 # undo the A20 hack: https://en.wikipedia.org/wiki/A20_line @@ -85,20 +85,20 @@ e6/write-al-into-port 0x64/imm8 } -== data - # load remaining sectors from first two tracks of disk into addresses [0x7e00, 0x17800) - b4 02 # ah <- 2 # read sectors from disk + b4/copy-to-ah 2/imm8 # read sectors from disk # dl comes conveniently initialized at boot time with the index of the device being booted - b5 00 # ch <- 0 # cylinder 0 - b6 00 # dh <- 0 # track 0 - b1 02 # cl <- 2 # second sector, 1-based - b0 7d # al <- 125 # number of sectors to read = 2*63 - 1 + b5/copy-to-ch 0/imm8 # cylinder 0 + b6/copy-to-dh 0/imm8 # track 0 + b1/copy-to-cl 2/imm8 # second sector, 1-based + b0/copy-to-al 0x7d/imm8 # number of sectors to read = 2*63 - 1 = 125 # address to write sectors to = es:bx = 0x7e00, contiguous with boot segment - bb 00 00 # bx <- 0 - 8e c3 # es <- bx - bb 00 7e # bx <- 0x7e00 [label] - cd 13 # int 13h, BIOS disk service + bb/copy-to-bx 0/imm16 + 8e/seg-> 3/mod/direct 3/rm32/bx 0/r32/es + bb/copy-to-bx 0x7e00/imm16 + cd/syscall 0x13/imm8/bios-disk-service + +== data 0f 82 a3 00 # jump-if-carry disk_error [label] # load two more tracks of disk into addresses [0x17800, 0x27400) -- cgit 1.4.1-2-gfad0