From 57409ecb6e6eda3d697d208b3433a4df02e8b91f Mon Sep 17 00:00:00 2001 From: mebibytedraco <139500397+mebibytedraco@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:52:35 -0500 Subject: [PATCH] Make F12 trigger breakpoint --- keyboard.asm | 8 +++++++- vsync.asm | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/keyboard.asm b/keyboard.asm index dc6ce73..fae8d23 100644 --- a/keyboard.asm +++ b/keyboard.asm @@ -2,6 +2,10 @@ ; add events to the event queue if a key was pressed or released ; this should only be called by system_vsync_handler +; inputs: +; none +; outputs: +; r0: non-zero if F12 was pressed, zero otherwise keyboard_update: ; pop a key from the keyboard queue in r0, 0x80000500 @@ -10,7 +14,7 @@ keyboard_update: ; invoke the debug monitor if F12 was pressed cmp r0, 0x58 - ifz jmp invoke_monitor + ifz jmp keyboard_update_end ; check if this is a make or break scancode bts r0, 7 @@ -25,6 +29,7 @@ keyboard_update: mov r6, 0 mov r7, 0 call new_event + mov r0, 0 jmp keyboard_update_end keyboard_update_break_scancode: and r0, 0x7F @@ -37,5 +42,6 @@ keyboard_update_break_scancode: mov r6, 0 mov r7, 0 call new_event + mov r0, 0 keyboard_update_end: ret diff --git a/vsync.asm b/vsync.asm index 37c4862..dd8f566 100644 --- a/vsync.asm +++ b/vsync.asm @@ -15,6 +15,9 @@ system_vsync_handler: call keyboard_update cmp.8 [UPDATE_ICON], 0 ifnz call icon_update + ; check if monitor should be started + cmp r0, 0 + ifnz jmp system_vsync_handler_breakpoint pop r7 pop r6 @@ -25,3 +28,16 @@ system_vsync_handler: pop r1 pop r0 reti + +system_vsync_handler_breakpoint: + pop r7 + pop r6 + pop r5 + pop r4 + pop r3 + pop r2 + pop r1 + pop r0 + ; breakpoint handler expects that there is an extra 4 bytes on the stack + sub rsp, 4 + jmp system_breakpoint_handler