Work on interrupts

This commit is contained in:
Kyle Cardoza 2024-03-30 07:56:29 -04:00
parent 607674ff8d
commit 718668b8f8
1 changed files with 22 additions and 36 deletions

View File

@ -6,32 +6,6 @@
#include "macros.h"
; -----------------------------------------------------------------------------
irq_enter .macro
phb
phd
rep #0b00110000
sta long:tmp_register_a
tsc
sta long:external_stack_pointer
lda long:internal_stack_pointer
tcs
lda long:tmp_register_a
.endm
irq_exit .macro
sta long:tmp_register_a
tsc
sta long:internal_stack_pointer
lda long:external_stack_pointer
tcs
lda long:tmp_register_a
pld
plb
rti
.endm
; -----------------------------------------------------------------------------
.section near
@ -65,7 +39,25 @@ interrupts_init:
; -----------------------------------------------------------------------------
cop_handler_native:
irq_enter
phd
phb
pha
short_a
lda #0
pha
plb
pha
pld
long_a
; First, we multiply the function number by 2, to get the jump
; table offset.
txa
asl a
tax
pla
; When we get here, the X register contains the function number.
; A and Y may or may not contain parameters. None of those are
@ -73,19 +65,13 @@ cop_handler_native:
; right handler for the particular function being called, without
; modifying anything but the X register.
; First, we multiply the function number by 2, to get the jump
; table offset.
pha
txa
asl a
tax
pla
; Now, we do an indirect, indexed jump through the jump table.
jsr (cop_jump_table,x)
; And we're done.
irq_exit
plb
pld
rti
cop_jump_table:
.word .near(cop_reset)