Make F12 trigger breakpoint

main
mebibytedraco 2023-12-22 15:52:35 -05:00
parent b1aa77aa70
commit 57409ecb6e
2 changed files with 23 additions and 1 deletions

View File

@ -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

View File

@ -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