Working on the condes feature

git-svn-id: svn://svn.cc65.org/cc65/trunk@464 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2000-11-21 10:51:53 +00:00
parent 23937f1dac
commit 8d94ef3fea
2 changed files with 57 additions and 7 deletions

View File

@@ -67,7 +67,6 @@ OBJS = add.o \
incsp6.o \ incsp6.o \
incsp7.o \ incsp7.o \
incsp8.o \ incsp8.o \
jmpvec.o \
ladd.o \ ladd.o \
laddeq.o \ laddeq.o \
laddeqsp.o \ laddeqsp.o \

View File

@@ -4,17 +4,62 @@
; CC65 runtime: Support for calling module constructors/destructors ; CC65 runtime: Support for calling module constructors/destructors
; ;
; The condes routine must be called with the table address in a/x and the ; The condes routine must be called with the table address in a/x and the
; number of vectors in the table in y. The current implementation limits ; size of the table in y. The current implementation limits the table size
; the table size to 128 bytes (64 vectors) but this shouldn't be problem ; to 254 bytes (127 vectors) but this shouldn't be problem for now and may
; for now and may be changed later. ; be changed later.
;
; libinit and libdone call condes with the predefined module constructor and
; destructor tables, they must be called from the platform specific startup
; code.
;
; The function does also export jmpvec as general purpose jump vector that
; lies in the data segment so it's address may be patched at runtime.
; ;
.export condes .export libinit, libdone, condes
.import jmpvec .export jmpvec
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
.import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
.code .code
condes: sta getbyt+1 ; --------------------------------------------------------------------------
; Initialize library modules
.proc libinit
lda #<__CONSTRUCTOR_TABLE__
ldx #>__CONSTRUCTOR_TABLE__
ldy #<(__CONSTRUCTOR_COUNT__*2)
bne condes
rts
.endproc
; --------------------------------------------------------------------------
; Cleanup library modules
.proc libdone
lda #<__DESTRUCTOR_TABLE__
ldx #>__DESTRUCTOR_TABLE__
ldy #<(__DESTRUCTOR_COUNT__*2)
bne condes
rts
.endproc
; --------------------------------------------------------------------------
; Generic table call handler
.proc condes
sta getbyt+1
stx getbyt+2 stx getbyt+2
sty index sty index
@@ -32,6 +77,9 @@ loop: ldy index
done: rts done: rts
.endproc
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Data. The getbyte routine is placed in the data segment cause it's patched ; Data. The getbyte routine is placed in the data segment cause it's patched
; at runtime. ; at runtime.
@@ -45,3 +93,6 @@ index: .byte 0
getbyt: lda $FFFF,y getbyt: lda $FFFF,y
rts rts
jmpvec: jmp $FFFF