about summary refs log tree commit diff stats
path: root/boot.subx
diff options
context:
space:
mode:
Diffstat (limited to 'boot.subx')
-rw-r--r--boot.subx207
1 files changed, 89 insertions, 118 deletions
diff --git a/boot.subx b/boot.subx
index ed2d213e..6982fccb 100644
--- a/boot.subx
+++ b/boot.subx
@@ -359,125 +359,96 @@ keyboard-interrupt-handler:
   3c/compare-al-and 0/imm8
   75/jump-if-!= $keyboard-interrupt-handler:epilogue/disp8
   # - read keycode
-  31/xor %eax 0/r32/eax
   e4/read-port-into-al 0x60/imm8
-  #
-#?   50/push-eax
-#?   51/push-ecx
-#?   (draw-int32-hex-wrapping-right-then-down-over-full-screen 0 %eax 0 0 7 0)
-#?   59/pop-to-ecx
-#?   58/pop-to-eax
-  #
-#?   50/push-eax
-#?   51/push-ecx
-#?   (draw-int32-decimal-wrapping-right-then-down 0 %eax 0 2 0x400 2 0 2 7 0)
-  89/<- %ecx 0/r32/eax
-  # . . push args
-  68/push 0/imm32/bg
-  68/push 7/imm32/fg
-  68/push 2/imm32/y
-  68/push 0x400/imm32/xmax
-  68/push 0/imm32/xmin
-#?   68/push 0x48/imm32/n
-  51/push-ecx
-  68/push 0/imm32/screen
-  # . . call
-#?   e8/call draw-int32-hex-wrapping-right-then-down/disp32
-#?   e8/call draw-int32-decimal-wrapping-right-then-down/disp32
-  e8/call draw-int32-decimal-rightward/disp32
-  # . . discard args
-  81 0/subop/add %esp 0x1c/imm32
-#?   59/pop-to-ecx
-#?   58/pop-to-eax
-#?   # - key released
-#?   # if (al == 0xaa) shift = false  # left shift is being lifted
-#?   {
-#?     3c/compare-al-and 0xaa/imm8
-#?     75/jump-if-!= break/disp8
-#?     # *shift = 0
-#?     c7 0/subop/copy *Keyboard-shift-pressed? 0/imm32
-#?   }
-#?   # if (al == 0xb6) shift = false  # right shift is being lifted
-#?   {
-#?     3c/compare-al-and 0xb6/imm8
-#?     75/jump-if-!= break/disp8
-#?     # *shift = 0
-#?     c7 0/subop/copy *Keyboard-shift-pressed? 0/imm32
-#?   }
-#?   # if (al == 0x9d) ctrl = false  # ctrl is being lifted
-#?   {
-#?     3c/compare-al-and 0x9d/imm8
-#?     75/jump-if-!= break/disp8
-#?     # *ctrl = 0
-#?     c7 0/subop/copy *Keyboard-ctrl-pressed? 0/imm32
-#?   }
-#?   # if (al & 0x80) a key is being lifted; return
-#?   50/push-eax
-#?   24/and-al-with 0x80/imm8
-#?   3c/compare-al-and 0/imm8
-#?   58/pop-to-eax
-#?   75/jump-if-!= $keyboard-interrupt-handler:epilogue/disp8
-#?   # - key pressed
-#?   # if (al == 0x2a) shift = true, return  # left shift pressed
-#?   {
-#?     3c/compare-al-and 0x2a/imm8
-#?     75/jump-if-!= break/disp8
-#?     # *shift = 1
-#?     c7 0/subop/copy *Keyboard-shift-pressed? 1/imm32
-#?     # return
-#?     eb/jump $keyboard-interrupt-handler:epilogue/disp8
-#?   }
-#?   # if (al == 0x36) shift = true, return  # right shift pressed
-#?   {
-#?     3c/compare-al-and 0x36/imm8
-#?     75/jump-if-!= break/disp8
-#?     # *shift = 1
-#?     c7 0/subop/copy *Keyboard-shift-pressed? 1/imm32
-#?     # return
-#?     eb/jump $keyboard-interrupt-handler:epilogue/disp8
-#?   }
-#?   # if (al == 0x1d) ctrl = true, return
-#?   {
-#?     3c/compare-al-and 0x1d/imm8
-#?     75/jump-if-!= break/disp8
-#?     # *ctrl = 1
-#?     c7 0/subop/copy *Keyboard-ctrl-pressed? 1/imm32
-#?     # return
-#?     eb/jump $keyboard-interrupt-handler:epilogue/disp8
-#?   }
-#?   # - convert key to character
-#?   # if (shift) use keyboard shift map
-#?   {
-#?     81 7/subop/compare *Keyboard-shift-pressed? 0/imm32
-#?     74/jump-if-= break/disp8
-#?     # sigils don't currently support labels inside *(eax+label)
-#?     05/add-to-eax Keyboard-shift-map/imm32
-#?     8a/byte-> *eax 0/r32/al
-#?     eb/jump $keyboard-interrupt-handler:select-map-done/disp8
-#?   }
-#?   # if (ctrl) al = *(ctrl map + al)
-#?   {
-#?     81 7/subop/compare *Keyboard-ctrl-pressed? 0/imm32
-#?     74/jump-if-= break/disp8
-#?     05/add-to-eax Keyboard-ctrl-map/imm32
-#?     8a/byte-> *eax 0/r32/al
-#?     eb/jump $keyboard-interrupt-handler:select-map-done/disp8
-#?   }
-#?   # otherwise al = *(normal map + al)
-#?   05/add-to-eax Keyboard-normal-map/imm32
-#?   8a/byte-> *eax 0/r32/al
-#? $keyboard-interrupt-handler:select-map-done:
-#?   # - if there's no character mapping, return
-#?   {
-#?     3c/compare-al-and 0/imm8
-#?     74/jump-if-= break/disp8
-#?     # - store al in keyboard buffer
-#?     88/<- *ecx 0/r32/al
-#?     # increment index
-#?     fe/increment-byte *Keyboard-buffer:write
-#?     # clear top nibble of index (keyboard buffer is circular)
-#?     80 4/subop/and-byte *Keyboard-buffer:write 0x0f/imm8
-#?   }
+  # - key released
+  # if (al == 0xaa) shift = false  # left shift is being lifted
+  {
+    3c/compare-al-and 0xaa/imm8
+    75/jump-if-!= break/disp8
+    # *shift = 0
+    c7 0/subop/copy *Keyboard-shift-pressed? 0/imm32
+  }
+  # if (al == 0xb6) shift = false  # right shift is being lifted
+  {
+    3c/compare-al-and 0xb6/imm8
+    75/jump-if-!= break/disp8
+    # *shift = 0
+    c7 0/subop/copy *Keyboard-shift-pressed? 0/imm32
+  }
+  # if (al == 0x9d) ctrl = false  # ctrl is being lifted
+  {
+    3c/compare-al-and 0x9d/imm8
+    75/jump-if-!= break/disp8
+    # *ctrl = 0
+    c7 0/subop/copy *Keyboard-ctrl-pressed? 0/imm32
+  }
+  # if (al & 0x80) a key is being lifted; return
+  50/push-eax
+  24/and-al-with 0x80/imm8
+  3c/compare-al-and 0/imm8
+  58/pop-to-eax
+  75/jump-if-!= $keyboard-interrupt-handler:epilogue/disp8
+  # - key pressed
+  # if (al == 0x2a) shift = true, return  # left shift pressed
+  {
+    3c/compare-al-and 0x2a/imm8
+    75/jump-if-!= break/disp8
+    # *shift = 1
+    c7 0/subop/copy *Keyboard-shift-pressed? 1/imm32
+    # return
+    eb/jump $keyboard-interrupt-handler:epilogue/disp8
+  }
+  # if (al == 0x36) shift = true, return  # right shift pressed
+  {
+    3c/compare-al-and 0x36/imm8
+    75/jump-if-!= break/disp8
+    # *shift = 1
+    c7 0/subop/copy *Keyboard-shift-pressed? 1/imm32
+    # return
+    eb/jump $keyboard-interrupt-handler:epilogue/disp8
+  }
+  # if (al == 0x1d) ctrl = true, return
+  {
+    3c/compare-al-and 0x1d/imm8
+    75/jump-if-!= break/disp8
+    # *ctrl = 1
+    c7 0/subop/copy *Keyboard-ctrl-pressed? 1/imm32
+    # return
+    eb/jump $keyboard-interrupt-handler:epilogue/disp8
+  }
+  # - convert key to character
+  # if (shift) use keyboard shift map
+  {
+    81 7/subop/compare *Keyboard-shift-pressed? 0/imm32
+    74/jump-if-= break/disp8
+    # sigils don't currently support labels inside *(eax+label)
+    05/add-to-eax Keyboard-shift-map/imm32
+    8a/byte-> *eax 0/r32/al
+    eb/jump $keyboard-interrupt-handler:select-map-done/disp8
+  }
+  # if (ctrl) al = *(ctrl map + al)
+  {
+    81 7/subop/compare *Keyboard-ctrl-pressed? 0/imm32
+    74/jump-if-= break/disp8
+    05/add-to-eax Keyboard-ctrl-map/imm32
+    8a/byte-> *eax 0/r32/al
+    eb/jump $keyboard-interrupt-handler:select-map-done/disp8
+  }
+  # otherwise al = *(normal map + al)
+  05/add-to-eax Keyboard-normal-map/imm32
+  8a/byte-> *eax 0/r32/al
+$keyboard-interrupt-handler:select-map-done:
+  # - if there's no character mapping, return
+  {
+    3c/compare-al-and 0/imm8
+    74/jump-if-= break/disp8
+    # - store al in keyboard buffer
+    88/<- *ecx 0/r32/al
+    # increment index
+    fe/increment-byte *Keyboard-buffer:write
+    # clear top nibble of index (keyboard buffer is circular)
+    80 4/subop/and-byte *Keyboard-buffer:write 0x0f/imm8
+  }
 $keyboard-interrupt-handler:epilogue:
   # epilogue
   9d/pop-flags