]> git.sur5r.net Git - cc65/blob - libsrc/runtime/condes.s
New condes module
[cc65] / libsrc / runtime / condes.s
1 ;
2 ; Ullrich von Bassewitz, 20.11.2000
3 ;
4 ; CC65 runtime: Support for calling module constructors/destructors
5 ;
6 ; The condes routine must be called with the table address in a/x and the
7 ; number of vectors in the table in y. The current implementation limits
8 ; the table size to 128 bytes (64 vectors) but this shouldn't be problem
9 ; for now and may be changed later.
10 ;
11
12         .export condes
13         .import jmpvec
14
15 .code
16
17 condes: sta     getbyt+1
18         stx     getbyt+2
19         sty     index
20
21 loop:   ldy     index
22         beq     done
23         dey
24         jsr     getbyt
25         sta     jmpvec+2
26         dey
27         jsr     getbyt
28         sta     jmpvec+1
29         jsr     jmpvec
30         jmp     loop
31
32 done:   rts
33
34 ; --------------------------------------------------------------------------
35 ; Data. The getbyte routine is placed in the data segment cause it's patched
36 ; at runtime.
37
38 .bss
39
40 index:  .byte   0
41
42 .data
43
44 getbyt: lda     $FFFF,y
45         rts
46