From 718668b8f8397df0de502548cad8837445359987 Mon Sep 17 00:00:00 2001 From: Kyle Cardoza Date: Sat, 30 Mar 2024 07:56:29 -0400 Subject: [PATCH] Work on interrupts --- src/interrupts.s | 58 ++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/src/interrupts.s b/src/interrupts.s index 40f2dc6..c051b34 100644 --- a/src/interrupts.s +++ b/src/interrupts.s @@ -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)