Eventually I want the kernel to be loaded from the SD card as well, but it still needs to separate from user programs. At some point there should be a folder just for the BIOS, which should read from the boot block of the SD card and start executing, and thats it.
58 lines
2.0 KiB
ArmAsm
58 lines
2.0 KiB
ArmAsm
; ---------------------------------------------------------------------------
|
|
; interrupt.s
|
|
; ---------------------------------------------------------------------------
|
|
;
|
|
; Interrupt handler.
|
|
;
|
|
; Checks for a BRK instruction and returns from all valid interrupts.
|
|
|
|
.import _handle_irq
|
|
|
|
.export _irq_int, _nmi_int
|
|
.export _irq_get_status, _irq_set_status
|
|
|
|
.include "io.inc65"
|
|
|
|
.segment "CODE"
|
|
|
|
.PC02 ; Force 65C02 assembly mode
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; Non-maskable interrupt (NMI) service routine
|
|
|
|
_nmi_int: RTI ; Return from all NMI interrupts
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; Maskable interrupt (IRQ) service routine
|
|
|
|
_irq_int: PHX ; Save X register contents to stack
|
|
TSX ; Transfer stack pointer to X
|
|
PHA ; Save accumulator contents to stack
|
|
INX ; Increment X so it points to the status
|
|
INX ; register value saved on the stack
|
|
LDA $100,X ; Load status register contents
|
|
AND #$10 ; Isolate B status bit
|
|
BNE break ; If B = 1, BRK detected
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; IRQ detected, return
|
|
|
|
irq: PLA ; Restore accumulator contents
|
|
PLX ; Restore X register contents
|
|
jsr _handle_irq ; Handle the IRQ
|
|
RTI ; Return from all IRQ interrupts
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; BRK detected, stop
|
|
|
|
break: JMP break ; If BRK is detected, something very bad
|
|
; has happened, so stop running
|
|
|
|
_irq_get_status:
|
|
lda IRQ_STATUS
|
|
ldx #$00
|
|
rts
|
|
|
|
_irq_set_status:
|
|
sta IRQ_STATUS
|
|
rts |