mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
Add support for interruptors (Stefan Haubenthal).
git-svn-id: svn://svn.cc65.org/cc65/trunk@5027 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
9c17760227
commit
5df93d5561
@ -7,7 +7,8 @@
|
|||||||
.export _exit
|
.export _exit
|
||||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||||
.import initlib, donelib
|
.import initlib, donelib
|
||||||
.import callmain, zerobss
|
.import callmain, zerobss, callirq
|
||||||
|
.import __INTERRUPTOR_COUNT__
|
||||||
.import __RAM_START__, __RAM_SIZE__
|
.import __RAM_START__, __RAM_SIZE__
|
||||||
.import __ZPSAVE_LOAD__, __STACKSIZE__
|
.import __ZPSAVE_LOAD__, __STACKSIZE__
|
||||||
|
|
||||||
@ -69,9 +70,24 @@ L1: lda sp,x
|
|||||||
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||||
sta sp+1 ; Set argument stack ptr
|
sta sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
|
; If we have IRQ functions, chain our stub into the IRQ vector
|
||||||
|
|
||||||
|
lda #<__INTERRUPTOR_COUNT__
|
||||||
|
beq NoIRQ1
|
||||||
|
lda IRQVec
|
||||||
|
ldx IRQVec+1
|
||||||
|
sta IRQInd+1
|
||||||
|
stx IRQInd+2
|
||||||
|
lda #<IRQStub
|
||||||
|
ldx #>IRQStub
|
||||||
|
sei
|
||||||
|
sta IRQVec
|
||||||
|
stx IRQVec+1
|
||||||
|
cli
|
||||||
|
|
||||||
; Call module constructors
|
; Call module constructors
|
||||||
|
|
||||||
jsr initlib
|
NoIRQ1: jsr initlib
|
||||||
|
|
||||||
; Push arguments and call main()
|
; Push arguments and call main()
|
||||||
|
|
||||||
@ -81,9 +97,21 @@ L1: lda sp,x
|
|||||||
|
|
||||||
_exit: jsr donelib ; Run module destructors
|
_exit: jsr donelib ; Run module destructors
|
||||||
|
|
||||||
|
; Reset the IRQ vector if we chained it.
|
||||||
|
|
||||||
|
pha ; Save the return code on stack
|
||||||
|
lda #<__INTERRUPTOR_COUNT__
|
||||||
|
beq NoIRQ2
|
||||||
|
lda IRQInd+1
|
||||||
|
ldx IRQInd+2
|
||||||
|
sei
|
||||||
|
sta IRQVec
|
||||||
|
stx IRQVec+1
|
||||||
|
cli
|
||||||
|
|
||||||
; Restore system stuff
|
; Restore system stuff
|
||||||
|
|
||||||
ldx spsave
|
NoIRQ2: ldx spsave
|
||||||
txs
|
txs
|
||||||
lda stsave
|
lda stsave
|
||||||
sta STATUS
|
sta STATUS
|
||||||
@ -100,13 +128,26 @@ L2: lda zpsave,x
|
|||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
; The IRQ vector jumps here, if condes routines are defined with type 2.
|
||||||
|
|
||||||
|
IRQStub:
|
||||||
|
cld ; Just to be sure
|
||||||
|
jsr callirq ; Call the functions
|
||||||
|
jmp IRQInd ; Jump to the saved IRQ vector
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Data
|
; Data
|
||||||
|
|
||||||
|
.data
|
||||||
|
|
||||||
|
IRQInd: jmp $0000
|
||||||
|
|
||||||
.segment "ZPSAVE"
|
.segment "ZPSAVE"
|
||||||
|
|
||||||
zpsave: .res zpspace
|
zpsave: .res zpspace
|
||||||
|
|
||||||
.bss
|
.bss
|
||||||
|
|
||||||
spsave: .res 1
|
spsave: .res 1
|
||||||
stsave: .res 1
|
stsave: .res 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user