about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-03-15 21:22:30 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-03-15 21:22:30 -0700
commitbc182ae559580d4d2cde6d5c5e8ed3bb5906bdb5 (patch)
tree3c193bf6d292ab34ffac46acf1cbc36a73371429
parent341f0c59be23e5eabee50b43608a64ebf75fd053 (diff)
downloadmu-bc182ae559580d4d2cde6d5c5e8ed3bb5906bdb5.tar.gz
boot.subx is now clean SubX
-rw-r--r--boot.subx16
-rwxr-xr-xlinux/packbin59507 -> 59567 bytes
-rw-r--r--linux/pack.subx28
3 files changed, 30 insertions, 14 deletions
diff --git a/boot.subx b/boot.subx
index 369ed975..412940d6 100644
--- a/boot.subx
+++ b/boot.subx
@@ -134,11 +134,7 @@
   0f 01/lgdt 2/subop/lgdt 0/mod/indirect 6/rm32/use-disp16 0x7cf8/disp16/gdt_descriptor
   # enable paging
   0f 20/<-cr 3/mod/direct 0/rm32/eax 0/r32/cr0
-== data
-  # TODO: SubX doesn't understand 66 prefix
-#?   66 83/or 3/mod/direct 0/rm32/eax 1/r32/?? 1/imm8  # eax <- or 0x1
-  66 83 c8 01  # eax <- or 0x1
-== code
+  66 83/or 3/mod/direct 0/rm32/eax 1/r32/?? 1/imm8  # eax <- or 0x1
   0f 22/->cr 3/mod/direct 0/rm32/eax 0/r32/cr0
   # far jump to initialize_32bit_mode that sets cs to offset 8 in the gdt in the process
   # We can't refer to the label directly because SubX doesn't have syntax for
@@ -191,10 +187,7 @@ gdt_descriptor:
 
 == code 0x7d00
 initialize_32bit_mode:
-== data
-  # TODO: SubX doesn't understand 66 prefix
-  66 b8 10 00  # ax <- offset 16 from gdt_start
-== code
+  66 b8/copy-to-ax 0x10/imm16  # offset 16 from gdt_start
   8e/->seg 3/mod/direct 0/rm32/ax 3/r32/ds
   8e/->seg 3/mod/direct 0/rm32/ax 2/r32/ss
   8e/->seg 3/mod/direct 0/rm32/ax 0/r32/es
@@ -223,10 +216,7 @@ initialize_32bit_mode:
   e6/write-al-into-port 0x21/imm8
 
   fb/enable-interrupts
-== data
-  # TODO: SubX doesn't understand db prefix
-  db e3/initialize-floating-point-coprocessor
-== code
+  db/floating-point-coprocessor e3/initialize
   # eax <- cr4
   0f 20/<-cr 3/mod/direct 0/rm32/eax 4/r32/cr4
   # eax <- or bit 9
diff --git a/linux/pack b/linux/pack
index 557b1c0c..e69773da 100755
--- a/linux/pack
+++ b/linux/pack
Binary files differdiff --git a/linux/pack.subx b/linux/pack.subx
index b619712a..d6ff7af5 100644
--- a/linux/pack.subx
+++ b/linux/pack.subx
@@ -1977,6 +1977,8 @@ emit-opcodes:  # line: (addr stream byte), out: (addr buffered-file)
     #   f3 xx
     #   f2 0f xx
     #   f3 0f xx
+    #   66 xx (hacky support for boot.subx)
+    #   db xx (hacky support for boot.subx)
     #
     # pseudocode:
     #   rewind-stream(line)
@@ -1985,7 +1987,7 @@ emit-opcodes:  # line: (addr stream byte), out: (addr buffered-file)
     #   if (slice-empty?(op1) || slice-starts-with?(op1, "#")) return
     #   op1 = next-token-from-slice(op1->start, op1->end, "/")
     #   write-slice-buffered(out, op1)
-    #   if !slice-equal?(op1, "0f") && !slice-equal?(op1, "f2") && !slice-equal?(op1, "f3")
+    #   if !slice-equal?(op1, "0f") && !slice-equal?(op1, "f2") && !slice-equal?(op1, "f3") && !slice-equal?(op1, "66") && !slice-equal?(op1, "db")
     #     return
     #
     #   var op2 = next-word(line)
@@ -2116,6 +2118,30 @@ $emit-opcodes:op1:
     # . if (eax != false) goto op2
     3d/compare-eax-and  0/imm32/false
     75/jump-if-!=  $emit-opcodes:op2/disp8
+    # if (slice-equal?(op1, "66")) goto op2
+    # . eax = slice-equal?(op1, "66")
+    # . . push args
+    68/push  "66"/imm32
+    51/push-ecx
+    # . . call
+    e8/call  slice-equal?/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
+    # . if (eax != false) goto op2
+    3d/compare-eax-and  0/imm32/false
+    75/jump-if-!=  $emit-opcodes:op2/disp8
+    # if (slice-equal?(op1, "db")) goto op2
+    # . eax = slice-equal?(op1, "db")
+    # . . push args
+    68/push  "db"/imm32
+    51/push-ecx
+    # . . call
+    e8/call  slice-equal?/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
+    # . if (eax != false) goto op2
+    3d/compare-eax-and  0/imm32/false
+    75/jump-if-!=  $emit-opcodes:op2/disp8
     # otherwise return
     e9/jump  $emit-opcodes:end/disp32
 $emit-opcodes:op2: