1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 07:29:33 +00:00

Added constructor support (contributed by Stefan Haubenthal).

git-svn-id: svn://svn.cc65.org/cc65/trunk@3757 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2006-08-17 19:19:55 +00:00
parent aa217e4535
commit 39f096b34e
2 changed files with 56 additions and 4 deletions

View File

@ -145,7 +145,15 @@ No extended memory drivers are currently available for the PET.
<sect1>Joystick drivers<p>
No joystick drivers are currently available for the PET.
<descrip>
<tag><tt/pet-ptvjoy.joy/</tag>
Driver for the Protovision 4-player adapter contributed by Groepaz. See
<htmlurl url="http://www.protovision-online.de/hardw/hardwstart.htm"
name="http://www.protovision-online.de/hardw/hardwstart.htm"> for prices and
building instructions. Up to two joysticks are supported.
</descrip><p>
<sect1>Mouse drivers<p>
@ -191,6 +199,15 @@ The program return code (low byte) is passed back to BASIC by use of the
<tt/ST/ variable.
<sect1>Interrupts<p>
The runtime for the PET uses routines marked as <tt/.CONDES/ type 2 for
interrupt handlers. Such routines must be written as simple machine language
subroutines and will be called automatically by the interrupt handler code
when they are linked into a program. See the discussion of the <tt/.CONDES/
feature in the <htmlurl url="ca65.html" name="assembler manual">.
<sect1>Using extended memory<p>
The extended memory at $9000 of the CBM 8x96 may be added to the heap by using

View File

@ -5,10 +5,11 @@
;
.export _exit
.import initlib, donelib
.import initlib, donelib, callirq
.import zerobss, push0
.import callmain
.import CLRCH, BSOUT
.import __INTERRUPTOR_COUNT__
.include "zeropage.inc"
.include "pet.inc"
@ -65,14 +66,40 @@ L1: lda sp,x
jsr initlib
; 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
; Push arguments and call main()
jsr callmain
NoIRQ1: jsr callmain
; Call module destructors. This is also the _exit entry.
_exit: pha ; Save the return code on stack
jsr donelib ; Run module destructors
lda #<__INTERRUPTOR_COUNT__
beq NoIRQ2
lda IRQInd+1
ldx IRQInd+2
sei
sta IRQVec
stx IRQVec+1
cli
; Run module destructors
NoIRQ2: jsr donelib ; Run module destructors
; Copy back the zero page stuff
@ -96,6 +123,13 @@ L2: lda zpsave,x
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
@ -103,6 +137,7 @@ L2: lda zpsave,x
.data
zpsave: .res zpspace
IRQInd: jmp $0000
.bss