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 .export initlib, donelib, condes
18 .import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
19 .import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
25 ; --------------------------------------------------------------------------
26 ; Initialize library modules
30 lda #<__CONSTRUCTOR_TABLE__
31 ldx #>__CONSTRUCTOR_TABLE__
32 ldy #<(__CONSTRUCTOR_COUNT__*2)
39 ; --------------------------------------------------------------------------
40 ; Cleanup library modules
44 lda #<__DESTRUCTOR_TABLE__
45 ldx #>__DESTRUCTOR_TABLE__
46 ldy #<(__DESTRUCTOR_COUNT__*2)
53 ; --------------------------------------------------------------------------
54 ; Generic table call handler. We cannot use callax here, since condes is also
55 ; used for interrupt handlers, and callax clobbers ptr1.
73 .if (.cpu .bitand ::CPU_ISET_65SC02)
84 ; --------------------------------------------------------------------------
85 ; Data. The getbyte and jmpvec routines are placed in the data segment
86 ; cause they're patched at runtime.