diff options
-rw-r--r-- | timer.subx | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/timer.subx b/timer.subx index 5a317c91..89c5ef6d 100644 --- a/timer.subx +++ b/timer.subx @@ -293,11 +293,11 @@ idt_start: 0/imm16 # target[16:32] -- timer-interrupt-handler must be within address 0x10000 # entry 9: keyboard - null-interrupt-handler/imm16 # target[0:16] + keyboard-interrupt-handler/imm16 # target[0:16] 8/imm16 # segment selector (gdt_code) 00 # unused 8e # 1/p 00/dpl 0 1110/type/32-bit-interrupt-gate - 0/imm16 # target[16:32] -- null-interrupt-handler must be within address 0x10000 + 0/imm16 # target[16:32] -- keyboard-interrupt-handler must be within address 0x10000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -326,22 +326,6 @@ idt_start: == code -null-interrupt-handler: - # prologue - fa/disable-interrupts - 60/push-all-registers - 9c/push-flags - # acknowledge interrupt - b0/copy-to-al 0x20/imm8 - e6/write-al-into-port 0x20/imm8 - 31/xor %eax 0/r32/eax -$null-interrupt-handler:epilogue: - # epilogue - 9d/pop-flags - 61/pop-all-registers - fb/enable-interrupts - cf/return-from-interrupt - timer-interrupt-handler: # prologue fa/disable-interrupts @@ -375,6 +359,45 @@ $timer-interrupt-handler:epilogue: fb/enable-interrupts cf/return-from-interrupt +keyboard-interrupt-handler: + # prologue + fa/disable-interrupts + 60/push-all-registers + 9c/push-flags + # acknowledge interrupt + b0/copy-to-al 0x20/imm8 + e6/write-al-into-port 0x20/imm8 + 31/xor %eax 0/r32/eax + # check output buffer of 8042 keyboard controller (https://web.archive.org/web/20040604041507/http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/keyboard/atkeyboard.html) + e4/read-port-into-al 0x64/imm8 + a8/test-bits-in-al 0x01/imm8 # set zf if bit 0 (least significant) is not set + 0f 84/jump-if-not-set $keyboard-interrupt-handler:epilogue/disp32 + # initialize current-pixel-location if necessary + 81 7/subop/compare *Keyboard-current-pixel 0/imm32 + { + 75/jump-if-!= break/disp8 + 8b/-> *Video-memory-addr 1/r32/ecx + 89/<- *Keyboard-current-pixel 1/r32/ecx + } + # - read keycode + e4/read-port-into-al 0x60/imm8 + # 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 + 8b/-> *Keyboard-current-pixel 1/r32/ecx + c6 0/subop/copy-byte *ecx 0x31/imm8/green + ff 0/subop/increment *Keyboard-current-pixel +$keyboard-interrupt-handler:epilogue: + # epilogue + 9d/pop-flags + 61/pop-all-registers + fb/enable-interrupts + cf/return-from-interrupt + == data Video-mode-info: @@ -435,4 +458,7 @@ Video-memory-addr: Timer-current-color: 0/imm32 +Keyboard-current-pixel: + 0/imm32 + # vim:ft=subx |