]> git.sur5r.net Git - cc65/commitdiff
New condes module
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 20 Nov 2000 22:17:14 +0000 (22:17 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 20 Nov 2000 22:17:14 +0000 (22:17 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@458 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/runtime/Makefile
libsrc/runtime/condes.s [new file with mode: 0644]

index 533f60a2a1da47a8602f5ebddfc6dea6eaa47fab..f800c1d0b9522b7e4cd3c078eb9f0fdea3fa9cca 100644 (file)
@@ -33,6 +33,7 @@ OBJS =        add.o           \
                bpushbsp.o      \
                call.o          \
                compl.o         \
+       condes.o        \
        decax1.o        \
        decax2.o        \
        decaxy.o        \
diff --git a/libsrc/runtime/condes.s b/libsrc/runtime/condes.s
new file mode 100644 (file)
index 0000000..f0a1fab
--- /dev/null
@@ -0,0 +1,46 @@
+;
+; Ullrich von Bassewitz, 20.11.2000
+;
+; CC65 runtime: Support for calling module constructors/destructors
+;
+; The condes routine must be called with the table address in a/x and the
+; number of vectors in the table in y. The current implementation limits
+; the table size to 128 bytes (64 vectors) but this shouldn't be problem
+; for now and may be changed later.
+;
+
+               .export condes
+               .import jmpvec
+
+.code
+
+condes:        sta     getbyt+1
+       stx     getbyt+2
+       sty     index
+
+loop:  ldy     index
+       beq     done
+       dey
+       jsr     getbyt
+       sta     jmpvec+2
+       dey
+       jsr     getbyt
+       sta     jmpvec+1
+       jsr     jmpvec
+       jmp     loop
+
+done:  rts
+
+; --------------------------------------------------------------------------
+; Data. The getbyte routine is placed in the data segment cause it's patched
+; at runtime.
+
+.bss
+
+index: .byte   0
+
+.data
+
+getbyt:        lda     $FFFF,y
+       rts
+