about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-03-14 22:12:34 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-03-14 22:12:34 -0700
commit4d0db2c94e8f2d89994e84b5495a3f5e32b12f01 (patch)
tree92652a49ba181e64f04fd062f44cb5ecddda3bea
parentcc7a44f9df2eecb7dccb86f97a4462ab734f769a (diff)
downloadmu-4d0db2c94e8f2d89994e84b5495a3f5e32b12f01.tar.gz
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.
-rw-r--r--boot.subx32
1 files changed, 16 insertions, 16 deletions
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)