.macpack cpu
-.code
-
; --------------------------------------------------------------------------
; Initialize library modules
+.segment "INIT"
+
.proc initlib
- ldy #<(__CONSTRUCTOR_COUNT__*2)
+ ldy #<(__CONSTRUCTOR_COUNT__*2)
beq exit
- lda #<__CONSTRUCTOR_TABLE__
- ldx #>__CONSTRUCTOR_TABLE__
+ lda #<__CONSTRUCTOR_TABLE__
+ ldx #>__CONSTRUCTOR_TABLE__
jmp condes
exit: rts
; --------------------------------------------------------------------------
; Cleanup library modules
+.code
+
.proc donelib
ldy #<(__DESTRUCTOR_COUNT__*2)
- beq initlib::exit
+ beq exit
lda #<__DESTRUCTOR_TABLE__
ldx #>__DESTRUCTOR_TABLE__
jmp condes
+exit: rts
.endproc
; --------------------------------------------------------------------------
-; Generic table call handler. Since the routine is also used to call a table
-; of interrupt handlers, it uses heavily self modifying code for performance
-; reasons. It will go into the data segment for this reason ...
+; Generic table call handler. The code uses self modifying code and goes
+; into the data segment for this reason.
; NOTE: The routine must not be called if the table is empty!
.data