]> git.sur5r.net Git - cc65/blob - libsrc/runtime/condes.s
First condes feature test
[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         sty     index
30         jsr     jmpvec
31         jmp     loop
32
33 done:   rts
34
35 ; --------------------------------------------------------------------------
36 ; Data. The getbyte routine is placed in the data segment cause it's patched
37 ; at runtime.
38
39 .bss
40
41 index:  .byte   0
42
43 .data
44
45 getbyt: lda     $FFFF,y
46         rts
47