Make F12 trigger breakpoint

This commit is contained in:
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 ; add events to the event queue if a key was pressed or released
; this should only be called by system_vsync_handler ; this should only be called by system_vsync_handler
; inputs:
; none
; outputs:
; r0: non-zero if F12 was pressed, zero otherwise
keyboard_update: keyboard_update:
; pop a key from the keyboard queue ; pop a key from the keyboard queue
in r0, 0x80000500 in r0, 0x80000500
@ -10,7 +14,7 @@ keyboard_update:
; invoke the debug monitor if F12 was pressed ; invoke the debug monitor if F12 was pressed
cmp r0, 0x58 cmp r0, 0x58
ifz jmp invoke_monitor ifz jmp keyboard_update_end
; check if this is a make or break scancode ; check if this is a make or break scancode
bts r0, 7 bts r0, 7
@ -25,6 +29,7 @@ keyboard_update:
mov r6, 0 mov r6, 0
mov r7, 0 mov r7, 0
call new_event call new_event
mov r0, 0
jmp keyboard_update_end jmp keyboard_update_end
keyboard_update_break_scancode: keyboard_update_break_scancode:
and r0, 0x7F and r0, 0x7F
@ -37,5 +42,6 @@ keyboard_update_break_scancode:
mov r6, 0 mov r6, 0
mov r7, 0 mov r7, 0
call new_event call new_event
mov r0, 0
keyboard_update_end: keyboard_update_end:
ret ret

View File

@ -15,6 +15,9 @@ system_vsync_handler:
call keyboard_update call keyboard_update
cmp.8 [UPDATE_ICON], 0 cmp.8 [UPDATE_ICON], 0
ifnz call icon_update ifnz call icon_update
; check if monitor should be started
cmp r0, 0
ifnz jmp system_vsync_handler_breakpoint
pop r7 pop r7
pop r6 pop r6
@ -25,3 +28,16 @@ system_vsync_handler:
pop r1 pop r1
pop r0 pop r0
reti 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