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
16 ; The function does also export jmpvec as general purpose jump vector that
17 ; lies in the data segment so it's address may be patched at runtime.
20 .export initlib, donelib, condes
23 .import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
24 .import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
30 ; --------------------------------------------------------------------------
31 ; Initialize library modules
35 lda #<__CONSTRUCTOR_TABLE__
36 ldx #>__CONSTRUCTOR_TABLE__
37 ldy #<(__CONSTRUCTOR_COUNT__*2)
44 ; --------------------------------------------------------------------------
45 ; Cleanup library modules
49 lda #<__DESTRUCTOR_TABLE__
50 ldx #>__DESTRUCTOR_TABLE__
51 ldy #<(__DESTRUCTOR_COUNT__*2)
58 ; --------------------------------------------------------------------------
59 ; Generic table call handler
88 ; --------------------------------------------------------------------------
89 ; Data. The getbyte routine is placed in the data segment cause it's patched