2 ; Ullrich von Bassewitz, 20.11.2000
4 ; CC65 runtime: Support for calling module constructors/destructors
6 ; The condes routine must be called with the table address in a/x and the
7 ; size of the table in y. The current implementation limits the table size
8 ; to 254 bytes (127 vectors) but this shouldn't be problem for now and may
11 ; libinit and libdone call condes with the predefined module constructor and
12 ; destructor tables, they must be called from the platform specific startup
15 ; The function does also export jmpvec as general purpose jump vector that
16 ; lies in the data segment so it's address may be patched at runtime.
19 .export initlib, donelib, condes
22 .import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
23 .import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
29 ; --------------------------------------------------------------------------
30 ; Initialize library modules
34 lda #<__CONSTRUCTOR_TABLE__
35 ldx #>__CONSTRUCTOR_TABLE__
36 ldy #<(__CONSTRUCTOR_COUNT__*2)
43 ; --------------------------------------------------------------------------
44 ; Cleanup library modules
48 lda #<__DESTRUCTOR_TABLE__
49 ldx #>__DESTRUCTOR_TABLE__
50 ldy #<(__DESTRUCTOR_COUNT__*2)
57 ; --------------------------------------------------------------------------
58 ; Generic table call handler
83 ; --------------------------------------------------------------------------
84 ; Data. The getbyte routine is placed in the data segment cause it's patched