Ignore the pushed value in interrupts and exceptions

Also handle more types of exceptions.
*** First commit compatible with the C rewrite!! ***
This commit is contained in:
Ry 2022-10-26 21:50:29 -07:00
parent e5dea368b0
commit 2720d0ddff
6 changed files with 42 additions and 2 deletions

View File

@ -158,6 +158,7 @@ stop_audio:
ret ret
refill_buffer_0: refill_buffer_0:
add rsp, 4
push r0 push r0
push r1 push r1
push r31 push r31
@ -181,6 +182,7 @@ refill_buffer_0_loop:
reti reti
refill_buffer_1: refill_buffer_1:
add rsp, 4
push r0 push r0
push r1 push r1
push r31 push r31
@ -204,6 +206,7 @@ refill_buffer_1_loop:
reti reti
refill_buffer_2: refill_buffer_2:
add rsp, 4
push r0 push r0
push r1 push r1
push r31 push r31
@ -227,6 +230,7 @@ refill_buffer_2_loop:
reti reti
refill_buffer_3: refill_buffer_3:
add rsp, 4
push r0 push r0
push r1 push r1
push r31 push r31

View File

@ -1,5 +1,19 @@
; exception handling routines ; exception handling routines
; called if a divide by zero occurs
; does not return, calls panic
system_div_zero_handler:
mov r0, system_div_zero_str
jmp panic
system_div_zero_str: data.str "Divide by zero" data.8 10 data.8 0
; called if an invalid opcode is executed
; does not return, calls panic
system_invalid_op_handler:
mov r0, system_invalid_op_str
jmp panic
system_invalid_op_str: data.str "Invalid opcode" data.8 10 data.8 0
; called if a page fault occurs ; called if a page fault occurs
; does not return, calls panic ; does not return, calls panic
system_page_fault_handler: system_page_fault_handler:
@ -7,3 +21,15 @@ system_page_fault_handler:
pop r1 pop r1
jmp panic jmp panic
system_page_fault_str: data.str "Page fault at virtual address r1" data.8 10 data.8 0 system_page_fault_str: data.str "Page fault at virtual address r1" data.8 10 data.8 0
; called upon execution of a `brk` instruction
system_breakpoint_handler:
add rsp, 4
push r0
mov r0, system_breakpoint_str
call debug_print
pop r0
reti
system_breakpoint_str: data.str "Breakpoint reached!" data.8 10 data.8 0

View File

@ -4,7 +4,7 @@
const FOX32ROM_VERSION_MAJOR: 0 const FOX32ROM_VERSION_MAJOR: 0
const FOX32ROM_VERSION_MINOR: 5 const FOX32ROM_VERSION_MINOR: 5
const FOX32ROM_VERSION_PATCH: 0 const FOX32ROM_VERSION_PATCH: 2
const SYSTEM_STACK: 0x01FFF800 const SYSTEM_STACK: 0x01FFF800
const BACKGROUND_COLOR: 0xFF674764 const BACKGROUND_COLOR: 0xFF674764
@ -39,12 +39,21 @@ entry_seed_done:
; set the interrupt vector for interrupt 0xFF - vsync ; set the interrupt vector for interrupt 0xFF - vsync
mov [0x000003FC], system_vsync_handler mov [0x000003FC], system_vsync_handler
; set the exception vector for exception 0x00 - divide by zero
mov [0x00000400], system_div_zero_handler
; set the exception vector for exception 0x01 - invalid opcode
mov [0x00000404], system_invalid_op_handler
; set the exception vector for exception 0x02 - page fault read ; set the exception vector for exception 0x02 - page fault read
mov [0x00000408], system_page_fault_handler mov [0x00000408], system_page_fault_handler
; set the exception vector for exception 0x03 - page fault write ; set the exception vector for exception 0x03 - page fault write
mov [0x0000040C], system_page_fault_handler mov [0x0000040C], system_page_fault_handler
; set the exception vector for exception 0x04 - breakpoint
mov [0x0000040C], system_breakpoint_handler
; enable interrupts ; enable interrupts
ise ise

View File

@ -1,6 +1,7 @@
; debug monitor vsync routine ; debug monitor vsync routine
monitor_vsync_handler: monitor_vsync_handler:
add rsp, 4
push r0 push r0
push r1 push r1
push r2 push r2

View File

@ -6,7 +6,6 @@
; outputs: ; outputs:
; none, does not return ; none, does not return
panic: panic:
brk
cmp r0, 0 cmp r0, 0
ifz mov r0, panic_string ifz mov r0, panic_string
call debug_print call debug_print

View File

@ -1,6 +1,7 @@
; vsync interrupt routine ; vsync interrupt routine
system_vsync_handler: system_vsync_handler:
add rsp, 4
push r0 push r0
push r1 push r1
push r2 push r2