├── rules.1802 ├── rules.8070 ├── rules.hc08 ├── rules.thread ├── rules.z180 ├── test ├── wtests │ ├── out.input132.c │ ├── out.input002.c │ ├── out.input005.c │ ├── out.input012.c │ ├── out.input017.c │ ├── out.input019.c │ ├── out.input020.c │ ├── out.input112.c │ ├── out.input114.c │ ├── out.input133.c │ ├── out.input117.c │ ├── out.input119.c │ ├── out.input136.c │ ├── out.input137.c │ ├── out.input152.c │ ├── out.input013.c │ ├── out.input016.c │ ├── out.input018.c │ ├── out.input067.c │ ├── out.input130.c │ ├── out.input134.c │ ├── out.input135.c │ ├── out.input18a.c │ ├── out.input001.c │ ├── out.input014.c │ ├── out.input053.c │ ├── out.input100.c │ ├── out.input125.c │ ├── out.input127.c │ ├── out.input139.c │ ├── out.input021.c │ ├── out.input090.c │ ├── out.input107.c │ ├── out.input110.c │ ├── out.input147.c │ ├── out.input003.c │ ├── out.input015.c │ ├── out.input022.c │ ├── out.input024.c │ ├── out.input116.c │ ├── out.input128.c │ ├── out.input151.c │ ├── out.input074.c │ ├── out.input025.c │ ├── out.input140.c │ ├── out.input115.c │ ├── out.input028.c │ ├── out.input080.c │ ├── out.input131.c │ ├── out.input148.c │ ├── Makefile │ ├── out.input150.c │ ├── out.input004.c │ ├── out.input029.c │ ├── out.input006.c │ ├── out.input007.c │ ├── out.input008.c │ ├── out.input009.c │ ├── out.input145.c │ ├── out.input120.c │ ├── out.input023.c │ ├── out.input121.c │ ├── out.input026.c │ ├── out.input010.c │ ├── input132.c │ ├── out.input071.c │ ├── out.input091.c │ ├── input114.c │ ├── out.input143.c │ ├── input053.c │ ├── out.input122.c │ ├── out.input146.c │ ├── out.input149.c │ ├── input130.c │ ├── out.input011.c │ ├── out.input027.c │ ├── out.input138.c │ ├── input017.c │ ├── input133.c │ ├── input054.c │ ├── input020.c │ ├── input117.c │ ├── input001.c │ ├── input007.c │ ├── input008.c │ ├── input018.c │ ├── input100.c │ ├── input002.c │ ├── input006.c │ ├── input012.c │ ├── input090.c │ ├── input080.c │ ├── input119.c │ ├── input152.c │ ├── input120.c │ ├── input139.c │ ├── input005.c │ ├── input016.c │ ├── input112.c │ ├── input135.c │ ├── input18a.c │ ├── input019.c │ ├── input136.c │ ├── input147.c │ ├── out.input153.c │ ├── input116.c │ ├── input121.c │ ├── input003.c │ ├── input013.c │ ├── input014.c │ ├── input021.c │ └── input024.c ├── testcrtz80.s ├── testcrt0_tms7000.s ├── lib65c816 │ ├── src │ │ ├── opcodes5.c │ │ ├── opcodes1.c │ │ ├── opcodes2.c │ │ ├── opcodes3.c │ │ └── opcodes4.c │ └── config.mk ├── tests │ ├── 0000-emu.c │ ├── 0005-for.c │ ├── 0509-ptrarg.c │ └── 0105-forlong.c ├── testcrt0_ee200.s ├── z80dis.h ├── testcrt0_byte1802.S ├── testcrt0_nova3.s ├── debug-one-z8 ├── testcrt0_6303.s ├── testcrt0_6803.s ├── testcrt0_nova.s ├── debug-one-6809 ├── debug-one-test ├── debug-one-8080 ├── debug-one-z80 ├── debug-one-6303 ├── debug-one-6803 ├── debug-one-8085 ├── debug-one-hc11 ├── debug-one-6502 ├── debug-one-65c816 ├── debug-one-nova ├── debug-one-8070 ├── debug-one-nova3 ├── debug-one-tms7000 ├── run-test.sh ├── run-testz8.sh ├── tms7k.h ├── testcrt0_6502.s ├── run-test6502.sh ├── run-test6809.sh ├── run-test8080.sh ├── run-test8085.sh ├── run-testnova.sh ├── run-test6303.sh ├── run-test65c816.sh ├── run-test6803.sh ├── run-testhc11.sh ├── run-testnova3.sh └── run-test8070.sh ├── .gitignore ├── rules.7000 ├── backend-super8.c ├── struct.h ├── primary.h ├── declaration.h ├── supportz80 ├── crt0.s ├── __notc.s ├── __cmpgteq0.s ├── __cmplt0.s ├── _abs.s ├── include │ ├── stdbool.h │ └── stddef.h ├── __bcsub.s ├── __ccne.s ├── __cplc.s ├── __not.s ├── __notl.s ├── __bcshl.s ├── __cceq.s ├── __ixsub.s ├── __iysub.s ├── __sex.s ├── __cmpneb.s ├── __borde.s ├── __cpl.s ├── __booll.s ├── __bxorde.s ├── __cmpeqb.s ├── __cmplteq0.s ├── __bcor.s ├── __ccgtl.s ├── __bcand.s ├── __bcxor.s ├── __ccgtul.s ├── __cclteql.s ├── __pushl.s ├── __ccltequl.s ├── __cmpgt0.s ├── __ccgteql.s ├── __ccltl.s ├── __ccgtequl.s ├── __ccgtu.s ├── __ccltul.s ├── __cmpgtu.s ├── __ccltequ.s ├── __shl.s ├── __castc.s ├── __ccequl.s ├── __pluseqc.s ├── __ccneul.s ├── __ldbyte.s ├── __orc.s ├── __ldbytew.s ├── __plus.s ├── __xorc.s ├── __cast_l.s ├── __cceqf.c ├── __ccnef.c ├── __minus.s ├── __xoreqc.s ├── __castu_l.s ├── __oreqc.s ├── __andeqc.s ├── __cast_ul.s ├── __ccltu.s ├── __boolf.c ├── __andc.s ├── __bcmul.s ├── __minuseqc.s └── __postdecc.s ├── initializer.h ├── support6502 ├── crt0.s ├── __cpl.s ├── __boolc.s ├── __notc.s ├── __yasp.s ├── __lstxay.s ├── __bool.s ├── __not.s ├── __asp.s ├── __booll.s ├── __cast_l.s ├── __addyasp.s ├── __netmpc.s ├── __ytmpc.s ├── __ytmp.s ├── zeropage.s ├── __lxaysptmp.s ├── __gteqtmpc.s ├── __andeqtmp.s ├── __eoreqtmp.s ├── __eqeqtmpc.s ├── __notl.s ├── __oraeqtmp.s ├── __pluseq.s ├── __sbceqtmp.s ├── __adceqtmp.s ├── __andtmp.s ├── __cpll.s ├── __eortmp.s ├── __lttmpuc.s ├── __oratmp.s ├── __subysp.s ├── __adctmp.s ├── __gteqtmpuc.s ├── __orl.s ├── __xorl.s ├── __bandl.s ├── __andspy.s ├── __eorspy.s ├── __ldaspy.s ├── __oraspy.s └── __staspy.s ├── support65c816 ├── crt0.s ├── __booll.s ├── __cpll.s ├── __ltxu.s ├── __gteqxu.s ├── __nex.s ├── __not.s ├── __gtxu.s ├── __lteqxu.s ├── __notl.s ├── __bool.s ├── __ltx.s ├── __orl.s ├── __bandl.s ├── __xorl.s ├── __gteqx.s ├── __gtx.s ├── __negatel.s ├── __plusl.s ├── __shreqxu.s ├── __lteqx.s ├── __diveqx.s ├── __diveqxu.s ├── __remeqx.s ├── __remeqxu.s ├── __cast_l.s ├── __eqeqx.s ├── __cceqf.c ├── __ccnef.c ├── __oreqx.s ├── __andeqx.s ├── __muleqx.s ├── __shleqx.s ├── __andeql.s ├── __boolf.c ├── __eoreql.s ├── __minusl.s ├── __oreql.s ├── __muln.s └── __pluseqx.s ├── supportee200 ├── dp.s ├── crt0.s ├── __cpll.s ├── __castc_.s ├── __bandl.s ├── __orl.s ├── __xorl.s └── __negatel.s ├── volatile.h ├── support6800 ├── crt0.s ├── __castc.s ├── __castc_l.s ├── __xplusplusuc.s ├── __cceq.s ├── __ccne.s ├── __pull4.s ├── __xminusminusc.s ├── __castl.s ├── __notl.s ├── __plus.s ├── __minus.s ├── __xminuseq.s ├── __booll.s ├── __cceqf.c ├── __cclt.s ├── __ccltu.s ├── __ccnef.c ├── __pop2.s ├── __abx.s ├── __boolf.c ├── __xshreqc.s └── __xshrequc.s ├── enum.h ├── idxdata.h ├── support8070 ├── crt0.s ├── include │ ├── stdbool.h │ └── stddef.h ├── __pluseqc.s ├── __minuseqc.s ├── __callea.s ├── __castc_.s ├── __muleq.s ├── __cceqf.c ├── __ccnef.c ├── __boolf.c └── __orl.s ├── support8080 ├── crt0.s ├── __not.s ├── __notc.s ├── include │ ├── stdbool.h │ └── stddef.h ├── __cmplt0.s ├── __borde.s ├── __cmpgteq0.s ├── __bxorde.s ├── __bcsub.s ├── __cplc.s ├── __bcand.s ├── __bcor.s ├── __bcxor.s ├── __notl.s ├── __sex.s ├── __bcshl.s ├── __booll.s ├── __ccgtl.s ├── __ccgtul.s ├── __cmpeqb.s ├── __cmpneb.s ├── __ccne.s ├── __cmpgt0.s ├── __cpl.s ├── __cceq.s ├── __cclteql.s ├── __ccltequl.s ├── __pushl.s ├── __cmplteq0.s ├── __ccltl.s ├── __ccltul.s ├── __ccgteql.s ├── __pluseqc.s ├── __castc.s ├── __ccgtequl.s ├── _strlen.s ├── __ccequl.s ├── __cmpeq.s ├── __cmpne.s ├── __ldbyte.s ├── __postdecc.s ├── __andeqde.s ├── __cceqf.c ├── __ccnef.c ├── __ccneul.s ├── __oreqde.s ├── __xoreqde.s ├── __plus.s ├── __cmpltu.s ├── __ldbytew.s ├── __orc.s ├── __andeqc.s ├── __boolf.c ├── __oreqc.s ├── __xorc.s ├── __xoreqc.s └── __cmpgtequ.s ├── support8085 ├── crt0.s ├── __not.s ├── __notc.s ├── include │ ├── stdbool.h │ └── stddef.h ├── __cmplt0.s ├── __bcsub.s ├── __borde.s ├── __cmpgteq0.s ├── __bxorde.s ├── __cplc.s ├── __bcand.s ├── __bcor.s ├── __bcxor.s ├── __notl.s ├── __sex.s ├── __bcshl.s ├── __booll.s ├── __ccgtl.s ├── __ccgtul.s ├── __cmpeqb.s ├── __cmpneb.s ├── __ccne.s ├── __cmpgt0.s ├── __cpl.s ├── __cceq.s ├── __cclteql.s ├── __ccltequl.s ├── __pushl.s ├── __cmplteq0.s ├── __ccltl.s ├── __ccltul.s ├── __ccgteql.s ├── __pluseqc.s ├── __castc.s ├── __ccgtequl.s ├── _strlen.s ├── __ccequl.s ├── __cmpeq.s ├── __cmpne.s ├── __postdecc.s ├── __andeqde.s ├── __cceqf.c ├── __ccnef.c ├── __ccneul.s ├── __oreqde.s ├── __xoreqde.s ├── __plus.s ├── __cmpltu.s ├── __orc.s ├── __andeqc.s ├── __boolf.c ├── __oreqc.s ├── __xorc.s ├── __xoreqc.s ├── __shr.s └── __cmpgtequ.s ├── supportnova3 ├── crt0.s ├── include │ └── stdbool.h ├── __cpll.s ├── __negl.s ├── __minuseq.s ├── __cceqf.c ├── __ccnef.c ├── __plusl.s ├── __postdec.s ├── __minusl.s └── __boolf.c ├── supportnova ├── crt0.s ├── include │ └── stdbool.h ├── __cpll.s ├── __negl.s ├── __cceqf.c ├── __ccnef.c ├── __minuseq.s └── __boolf.c ├── supportz8 ├── crt0.s ├── include │ ├── stdbool.h │ └── stddef.h ├── __mul8.s ├── __jmpr2.s ├── __bool.s ├── __cceqf.c ├── __ccnef.c ├── __boolf.c └── __pnref.s ├── supportsuper8 ├── crt0.s ├── include │ ├── stdbool.h │ └── stddef.h ├── __mul8.s ├── __cceqf.c ├── __ccnef.c ├── __bool.s ├── __jmpr2.s └── __boolf.c ├── supporttms7000 ├── crt0.s ├── include │ ├── stdbool.h │ └── stddef.h ├── __minuseqc.s ├── __pluseqc.s ├── __mul8.s ├── __pnref.s ├── __bool.s ├── __cceqf.c ├── __ccnef.c └── __boolf.c ├── label.h ├── support6303 ├── __derefl.s ├── __castc.s ├── crt0.s ├── __pop4.s ├── __xplusplusuc.s ├── __xminusminusc.s ├── __notl.s ├── __xminuseq.s ├── __booll.s ├── __cpll.s ├── __xminusminus.s ├── __castl.s ├── __xplusplusu.s ├── __cceqf.c ├── __ccnef.c ├── __divul.s ├── __boolf.c ├── __xshreqc.s └── __xshrequc.s ├── rules.ddp ├── support6809 ├── crt0.s ├── __cpll.s ├── __divul.s ├── __castl.s ├── __xminuseq.s ├── __booll.s ├── __notl.s ├── __xplusplusuc.s ├── __remul.s ├── __xminusminusc.s ├── __xminusminus.s ├── __minus.s ├── __cceqf.c ├── __ccnef.c ├── __cceql.s ├── __ccnel.s ├── __boolf.c ├── __xshreqc.s ├── __negatel.s ├── __xshrequc.s ├── __xshreql.s └── __xshrequl.s ├── support68hc11 ├── crt0.s ├── __castc.s ├── __cpll.s ├── __castl.s ├── __divul.s ├── __xplusplusuc.s ├── __booll.s ├── __pop4.s ├── __xminusminusc.s ├── __notl.s ├── __xminuseq.s ├── __xminusminus.s ├── __xplusplusu.s ├── __minus.s ├── __remul.s ├── __cceqf.c ├── __ccnef.c ├── __negatel.s ├── __boolf.c ├── __ccnel.s ├── __xshreqc.s ├── __xshrequc.s ├── __cceql.s ├── __xshreq.s └── __xshreql.s ├── support6803 ├── __castc.s ├── __derefl.s ├── crt0.s ├── __pop4.s ├── __xplusplusuc.s ├── __xminusminusc.s ├── __notl.s ├── __xminuseq.s ├── __booll.s ├── __cpll.s ├── __xminusminus.s ├── __castl.s ├── __xplusplusu.s ├── __cceqf.c ├── __ccnef.c ├── __divul.s ├── __boolf.c ├── __xshreqc.s └── __xshrequc.s ├── cpp ├── rules.ee200 ├── switch.h ├── symtab.h ├── fp ├── __cceqf.c ├── __ccnef.c ├── __ccgtf.c ├── __cclteq.c ├── __ccltf.c └── __ccgteqf.c └── Preprocessor ├── README ├── token1.c └── token2.c /rules.1802: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rules.8070: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rules.hc08: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rules.thread: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rules.z180: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/wtests/out.input132.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/wtests/out.input002.c: -------------------------------------------------------------------------------- 1 | 17 2 | -------------------------------------------------------------------------------- /test/wtests/out.input005.c: -------------------------------------------------------------------------------- 1 | 6 2 | -------------------------------------------------------------------------------- /test/wtests/out.input012.c: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /test/wtests/out.input017.c: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /test/wtests/out.input019.c: -------------------------------------------------------------------------------- 1 | 30 2 | -------------------------------------------------------------------------------- /test/wtests/out.input020.c: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /test/wtests/out.input112.c: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /test/wtests/out.input114.c: -------------------------------------------------------------------------------- 1 | J 2 | -------------------------------------------------------------------------------- /test/wtests/out.input133.c: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | *~ 4 | 5 | -------------------------------------------------------------------------------- /test/wtests/out.input117.c: -------------------------------------------------------------------------------- 1 | Hello 2 | -------------------------------------------------------------------------------- /test/wtests/out.input119.c: -------------------------------------------------------------------------------- 1 | 8 2 | 6 3 | -------------------------------------------------------------------------------- /test/wtests/out.input136.c: -------------------------------------------------------------------------------- 1 | -35 2 | -------------------------------------------------------------------------------- /test/wtests/out.input137.c: -------------------------------------------------------------------------------- 1 | x is 36 2 | -------------------------------------------------------------------------------- /test/wtests/out.input152.c: -------------------------------------------------------------------------------- 1 | 4 2 4 2 | -------------------------------------------------------------------------------- /test/wtests/out.input013.c: -------------------------------------------------------------------------------- 1 | 23 2 | 56 3 | -------------------------------------------------------------------------------- /test/wtests/out.input016.c: -------------------------------------------------------------------------------- 1 | 12 2 | 18 3 | -------------------------------------------------------------------------------- /test/wtests/out.input018.c: -------------------------------------------------------------------------------- 1 | 34 2 | 34 3 | -------------------------------------------------------------------------------- /test/wtests/out.input067.c: -------------------------------------------------------------------------------- 1 | 5 2 | 17 3 | -------------------------------------------------------------------------------- /test/wtests/out.input130.c: -------------------------------------------------------------------------------- 1 | Hello world 2 | -------------------------------------------------------------------------------- /test/wtests/out.input134.c: -------------------------------------------------------------------------------- 1 | 1st match 2 | -------------------------------------------------------------------------------- /test/wtests/out.input135.c: -------------------------------------------------------------------------------- 1 | testing x 2 | -------------------------------------------------------------------------------- /test/wtests/out.input18a.c: -------------------------------------------------------------------------------- 1 | 15 2 | 16 3 | -------------------------------------------------------------------------------- /test/wtests/out.input001.c: -------------------------------------------------------------------------------- 1 | 36 2 | 10 3 | 25 4 | -------------------------------------------------------------------------------- /test/wtests/out.input014.c: -------------------------------------------------------------------------------- 1 | 10 2 | 20 3 | 30 4 | -------------------------------------------------------------------------------- /test/wtests/out.input053.c: -------------------------------------------------------------------------------- 1 | Hello world, 23 2 | -------------------------------------------------------------------------------- /test/wtests/out.input100.c: -------------------------------------------------------------------------------- 1 | Hello world 17 20 2 | -------------------------------------------------------------------------------- /test/wtests/out.input125.c: -------------------------------------------------------------------------------- 1 | 2008 2 | 2008 3 | -------------------------------------------------------------------------------- /test/wtests/out.input127.c: -------------------------------------------------------------------------------- 1 | 2008 2 | 2008 3 | -------------------------------------------------------------------------------- /test/wtests/out.input139.c: -------------------------------------------------------------------------------- 1 | same apparently 2 | -------------------------------------------------------------------------------- /rules.7000: -------------------------------------------------------------------------------- 1 | 2 | jmp %1 3 | %1: 4 | = 5 | %1: 6 | -------------------------------------------------------------------------------- /test/wtests/out.input021.c: -------------------------------------------------------------------------------- 1 | 10 2 | Hello world 3 | -------------------------------------------------------------------------------- /test/wtests/out.input090.c: -------------------------------------------------------------------------------- 1 | 23 100 H Hello world 2 | -------------------------------------------------------------------------------- /test/wtests/out.input107.c: -------------------------------------------------------------------------------- 1 | fish 2 | cow 3 | NULL 4 | -------------------------------------------------------------------------------- /test/wtests/out.input110.c: -------------------------------------------------------------------------------- 1 | 18 2 | 12 3 | 45 4 | 5 5 | -------------------------------------------------------------------------------- /test/wtests/out.input147.c: -------------------------------------------------------------------------------- 1 | 6 2 | 9 3 | 6 4 | 9 5 | -------------------------------------------------------------------------------- /test/wtests/out.input003.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | -------------------------------------------------------------------------------- /test/wtests/out.input015.c: -------------------------------------------------------------------------------- 1 | 18 2 | 18 3 | 12 4 | 12 5 | -------------------------------------------------------------------------------- /test/wtests/out.input022.c: -------------------------------------------------------------------------------- 1 | 100 2 | 100 3 | 101 4 | 103 5 | -------------------------------------------------------------------------------- /test/wtests/out.input024.c: -------------------------------------------------------------------------------- 1 | 2 2 | 59 3 | 57 4 | 8 5 | 7 6 | -------------------------------------------------------------------------------- /test/wtests/out.input116.c: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 2 4 | 3 5 | 4 6 | -------------------------------------------------------------------------------- /test/wtests/out.input128.c: -------------------------------------------------------------------------------- 1 | 10 10 2 | 15 15 3 | 20 20 4 | -------------------------------------------------------------------------------- /test/wtests/out.input151.c: -------------------------------------------------------------------------------- 1 | 0 2 | 5 3 | 7 4 | 9 5 | 9 6 | -------------------------------------------------------------------------------- /backend-super8.c: -------------------------------------------------------------------------------- 1 | #define SUPER8 2 | #include "backend-z8.c" 3 | -------------------------------------------------------------------------------- /test/wtests/out.input074.c: -------------------------------------------------------------------------------- 1 | 100 2 | 5 3 | 7 4 | 100 5 | 100 6 | -------------------------------------------------------------------------------- /struct.h: -------------------------------------------------------------------------------- 1 | extern void struct_declaration(struct symbol *sym); 2 | -------------------------------------------------------------------------------- /test/wtests/out.input025.c: -------------------------------------------------------------------------------- 1 | 10 2 | 20 3 | 30 4 | 5 5 | 15 6 | 25 7 | -------------------------------------------------------------------------------- /test/wtests/out.input140.c: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 4 4 | 9 5 | 16 6 | 5 H 7 | -------------------------------------------------------------------------------- /test/wtests/out.input115.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 4 4 | 2 5 | 7 6 | 22 7 | 16 8 | -------------------------------------------------------------------------------- /test/wtests/out.input028.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 5 5 | 8 6 | 13 7 | 21 8 | 34 9 | -------------------------------------------------------------------------------- /test/wtests/out.input080.c: -------------------------------------------------------------------------------- 1 | 0 1 2 | 1 3 3 | 2 5 4 | 3 7 5 | 4 9 6 | 5 11 7 | -------------------------------------------------------------------------------- /test/wtests/out.input131.c: -------------------------------------------------------------------------------- 1 | Doing nothing... nothing done 2 | x is now 100 3 | -------------------------------------------------------------------------------- /test/wtests/out.input148.c: -------------------------------------------------------------------------------- 1 | i is 1 2 | i is 2 3 | i is 3 4 | leftover owl 5 | -------------------------------------------------------------------------------- /test/wtests/Makefile: -------------------------------------------------------------------------------- 1 | clean: 2 | rm -f a.out *.o *.s *.map *.log typescript 3 | -------------------------------------------------------------------------------- /test/wtests/out.input150.c: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | 4 5 6 3 | 7 8 9 4 | 5 | 1 2 3 6 | 4 5 fish 7 | -------------------------------------------------------------------------------- /primary.h: -------------------------------------------------------------------------------- 1 | extern struct node *primary(void); 2 | extern struct node *constant_node(void); 3 | -------------------------------------------------------------------------------- /test/wtests/out.input004.c: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 1 4 | 1 5 | 1 6 | 1 7 | 1 8 | 1 9 | 1 10 | -------------------------------------------------------------------------------- /test/wtests/out.input029.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 5 5 | 8 6 | 13 7 | 21 8 | 34 9 | 9 10 | -------------------------------------------------------------------------------- /declaration.h: -------------------------------------------------------------------------------- 1 | extern void dotypedef(void); 2 | extern void declaration(unsigned defstorage); 3 | -------------------------------------------------------------------------------- /supportz80/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | 4 | start: 5 | call _main 6 | push hl 7 | call _exit 8 | -------------------------------------------------------------------------------- /test/wtests/out.input006.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /test/wtests/out.input007.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /test/wtests/out.input008.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /test/wtests/out.input009.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /test/wtests/out.input145.c: -------------------------------------------------------------------------------- 1 | q 2 | w 3 | e 4 | r 5 | e 6 | 3 7 | 5 8 | 7 9 | 9 10 | 7 11 | -------------------------------------------------------------------------------- /initializer.h: -------------------------------------------------------------------------------- 1 | extern void initializers(struct symbol *sym, unsigned type, unsigned storage); 2 | 3 | -------------------------------------------------------------------------------- /support6502/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | 4 | start: 5 | jsr _main 6 | jsr __push0 7 | jsr _exit 8 | -------------------------------------------------------------------------------- /support65c816/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | 4 | start: 5 | jsr _main 6 | jsr __push0 7 | jsr _exit 8 | -------------------------------------------------------------------------------- /supportee200/dp.s: -------------------------------------------------------------------------------- 1 | .setcpu 4 2 | .export __hireg 3 | 4 | .bss 5 | 6 | __hireg: 7 | .word 0 8 | -------------------------------------------------------------------------------- /test/wtests/out.input120.c: -------------------------------------------------------------------------------- 1 | 9 2 | 10 3 | 11 4 | 12 5 | 13 6 | 7 7 | 8 8 | 9 9 | 10 10 | 11 11 | -------------------------------------------------------------------------------- /volatile.h: -------------------------------------------------------------------------------- 1 | extern void add_volatile(unsigned sym); 2 | extern unsigned is_volatile(unsigned sym); 3 | -------------------------------------------------------------------------------- /support6800/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | 4 | start: 5 | jsr _main 6 | pshb 7 | psha 8 | jsr _exit 9 | -------------------------------------------------------------------------------- /supportee200/crt0.s: -------------------------------------------------------------------------------- 1 | .setcpu 4 2 | .code 3 | 4 | start: 5 | jsr _main 6 | stb (-s) 7 | jsr _exit 8 | -------------------------------------------------------------------------------- /test/testcrtz80.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Stub crt for running tests 3 | ; 4 | call _main 5 | ld a,l 6 | out (0xFF),a 7 | -------------------------------------------------------------------------------- /test/wtests/out.input023.c: -------------------------------------------------------------------------------- 1 | -23 2 | 100 3 | -2 4 | 0 5 | 1 6 | 0 7 | 13 8 | 14 9 | Hello world 10 | -------------------------------------------------------------------------------- /test/wtests/out.input121.c: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | 5 5 | 13 6 | 14 7 | 15 8 | 16 9 | 1000 10 | 1000 11 | -------------------------------------------------------------------------------- /enum.h: -------------------------------------------------------------------------------- 1 | extern unsigned find_constant(unsigned name, unsigned *value); 2 | extern unsigned enum_body(void); 3 | -------------------------------------------------------------------------------- /idxdata.h: -------------------------------------------------------------------------------- 1 | extern unsigned *idx_get(unsigned len); 2 | extern unsigned *idx_copy(unsigned *from, unsigned len); 3 | -------------------------------------------------------------------------------- /support8070/crt0.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; 3 | ; 4 | .code 5 | 6 | start: 7 | jsr _main 8 | push ea 9 | jsr _exit 10 | -------------------------------------------------------------------------------- /support8080/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | .setcpu 8080 4 | 5 | start: 6 | call _main 7 | push h 8 | call _exit 9 | -------------------------------------------------------------------------------- /support8085/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | .setcpu 8085 4 | 5 | start: 6 | call _main 7 | push h 8 | call _exit 9 | -------------------------------------------------------------------------------- /test/wtests/out.input026.c: -------------------------------------------------------------------------------- 1 | 13 2 | 23 3 | 34 4 | 44 5 | 54 6 | 64 7 | 74 8 | 84 9 | 94 10 | 95 11 | 96 12 | -------------------------------------------------------------------------------- /supportnova3/crt0.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | __main: 4 | jsr @1,1 5 | .word _main 6 | psha 1 7 | jsr @1,1 8 | ; .word _exit 9 | -------------------------------------------------------------------------------- /test/wtests/out.input010.c: -------------------------------------------------------------------------------- 1 | 20 2 | 10 3 | 1 4 | 2 5 | 3 6 | 4 7 | 5 8 | 253 9 | 254 10 | 255 11 | 0 12 | 1 13 | -------------------------------------------------------------------------------- /supportnova/crt0.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | __main: 4 | jsr @1,1 5 | .word _main 6 | sta 1,__sp,0 7 | jsr @1,1 8 | ; .word _exit 9 | -------------------------------------------------------------------------------- /supportz8/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | 4 | start: 5 | call _main 6 | clr r0 7 | push r0 8 | push r0 9 | call _exit 10 | -------------------------------------------------------------------------------- /supportz80/__notc.s: -------------------------------------------------------------------------------- 1 | .export __notc 2 | .code 3 | 4 | __notc: 5 | ld a,l 6 | or a 7 | jp z,__true 8 | jp __false 9 | -------------------------------------------------------------------------------- /test/testcrt0_tms7000.s: -------------------------------------------------------------------------------- 1 | movd %0xefff,r15 2 | mov %0x20,b 3 | ldsp 4 | call @_main 5 | mov r5,a 6 | movp a,p255 7 | 8 | -------------------------------------------------------------------------------- /supportsuper8/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | 4 | start: 5 | call _main 6 | clr r0 7 | push r0 8 | push r0 9 | call _exit 10 | -------------------------------------------------------------------------------- /supportz80/__cmpgteq0.s: -------------------------------------------------------------------------------- 1 | .export __cmpgteq0 2 | .code 3 | 4 | __cmpgteq0: 5 | bit 7,h 6 | jp nz,__false 7 | jp __true 8 | -------------------------------------------------------------------------------- /test/wtests/input132.c: -------------------------------------------------------------------------------- 1 | extern int fred; 2 | int fred; 3 | 4 | int mary; 5 | extern int mary; 6 | 7 | int main() { return(0); } 8 | -------------------------------------------------------------------------------- /test/wtests/out.input071.c: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 2 4 | 3 5 | 4 6 | 7 7 | 8 8 | 9 9 | 10 10 | 11 11 | 12 12 | 13 13 | 14 14 | Done 15 | -------------------------------------------------------------------------------- /test/wtests/out.input091.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 1 7 | 2 8 | 3 9 | 4 10 | 5 11 | 0 12 | 0 13 | 0 14 | 0 15 | 0 16 | -------------------------------------------------------------------------------- /test/lib65c816/src/opcodes5.c: -------------------------------------------------------------------------------- 1 | #define NATIVE_MODE 2 | #undef SHORT_M 3 | #undef SHORT_X 4 | #define CPUMODE e0m0x0 5 | #include "opcodes.h" 6 | -------------------------------------------------------------------------------- /test/wtests/input114.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | int main() { 3 | int x= 0x4a; 4 | cprintf("%c\n", x); 5 | return(0); 6 | } 7 | -------------------------------------------------------------------------------- /test/wtests/out.input143.c: -------------------------------------------------------------------------------- 1 | One of the three is NULL 2 | One of the three is NULL 3 | One of the three is NULL 4 | All three are non-NULL 5 | -------------------------------------------------------------------------------- /test/lib65c816/src/opcodes1.c: -------------------------------------------------------------------------------- 1 | #undef NATIVE_MODE 2 | #define SHORT_M 3 | #define SHORT_X 4 | #define CPUMODE e1m1x1 5 | #include "opcodes.h" 6 | -------------------------------------------------------------------------------- /test/lib65c816/src/opcodes2.c: -------------------------------------------------------------------------------- 1 | #define NATIVE_MODE 2 | #define SHORT_M 3 | #define SHORT_X 4 | #define CPUMODE e0m1x1 5 | #include "opcodes.h" 6 | -------------------------------------------------------------------------------- /test/lib65c816/src/opcodes3.c: -------------------------------------------------------------------------------- 1 | #define NATIVE_MODE 2 | #undef SHORT_M 3 | #define SHORT_X 4 | #define CPUMODE e0m0x1 5 | #include "opcodes.h" 6 | -------------------------------------------------------------------------------- /test/lib65c816/src/opcodes4.c: -------------------------------------------------------------------------------- 1 | #define NATIVE_MODE 2 | #define SHORT_M 3 | #undef SHORT_X 4 | #define CPUMODE e0m1x0 5 | #include "opcodes.h" 6 | -------------------------------------------------------------------------------- /test/tests/0000-emu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test the framework works at all 3 | */ 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /test/wtests/input053.c: -------------------------------------------------------------------------------- 1 | int cprintf(char *fmt, ...); 2 | 3 | int main() 4 | { 5 | cprintf("Hello world, %d\n", 23); 6 | return(0); 7 | } 8 | -------------------------------------------------------------------------------- /supporttms7000/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | 4 | start: 5 | call @_main 6 | ; TODO; this will be right once we fix first arg in regs 7 | call @_exit 8 | -------------------------------------------------------------------------------- /test/testcrt0_ee200.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; EE200 wrapper for testing 3 | ; 4 | .code 5 | 6 | lda 0xE000 7 | xas 8 | jsr _main 9 | stbb (0xFFFF) 10 | -------------------------------------------------------------------------------- /supportz80/__cmplt0.s: -------------------------------------------------------------------------------- 1 | .export __cmplt0 2 | 3 | .code 4 | 5 | __cmplt0: 6 | ld a,h 7 | or a 8 | jp m,__true 9 | jp __false 10 | 11 | -------------------------------------------------------------------------------- /test/wtests/out.input122.c: -------------------------------------------------------------------------------- 1 | x 0, y 0, x || y 0, x && y 0 2 | x 0, y 1, x || y 1, x && y 0 3 | x 1, y 0, x || y 1, x && y 0 4 | x 1, y 1, x || y 1, x && y 1 5 | -------------------------------------------------------------------------------- /label.h: -------------------------------------------------------------------------------- 1 | extern void init_labels(void); 2 | extern void check_labels(void); 3 | extern void add_label(unsigned name); 4 | extern void use_label(unsigned name); 5 | -------------------------------------------------------------------------------- /support6303/__derefl.s: -------------------------------------------------------------------------------- 1 | .export __derefl 2 | .setcpu 6303 3 | .code 4 | 5 | __derefl: 6 | xgdx 7 | ldd ,x 8 | std @hireg 9 | ldd 2,x 10 | rts 11 | -------------------------------------------------------------------------------- /support8080/__not.s: -------------------------------------------------------------------------------- 1 | .export __not 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __not: 7 | mov a,h 8 | ora l 9 | jz __true 10 | jmp __false 11 | -------------------------------------------------------------------------------- /support8085/__not.s: -------------------------------------------------------------------------------- 1 | .export __not 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __not: 7 | mov a,h 8 | ora l 9 | jz __true 10 | jmp __false 11 | -------------------------------------------------------------------------------- /test/wtests/out.input146.c: -------------------------------------------------------------------------------- 1 | q 2 | w 3 | e 4 | r 5 | e 6 | r 7 | e 8 | r 9 | e 10 | 11 | 3 12 | 5 13 | 7 14 | 9 15 | 7 16 | 9 17 | 7 18 | 9 19 | 7 20 | -------------------------------------------------------------------------------- /test/wtests/out.input149.c: -------------------------------------------------------------------------------- 1 | 1 -4 2 | 2 -8 3 | 3 -12 4 | 4 -16 5 | 5 -21 6 | 6 -27 7 | 7 -34 8 | 8 -42 9 | 9 -51 10 | 10 -61 11 | 11 -72 12 | 12 -84 13 | -------------------------------------------------------------------------------- /rules.ddp: -------------------------------------------------------------------------------- 1 | jmp %1 2 | %1: 3 | = 4 | %1: 5 | 6 | # We have no MMIO so this is fine as a rewrite 7 | sta %1,1 8 | ; 9 | lda %1,1 10 | = 11 | sta %1,1 12 | -------------------------------------------------------------------------------- /support6800/__castc.s: -------------------------------------------------------------------------------- 1 | .export __castc_ 2 | .export __castc_u 3 | 4 | __castc_: 5 | __castc_u: 6 | clra 7 | asrb 8 | rolb 9 | sbca #$00 10 | rts 11 | -------------------------------------------------------------------------------- /support8080/__notc.s: -------------------------------------------------------------------------------- 1 | .export __notc 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __notc: 7 | mov a,l 8 | ora a 9 | jz __true 10 | jmp __false 11 | -------------------------------------------------------------------------------- /support8085/__notc.s: -------------------------------------------------------------------------------- 1 | .export __notc 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __notc: 7 | mov a,l 8 | ora a 9 | jz __true 10 | jmp __false 11 | -------------------------------------------------------------------------------- /supportnova/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDBOOL_H 2 | #define __STDBOOL_H 3 | 4 | typedef unsigned int bool; 5 | 6 | #define true 1 7 | #define false 0 8 | #endif 9 | -------------------------------------------------------------------------------- /supportz8/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDBOOL_H 2 | #define __STDBOOL_H 3 | 4 | typedef unsigned char bool; 5 | 6 | #define true 1 7 | #define false 0 8 | #endif 9 | -------------------------------------------------------------------------------- /supportz80/_abs.s: -------------------------------------------------------------------------------- 1 | 2 | .export _abs 3 | 4 | _abs: 5 | pop de 6 | pop hl 7 | push hl 8 | push de 9 | bit 7,h 10 | ret z 11 | jp __negate 12 | 13 | -------------------------------------------------------------------------------- /supportz80/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDBOOL_H 2 | #define __STDBOOL_H 3 | 4 | typedef unsigned char bool; 5 | 6 | #define true 1 7 | #define false 0 8 | #endif 9 | -------------------------------------------------------------------------------- /test/wtests/input130.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | char *x= "foo"; 4 | 5 | int main() { 6 | cprintf("Hello " "world" "\n"); 7 | return(0); 8 | } 9 | -------------------------------------------------------------------------------- /support6809/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | start: 4 | clra 5 | clrb 6 | std @zero 7 | incb 8 | std @one 9 | lbsr _main 10 | pshs d 11 | lbsr _exit 12 | -------------------------------------------------------------------------------- /support68hc11/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | start: 4 | ldd #0 5 | std @zero 6 | ldd #1 7 | std @one 8 | jsr _main 9 | ldx #0 10 | pshx 11 | jsr _exit 12 | -------------------------------------------------------------------------------- /support8070/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDBOOL_H 2 | #define __STDBOOL_H 3 | 4 | typedef unsigned char bool; 5 | 6 | #define true 1 7 | #define false 0 8 | #endif 9 | -------------------------------------------------------------------------------- /support8080/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDBOOL_H 2 | #define __STDBOOL_H 3 | 4 | typedef unsigned char bool; 5 | 6 | #define true 1 7 | #define false 0 8 | #endif 9 | -------------------------------------------------------------------------------- /support8085/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDBOOL_H 2 | #define __STDBOOL_H 3 | 4 | typedef unsigned char bool; 5 | 6 | #define true 1 7 | #define false 0 8 | #endif 9 | -------------------------------------------------------------------------------- /supportnova3/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDBOOL_H 2 | #define __STDBOOL_H 3 | 4 | typedef unsigned int bool; 5 | 6 | #define true 1 7 | #define false 0 8 | #endif 9 | -------------------------------------------------------------------------------- /supportsuper8/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDBOOL_H 2 | #define __STDBOOL_H 3 | 4 | typedef unsigned char bool; 5 | 6 | #define true 1 7 | #define false 0 8 | #endif 9 | -------------------------------------------------------------------------------- /supporttms7000/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDBOOL_H 2 | #define __STDBOOL_H 3 | 4 | typedef unsigned char bool; 5 | 6 | #define true 1 7 | #define false 0 8 | #endif 9 | -------------------------------------------------------------------------------- /supportz80/__bcsub.s: -------------------------------------------------------------------------------- 1 | .export __bcsub 2 | .code 3 | 4 | 5 | __bcsub: ld a,c 6 | sub l 7 | ld c,a 8 | ld a,b 9 | sbc a,h 10 | ld b,a 11 | ret 12 | -------------------------------------------------------------------------------- /test/z80dis.h: -------------------------------------------------------------------------------- 1 | 2 | /* Entry point */ 3 | extern void z80_disasm(char *buf, uint16_t pc); 4 | 5 | /* Caller provided */ 6 | extern uint8_t z80dis_byte(uint16_t addr); 7 | -------------------------------------------------------------------------------- /support6502/__cpl.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Complement XA 3 | ; 4 | .export __cpl 5 | 6 | __cpl: 7 | pha 8 | txa 9 | eor #0xFF 10 | tax 11 | pla 12 | eor #0xFF 13 | rts 14 | -------------------------------------------------------------------------------- /supportz80/__ccne.s: -------------------------------------------------------------------------------- 1 | .export __ccne 2 | .code 3 | 4 | __ccne: ex de,hl 5 | pop hl 6 | ex (sp),hl 7 | or a 8 | sbc hl,de 9 | ret z 10 | jp __true 11 | -------------------------------------------------------------------------------- /supportz80/__cplc.s: -------------------------------------------------------------------------------- 1 | .export __negatec 2 | .export __cplc 3 | .code 4 | 5 | __negatec: 6 | dec l 7 | __cplc: 8 | ld a,l 9 | cpl 10 | ld l,a 11 | ret 12 | -------------------------------------------------------------------------------- /supportz80/__not.s: -------------------------------------------------------------------------------- 1 | .export __not 2 | .export __cctonot 3 | .code 4 | 5 | __not: 6 | ld a,h 7 | or l 8 | __cctonot: 9 | jp z,__true 10 | jp __false 11 | -------------------------------------------------------------------------------- /test/wtests/out.input011.c: -------------------------------------------------------------------------------- 1 | 10 2 | 20 3 | 30 4 | 1 5 | 2 6 | 3 7 | 4 8 | 5 9 | 253 10 | 254 11 | 255 12 | 0 13 | 1 14 | 2 15 | 3 16 | 1 17 | 2 18 | 3 19 | 4 20 | 5 21 | -------------------------------------------------------------------------------- /support6303/__castc.s: -------------------------------------------------------------------------------- 1 | .export __castc_ 2 | .export __castc_u 3 | 4 | __castc_: 5 | __castc_u: 6 | clra 7 | bitb #$80 8 | beq ispve 9 | deca 10 | ispve: 11 | rts 12 | -------------------------------------------------------------------------------- /support6803/__castc.s: -------------------------------------------------------------------------------- 1 | .export __castc_ 2 | .export __castc_u 3 | 4 | __castc_: 5 | __castc_u: 6 | clra 7 | bitb #$80 8 | beq ispve 9 | deca 10 | ispve: 11 | rts 12 | -------------------------------------------------------------------------------- /support6803/__derefl.s: -------------------------------------------------------------------------------- 1 | .export __derefl 2 | .setcpu 6803 3 | .code 4 | 5 | __derefl: 6 | std @tmp 7 | ldx @tmp 8 | ldd ,x 9 | std @hireg 10 | ldd 2,x 11 | rts 12 | -------------------------------------------------------------------------------- /support8070/__pluseqc.s: -------------------------------------------------------------------------------- 1 | .export __pluseqc 2 | 3 | ; (TOS.B) += A 4 | 5 | __pluseqc: 6 | pop p2 7 | pop p3 8 | push p2 9 | add a,0,p3 10 | st a,0,p3 11 | ret 12 | -------------------------------------------------------------------------------- /support8080/__cmplt0.s: -------------------------------------------------------------------------------- 1 | .export __cmplt0 2 | .setcpu 8080 3 | 4 | .code 5 | 6 | __cmplt0: 7 | mov a,h 8 | ora a 9 | jm __true 10 | jmp __false 11 | 12 | -------------------------------------------------------------------------------- /support8085/__cmplt0.s: -------------------------------------------------------------------------------- 1 | .export __cmplt0 2 | .setcpu 8080 3 | 4 | .code 5 | 6 | __cmplt0: 7 | mov a,h 8 | ora a 9 | jm __true 10 | jmp __false 11 | 12 | -------------------------------------------------------------------------------- /test/testcrt0_byte1802.S: -------------------------------------------------------------------------------- 1 | #include "../support1802/1802ops.h" 2 | .code 3 | start: 4 | .byte op_callfname ; callfname 5 | .word _main 6 | .byte op_native ; traps back out 7 | -------------------------------------------------------------------------------- /support68hc11/__castc.s: -------------------------------------------------------------------------------- 1 | .export __castc_ 2 | .export __castc_u 3 | 4 | __castc_: 5 | __castc_u: 6 | clra 7 | bitb #$80 8 | beq ispve 9 | deca 10 | ispve: 11 | rts 12 | -------------------------------------------------------------------------------- /support8080/__borde.s: -------------------------------------------------------------------------------- 1 | .export __borde 2 | .code 3 | .setcpu 8080 4 | 5 | __borde: 6 | mov a,d 7 | ora h 8 | mov h,a 9 | mov a,e 10 | ora l 11 | mov l,a 12 | ret 13 | -------------------------------------------------------------------------------- /support8080/__cmpgteq0.s: -------------------------------------------------------------------------------- 1 | .export __cmpgteq0 2 | .setcpu 8080 3 | 4 | .code 5 | 6 | __cmpgteq0: 7 | mov a,h 8 | ora a 9 | jm __false 10 | jmp __true 11 | 12 | -------------------------------------------------------------------------------- /support8085/__bcsub.s: -------------------------------------------------------------------------------- 1 | .export __bcsub 2 | .setcpu 8080 3 | .code 4 | 5 | __bcsub: mov a,c 6 | sub l 7 | mov c,a 8 | mov a,b 9 | sbb h 10 | mov b,a 11 | ret 12 | -------------------------------------------------------------------------------- /support8085/__borde.s: -------------------------------------------------------------------------------- 1 | .export __borde 2 | .code 3 | .setcpu 8080 4 | 5 | __borde: 6 | mov a,d 7 | ora h 8 | mov h,a 9 | mov a,e 10 | ora l 11 | mov l,a 12 | ret 13 | -------------------------------------------------------------------------------- /support8085/__cmpgteq0.s: -------------------------------------------------------------------------------- 1 | .export __cmpgteq0 2 | .setcpu 8080 3 | 4 | .code 5 | 6 | __cmpgteq0: 7 | mov a,h 8 | ora a 9 | jm __false 10 | jmp __true 11 | 12 | -------------------------------------------------------------------------------- /supportz80/__notl.s: -------------------------------------------------------------------------------- 1 | .export __notl 2 | .code 3 | 4 | __notl: 5 | ld a,h 6 | or l 7 | ld hl,(__hireg) 8 | or h 9 | or l 10 | jp z,__true 11 | jp __false 12 | -------------------------------------------------------------------------------- /test/wtests/out.input027.c: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 1 10 | 2 11 | 3 12 | 4 13 | 5 14 | 1 15 | 2 16 | 3 17 | 4 18 | 5 19 | 1 20 | 2 21 | 3 22 | 4 23 | 5 24 | -------------------------------------------------------------------------------- /cpp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Temporary until we get our own cpp 3 | # 4 | if [ -e /lib/cpp ] ; then 5 | /lib/cpp -undef -nostdinc $* 6 | else 7 | /bin/cpp -undef -nostdinc $* 8 | fi 9 | 10 | -------------------------------------------------------------------------------- /rules.ee200: -------------------------------------------------------------------------------- 1 | # Branches 2 | jmp %1 3 | %1: 4 | = 5 | %1: 6 | 7 | jmp %2 8 | %1: 9 | %2: 10 | = 11 | %1: 12 | %2: 13 | 14 | jmp L%1 15 | jmp L%2 16 | = 17 | jmp L%1 18 | 19 | -------------------------------------------------------------------------------- /support8080/__bxorde.s: -------------------------------------------------------------------------------- 1 | .export __bxorde 2 | .code 3 | .setcpu 8080 4 | 5 | __bxorde: 6 | mov a,d 7 | xra h 8 | mov h,a 9 | mov a,e 10 | xra l 11 | mov l,a 12 | ret 13 | -------------------------------------------------------------------------------- /support8085/__bxorde.s: -------------------------------------------------------------------------------- 1 | .export __bxorde 2 | .code 3 | .setcpu 8080 4 | 5 | __bxorde: 6 | mov a,d 7 | xra h 8 | mov h,a 9 | mov a,e 10 | xra l 11 | mov l,a 12 | ret 13 | -------------------------------------------------------------------------------- /supportz80/__bcshl.s: -------------------------------------------------------------------------------- 1 | .export __bcshl 2 | .code 3 | 4 | __bcshl: 5 | ; shift BC right by E 6 | ld l,c 7 | ld h,b 8 | call __shlde 9 | ld c,l 10 | ld b,h 11 | ret 12 | -------------------------------------------------------------------------------- /supportz80/__cceq.s: -------------------------------------------------------------------------------- 1 | .export __cceq 2 | 3 | .code 4 | 5 | __cceq: ex de,hl 6 | pop hl 7 | ex (sp),hl 8 | or a 9 | sbc hl,de 10 | jp nz,__false 11 | jp __true 12 | -------------------------------------------------------------------------------- /supportz80/__ixsub.s: -------------------------------------------------------------------------------- 1 | .export __ixsub 2 | .code 3 | 4 | 5 | __ixsub: ex de,hl 6 | push ix 7 | pop hl 8 | or a 9 | sbc hl,de 10 | push hl 11 | pop ix 12 | ret 13 | -------------------------------------------------------------------------------- /supportz80/__iysub.s: -------------------------------------------------------------------------------- 1 | .export __iysub 2 | .code 3 | 4 | 5 | __iysub: ex de,hl 6 | push iy 7 | pop hl 8 | or a 9 | sbc hl,de 10 | push hl 11 | pop iy 12 | ret 13 | -------------------------------------------------------------------------------- /test/wtests/out.input138.c: -------------------------------------------------------------------------------- 1 | 0 0 | 0 2 | 0 1 | 0 3 | 1 0 | 0 4 | 1 1 | 1 5 | 0 0 | 0 6 | 0 1 | 1 7 | 1 0 | 1 8 | 1 1 | 1 9 | aptr is NULL or doesn't point at 1 10 | aptr points at 1 11 | -------------------------------------------------------------------------------- /support6303/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | .setcpu 6803 4 | 5 | start: 6 | ldd #0 7 | std @zero 8 | ldd #1 9 | std @one 10 | jsr _main 11 | ldx #0 12 | pshx 13 | jsr _exit 14 | -------------------------------------------------------------------------------- /support6803/crt0.s: -------------------------------------------------------------------------------- 1 | 2 | .code 3 | .setcpu 6803 4 | 5 | start: 6 | ldd #0 7 | std @zero 8 | ldd #1 9 | std @one 10 | jsr _main 11 | ldx #0 12 | pshx 13 | jsr _exit 14 | -------------------------------------------------------------------------------- /support8080/__bcsub.s: -------------------------------------------------------------------------------- 1 | .export __bcsub 2 | .setcpu 8080 3 | .code 4 | 5 | 6 | __bcsub: mov a,c 7 | sub l 8 | mov c,a 9 | mov a,b 10 | sbb h 11 | mov b,a 12 | ret 13 | -------------------------------------------------------------------------------- /supportz80/__sex.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Sign extend L into HL 3 | ; 4 | .export __sex 5 | .code 6 | 7 | __sex: 8 | ld a,l 9 | ld h,0 10 | or a 11 | ret p 12 | dec h 13 | ret 14 | 15 | -------------------------------------------------------------------------------- /support6502/__boolc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Turn A into 0 or 1 and flags 3 | ; 4 | .export __boolc 5 | 6 | __boolc: 7 | ldx #0 8 | cmp #0 9 | bne setit 10 | rts 11 | setit: 12 | lda #1 13 | rts 14 | -------------------------------------------------------------------------------- /support65c816/__booll.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __booll 6 | 7 | __booll: 8 | stz @hireg 9 | ora @hireg 10 | beq done ; A already zero 11 | lda #1 12 | done: rts 13 | -------------------------------------------------------------------------------- /support68hc11/__cpll.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Long complement. Possibly inlinable 3 | ; 4 | .export __cpll 5 | .code 6 | __cpll: 7 | coma 8 | comb 9 | xgdy 10 | coma 11 | comb 12 | xgdy 13 | rts 14 | -------------------------------------------------------------------------------- /supportnova3/__cpll.s: -------------------------------------------------------------------------------- 1 | .export f__cpll 2 | .code 3 | 4 | f__cpll: 5 | sta 3,__tmp,0 6 | lda 0,__hireg,0 7 | com 0,0 8 | com 1,1 9 | sta 0,__hireg,0 10 | mffp 3 11 | jmp @__tmp,0 12 | -------------------------------------------------------------------------------- /supportnova3/__negl.s: -------------------------------------------------------------------------------- 1 | .export f__negl 2 | .code 3 | 4 | f__negl: 5 | sta 3,__tmp,0 6 | lda 0,__hireg,0 7 | neg 1,1,snr 8 | neg 0,0,skp 9 | com 0,0 10 | mffp 3 11 | jmp @__tmp,0 12 | -------------------------------------------------------------------------------- /test/wtests/input017.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | 3 | int main() { 4 | int d; 5 | int *e; 6 | 7 | d= 100; 8 | e= &d; 9 | *e= 12; 10 | printint(d); 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /test/wtests/input133.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | extern int fred[]; 4 | int fred[23]; 5 | 6 | char mary[100]; 7 | extern char mary[]; 8 | 9 | void main() { cprintf("OK\n"); } 10 | -------------------------------------------------------------------------------- /support6502/__notc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Turn A into 0 or 1 and flags 3 | ; 4 | 5 | .export __notc 6 | __notc: 7 | ldx #0 8 | cmp #0 9 | beq setit 10 | txa 11 | rts 12 | setit: 13 | lda #1 14 | rts 15 | -------------------------------------------------------------------------------- /support6502/__yasp.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Return XA = YA + SP 3 | ; 4 | .export __yasp 5 | 6 | .code 7 | 8 | __yasp: 9 | clc 10 | adc @sp 11 | pha 12 | tya 13 | adc @sp+1 14 | tax 15 | pla 16 | rts -------------------------------------------------------------------------------- /support65c816/__cpll.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __cpll 6 | 7 | __cpll: 8 | eor #0xFFFF 9 | pha 10 | lda #0xFFFF 11 | eor @hireg 12 | sta @hireg 13 | pla 14 | rts 15 | -------------------------------------------------------------------------------- /support65c816/__ltxu.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | .export __ltxu 5 | 6 | __ltxu: 7 | stx @tmp 8 | sec 9 | sbc @tmp 10 | bcc true 11 | lda #0 12 | rts 13 | true: lda #1 14 | rts 15 | -------------------------------------------------------------------------------- /support6800/__castc_l.s: -------------------------------------------------------------------------------- 1 | .export __castc_l 2 | .export __castc_ul 3 | 4 | __castc_l: 5 | __castc_ul: 6 | clra 7 | asrb 8 | rolb 9 | sbca #$00 10 | sta @hireg 11 | sta @hireg+1 12 | rts 13 | -------------------------------------------------------------------------------- /support6800/__xplusplusuc.s: -------------------------------------------------------------------------------- 1 | .export __xplusplusuc 2 | .export __xplusplusc 3 | 4 | .code 5 | 6 | __xplusplusc: 7 | __xplusplusuc: 8 | tba 9 | ldab ,x 10 | aba 11 | staa ,x 12 | rts 13 | -------------------------------------------------------------------------------- /support6809/__cpll.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Long complement. Possibly inlinable 3 | ; 4 | .export __cpll 5 | .code 6 | __cpll: 7 | coma 8 | comb 9 | exg d,y 10 | coma 11 | comb 12 | exg d,y 13 | rts 14 | -------------------------------------------------------------------------------- /support6809/__divul.s: -------------------------------------------------------------------------------- 1 | .export __divul 2 | .code 3 | __divul: 4 | std ,--s 5 | sty ,--s 6 | tfr s,x 7 | lbsr div32x32 8 | ldy 6,x 9 | ldd 8,x 10 | ldx 4,x 11 | leas 10,s 12 | jmp ,x 13 | -------------------------------------------------------------------------------- /support8080/__cplc.s: -------------------------------------------------------------------------------- 1 | .export __negatec 2 | .export __cplc 3 | 4 | .setcpu 8080 5 | .code 6 | 7 | __negatec: 8 | dcr l 9 | __cplc: 10 | mov a,l 11 | cma 12 | mov l,a 13 | ret 14 | -------------------------------------------------------------------------------- /support8085/__cplc.s: -------------------------------------------------------------------------------- 1 | .export __negatec 2 | .export __cplc 3 | 4 | .setcpu 8080 5 | .code 6 | 7 | __negatec: 8 | dcr l 9 | __cplc: 10 | mov a,l 11 | cma 12 | mov l,a 13 | ret 14 | -------------------------------------------------------------------------------- /supportee200/__cpll.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Complement hireg:B 3 | ; 4 | .export __cpll 5 | 6 | .setcpu 4 7 | 8 | .code 9 | __cpll: 10 | lda (__hireg) 11 | ivr b 12 | iva 13 | sta (__hireg) 14 | rsr 15 | -------------------------------------------------------------------------------- /supportnova/__cpll.s: -------------------------------------------------------------------------------- 1 | .export f__cpll 2 | .code 3 | 4 | f__cpll: 5 | sta 3,__tmp,0 6 | lda 0,__hireg,0 7 | com 0,0 8 | com 1,1 9 | sta 0,__hireg,0 10 | lda 3,__fp,0 11 | jmp @__tmp,0 12 | -------------------------------------------------------------------------------- /supportnova/__negl.s: -------------------------------------------------------------------------------- 1 | .export f__negl 2 | .code 3 | 4 | f__negl: 5 | sta 3,__tmp,0 6 | lda 0,__hireg,0 7 | neg 1,1,snr 8 | neg 0,0,skp 9 | com 0,0 10 | lda 3,__fp,0 11 | jmp @__tmp,0 12 | -------------------------------------------------------------------------------- /supportz80/__cmpneb.s: -------------------------------------------------------------------------------- 1 | .export __cmpneb 2 | .code 3 | 4 | ; 5 | ; Tighter version with the other value in DE 6 | ; 7 | __cmpneb: 8 | ld a,l 9 | cp e 10 | jp nz,__true 11 | jp __false 12 | -------------------------------------------------------------------------------- /switch.h: -------------------------------------------------------------------------------- 1 | extern void switch_done(unsigned tag, unsigned long *oldptr, unsigned type); 2 | extern unsigned long *switch_alloc(void); 3 | extern void switch_add_node(unsigned long value); 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/wtests/input054.c: -------------------------------------------------------------------------------- 1 | int cprintf(char *fmt, ...); 2 | 3 | int main() 4 | { 5 | int i; 6 | for (i=0; i < 20; i++) { 7 | cprintf("Hello world, %d\n", i); 8 | } 9 | return(0); 10 | } 11 | -------------------------------------------------------------------------------- /support6303/__pop4.s: -------------------------------------------------------------------------------- 1 | .export __pop4 2 | .code 3 | 4 | __false4: 5 | clrb 6 | __true4: 7 | ldb #1 8 | __pop4: 9 | clra 10 | pulx 11 | ins 12 | ins 13 | ins 14 | ins 15 | tstb 16 | jmp ,x 17 | -------------------------------------------------------------------------------- /support6502/__lstxay.s: -------------------------------------------------------------------------------- 1 | .export __lstaxy 2 | .code 3 | 4 | ; Compiler knows this increments Y 5 | 6 | __lstaxy: 7 | pha 8 | sta (@sp),y 9 | txa 10 | iny 11 | sta (@sp),y 12 | pla 13 | rts 14 | -------------------------------------------------------------------------------- /support65c816/__gteqxu.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __gteqxu 6 | 7 | __gteqxu: 8 | stx @tmp 9 | sec 10 | sbc @tmp 11 | lda #0 ; move carry into A 12 | rol a 13 | rts 14 | 15 | -------------------------------------------------------------------------------- /support6803/__pop4.s: -------------------------------------------------------------------------------- 1 | .export __pop4 2 | .code 3 | 4 | __false4: 5 | clrb 6 | __true4: 7 | ldb #1 8 | __pop4: 9 | clra 10 | pulx 11 | ins 12 | ins 13 | ins 14 | ins 15 | tstb 16 | jmp ,x 17 | -------------------------------------------------------------------------------- /support6809/__castl.s: -------------------------------------------------------------------------------- 1 | .export __cast_l 2 | .export __cast_ul 3 | .code 4 | 5 | __cast_ul: 6 | __cast_l: 7 | bita #0x80 8 | beq extpv 9 | ldy #-1 10 | rts 11 | extpv: 12 | ldy #0 13 | rts 14 | -------------------------------------------------------------------------------- /support6809/__xminuseq.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X -= D 3 | ; 4 | .export __xminuseq 5 | .export __xminusequ 6 | 7 | __xminuseq: 8 | __xminusequ: 9 | std ,--s 10 | ldd ,x 11 | subd ,s++ 12 | std ,x 13 | rts 14 | -------------------------------------------------------------------------------- /support68hc11/__castl.s: -------------------------------------------------------------------------------- 1 | .export __cast_l 2 | .export __cast_ul 3 | .code 4 | 5 | __cast_ul: 6 | __cast_l: 7 | bita #0x80 8 | beq extpv 9 | ldy #-1 10 | rts 11 | extpv: 12 | ldy #0 13 | rts 14 | -------------------------------------------------------------------------------- /support68hc11/__divul.s: -------------------------------------------------------------------------------- 1 | .export __divul 2 | .code 3 | __divul: 4 | pshb 5 | psha 6 | pshy 7 | tsx 8 | jsr div32x32 9 | pulx 10 | pulx 11 | pulx 12 | puly 13 | pula 14 | pulb 15 | jmp ,x 16 | -------------------------------------------------------------------------------- /support68hc11/__xplusplusuc.s: -------------------------------------------------------------------------------- 1 | .export __xplusplusuc 2 | .export __xplusplusc 3 | 4 | .code 5 | 6 | __xplusplusc: 7 | __xplusplusuc: 8 | tba 9 | ldab ,x 10 | aba 11 | staa ,x 12 | rts 13 | -------------------------------------------------------------------------------- /support8080/__bcand.s: -------------------------------------------------------------------------------- 1 | .export __bcana 2 | .setcpu 8080 3 | .code 4 | 5 | __bcana: 6 | ; BC &= HL 7 | mov a,h 8 | ana b 9 | mov b,a 10 | mov a,l 11 | ana c 12 | mov c,a 13 | ret 14 | -------------------------------------------------------------------------------- /support8080/__bcor.s: -------------------------------------------------------------------------------- 1 | .export __bcora 2 | .setcpu 8080 3 | .code 4 | 5 | __bcora: 6 | ; BC &= HL 7 | mov a,h 8 | ora b 9 | mov b,a 10 | mov a,l 11 | ora c 12 | mov c,a 13 | ret 14 | -------------------------------------------------------------------------------- /support8080/__bcxor.s: -------------------------------------------------------------------------------- 1 | .export __bcxra 2 | .setcpu 8080 3 | .code 4 | 5 | __bcxra: 6 | ; BC &= HL 7 | mov a,h 8 | xra b 9 | mov b,a 10 | mov a,l 11 | xra c 12 | mov c,a 13 | ret 14 | -------------------------------------------------------------------------------- /support8080/__notl.s: -------------------------------------------------------------------------------- 1 | .export __notl 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __notl: 7 | mov a,h 8 | ora l 9 | lhld __hireg 10 | ora h 11 | ora l 12 | jz __true 13 | jmp __false 14 | -------------------------------------------------------------------------------- /support8080/__sex.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Sign extend L into HL 3 | ; 4 | .export __sex 5 | .setcpu 8080 6 | .code 7 | 8 | __sex: 9 | mov a,l 10 | mvi h,0 11 | ora a 12 | rp 13 | dcr h 14 | ret 15 | -------------------------------------------------------------------------------- /support8085/__bcand.s: -------------------------------------------------------------------------------- 1 | .export __bcana 2 | .setcpu 8080 3 | .code 4 | 5 | __bcana: 6 | ; BC &= HL 7 | mov a,h 8 | ana b 9 | mov b,a 10 | mov a,l 11 | ana c 12 | mov c,a 13 | ret 14 | -------------------------------------------------------------------------------- /support8085/__bcor.s: -------------------------------------------------------------------------------- 1 | .export __bcora 2 | .setcpu 8080 3 | .code 4 | 5 | __bcora: 6 | ; BC &= HL 7 | mov a,h 8 | ora b 9 | mov b,a 10 | mov a,l 11 | ora c 12 | mov c,a 13 | ret 14 | -------------------------------------------------------------------------------- /support8085/__bcxor.s: -------------------------------------------------------------------------------- 1 | .export __bcxra 2 | .setcpu 8080 3 | .code 4 | 5 | __bcxra: 6 | ; BC &= HL 7 | mov a,h 8 | xra b 9 | mov b,a 10 | mov a,l 11 | xra c 12 | mov c,a 13 | ret 14 | -------------------------------------------------------------------------------- /support8085/__notl.s: -------------------------------------------------------------------------------- 1 | .export __notl 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __notl: 7 | mov a,h 8 | ora l 9 | lhld __hireg 10 | ora h 11 | ora l 12 | jz __true 13 | jmp __false 14 | -------------------------------------------------------------------------------- /support8085/__sex.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Sign extend L into HL 3 | ; 4 | .export __sex 5 | .setcpu 8080 6 | .code 7 | 8 | __sex: 9 | mov a,l 10 | mvi h,0 11 | ora a 12 | rp 13 | dcr h 14 | ret 15 | -------------------------------------------------------------------------------- /supportz80/__borde.s: -------------------------------------------------------------------------------- 1 | .export __borde 2 | .export __borde0d 3 | .code 4 | 5 | __borde: 6 | ld a,d 7 | or h 8 | ld h,a 9 | __borde0d: 10 | ld a,e 11 | or l 12 | ld l,a 13 | ret 14 | -------------------------------------------------------------------------------- /supportz80/__cpl.s: -------------------------------------------------------------------------------- 1 | .export __negate 2 | .export __cpl 3 | .code 4 | 5 | __negate: 6 | dec hl 7 | __cpl: 8 | ld a,h 9 | cpl 10 | ld h,a 11 | ld a,l 12 | cpl 13 | ld l,a 14 | ret 15 | -------------------------------------------------------------------------------- /symtab.h: -------------------------------------------------------------------------------- 1 | #define MAXNAME 1024 2 | 3 | #define NAMELEN 16 /* 15 usable due to _ lead on C names */ 4 | 5 | struct name { 6 | char name[NAMELEN]; 7 | uint16_t id; 8 | struct name *next; 9 | }; 10 | -------------------------------------------------------------------------------- /test/wtests/input020.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int a; 5 | int b[25]; 6 | 7 | int main() { 8 | b[3]= 12; 9 | a= b[3]; 10 | printint(a); 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /test/wtests/input117.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | static char *fred(void) { 4 | return("Hello"); 5 | } 6 | 7 | int main(void) { 8 | cprintf("%s\n", fred()); 9 | return(0); 10 | } 11 | -------------------------------------------------------------------------------- /support6502/__bool.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Turn XA into 0 or 1 and flags 3 | ; 4 | .export __bool 5 | 6 | __bool: 7 | stx @tmp 8 | ldx #0 9 | ora @tmp 10 | bne setit 11 | rts 12 | setit: 13 | lda #1 14 | rts 15 | -------------------------------------------------------------------------------- /support6800/__cceq.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare D with TOS 3 | ; 4 | .export __cceq 5 | 6 | __cceq: 7 | tsx 8 | subb 3,x 9 | bne false 10 | suba 2,x 11 | bne false 12 | jmp __true2 13 | false: jmp __false2 14 | -------------------------------------------------------------------------------- /support6800/__ccne.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare D with TOS 3 | ; 4 | .export __ccne 5 | 6 | __ccne: 7 | tsx 8 | subb 3,x 9 | bne true 10 | suba 2,x 11 | bne true 12 | jmp __false2 13 | true: jmp __true2 14 | -------------------------------------------------------------------------------- /support6809/__booll.s: -------------------------------------------------------------------------------- 1 | .export __booll 2 | .code 3 | __booll: 4 | cmpy #0 5 | bne true 6 | subd #0 7 | beq false ; If this passes then D is already zero 8 | true: 9 | ldd @one 10 | false: 11 | rts 12 | -------------------------------------------------------------------------------- /support68hc11/__booll.s: -------------------------------------------------------------------------------- 1 | .export __booll 2 | .code 3 | __booll: 4 | cpy #0 5 | bne true 6 | subd #0 7 | beq false ; If this passes then D is already zero 8 | true: 9 | ldd @one 10 | false: 11 | rts 12 | -------------------------------------------------------------------------------- /support68hc11/__pop4.s: -------------------------------------------------------------------------------- 1 | .export __pop4 2 | .code 3 | 4 | __false4: 5 | clrb 6 | __true4: 7 | ldb #1 8 | __pop4: 9 | clra 10 | pulx 11 | ins 12 | ins 13 | ins 14 | ins 15 | tstb 16 | jmp ,x 17 | -------------------------------------------------------------------------------- /support8070/__minuseqc.s: -------------------------------------------------------------------------------- 1 | .export __minuseqc 2 | 3 | ; (TOS.B) += A 4 | 5 | __minuseqc: 6 | pop p2 7 | pop p3 8 | push p2 9 | st a,:__tmp 10 | ld a,0,p3 11 | sub a,:__tmp 12 | st a,0,p3 13 | ret 14 | -------------------------------------------------------------------------------- /support8080/__bcshl.s: -------------------------------------------------------------------------------- 1 | .export __bcshl 2 | .setcpu 8080 3 | .code 4 | 5 | __bcshl: 6 | ; shift BC right by E 7 | mov l,c 8 | mov h,b 9 | call __shlde 10 | mov c,l 11 | mov b,h 12 | ret 13 | -------------------------------------------------------------------------------- /support8085/__bcshl.s: -------------------------------------------------------------------------------- 1 | .export __bcshl 2 | .setcpu 8080 3 | .code 4 | 5 | __bcshl: 6 | ; shift BC right by E 7 | mov l,c 8 | mov h,b 9 | call __shlde 10 | mov c,l 11 | mov b,h 12 | ret 13 | -------------------------------------------------------------------------------- /supporttms7000/__minuseqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; *TOS - AC 3 | ; 4 | .export __minuseqc 5 | .code 6 | 7 | 8 | __minuseqc: 9 | call @__pop12 10 | lda *r13 11 | sub a,r5 12 | sta *r13 13 | mov a,r5 14 | rets 15 | -------------------------------------------------------------------------------- /supportz8/__mul8.s: -------------------------------------------------------------------------------- 1 | .export __mul8 2 | .export __mul4 3 | 4 | .code 5 | 6 | __mul8: 7 | add r3,r3 8 | adc r2,r2 9 | __mul4: 10 | add r3,r3 11 | adc r2,r2 12 | add r3,r3 13 | adc r2,r2 14 | ret 15 | -------------------------------------------------------------------------------- /supportz80/__booll.s: -------------------------------------------------------------------------------- 1 | .export __booll 2 | 3 | .code 4 | 5 | __booll: 6 | ld a,h 7 | or l 8 | ld hl,(__hireg) 9 | or h 10 | or l 11 | ld hl,0 12 | ret z 13 | inc l ; NZ 14 | ret 15 | -------------------------------------------------------------------------------- /supportz80/__bxorde.s: -------------------------------------------------------------------------------- 1 | .export __bxorde 2 | .export __bxorde0d 3 | .code 4 | 5 | __bxorde: 6 | ld a,d 7 | xor h 8 | ld h,a 9 | __bxorde0d: 10 | ld a,e 11 | xor l 12 | ld l,a 13 | ret 14 | -------------------------------------------------------------------------------- /supportz80/__cmpeqb.s: -------------------------------------------------------------------------------- 1 | .export __cmpeqb 2 | 3 | .code 4 | 5 | ; 6 | ; Tighter version with the other value in DE 7 | ; 8 | __cmpeqb: 9 | ld a,l 10 | cp e 11 | jp nz,__false 12 | jp __true 13 | -------------------------------------------------------------------------------- /supportz80/__cmplteq0.s: -------------------------------------------------------------------------------- 1 | .export __cmplteq0 2 | .code 3 | 4 | __cmplteq0: 5 | ld a,h 6 | or a 7 | jp m,__true 8 | jp nz,__false 9 | ld a,l 10 | or a 11 | jp nz,__false 12 | jp __true 13 | -------------------------------------------------------------------------------- /test/wtests/input001.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int main() 5 | { printint(12 * 3); 6 | printint(18 - 2 * 4); 7 | printint(1 + 2 + 9 - 5/2 + 3*5); 8 | return(0); 9 | } 10 | -------------------------------------------------------------------------------- /test/wtests/input007.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int main() 5 | { 6 | int i; 7 | for (i= 1; i <= 10; i= i + 1) { 8 | printint(i); 9 | } 10 | return(0); 11 | } 12 | -------------------------------------------------------------------------------- /test/wtests/input008.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int main() 5 | { 6 | int i; 7 | for (i= 1; i <= 10; i= i + 1) { 8 | printint(i); 9 | } 10 | return(0); 11 | } 12 | -------------------------------------------------------------------------------- /test/wtests/input018.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int main() 5 | { 6 | int a; 7 | int b; 8 | a= b= 34; 9 | printint(a); 10 | printint(b); 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /test/wtests/input100.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | int main() { 3 | int x= 3, y=14; 4 | int z= 2 * x + y; 5 | char *str= "Hello world"; 6 | cprintf("%s %d %d\n", str, x+y, z); 7 | return(0); 8 | } 9 | -------------------------------------------------------------------------------- /support6502/__not.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Turn XA into 0 or 1 and flags 3 | ; 4 | 5 | .export __not 6 | __not: 7 | stx @tmp 8 | ldx #0 9 | ora @tmp 10 | beq setit 11 | txa 12 | rts 13 | setit: 14 | lda #1 15 | rts 16 | -------------------------------------------------------------------------------- /support65c816/__nex.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __nex 6 | .export __nexu 7 | 8 | __nex: 9 | __nexu: 10 | stx @tmp 11 | sec 12 | sbc @tmp 13 | beq false 14 | lda #1 15 | false: rts 16 | -------------------------------------------------------------------------------- /support6800/__pull4.s: -------------------------------------------------------------------------------- 1 | 2 | .export __pull4 3 | .code 4 | 5 | __pull4: 6 | tsx 7 | ldx ,x 8 | ins 9 | ins 10 | pula 11 | pulb 12 | staa @hireg 13 | stab @hireg+1 14 | pula 15 | pulb 16 | jmp ,x 17 | -------------------------------------------------------------------------------- /support6809/__notl.s: -------------------------------------------------------------------------------- 1 | .export __notl 2 | .code 3 | __notl: 4 | cmpy #0 5 | bne false 6 | cmpd #0 7 | beq true 8 | false: 9 | clra 10 | clrb 11 | rts 12 | true: 13 | ; D is zero 14 | incb 15 | rts 16 | -------------------------------------------------------------------------------- /support8070/__callea.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Stub for doing a jsr ea 3 | ; 4 | .export __callea 5 | 6 | __callea: 7 | sub ea,=1 ; because we need to allow for the 8 | ; pre-inc of the PC 9 | ld p0,ea ; PC = EA 10 | -------------------------------------------------------------------------------- /supportee200/__castc_.s: -------------------------------------------------------------------------------- 1 | .setcpu 4 2 | .code 3 | 4 | .export __castc_ 5 | .export __castc_u 6 | 7 | __castc_: 8 | __castc_u: 9 | clrb bh 10 | orib bl,bl 11 | bp done 12 | dcrb bh 13 | done: rsr 14 | 15 | -------------------------------------------------------------------------------- /supportsuper8/__mul8.s: -------------------------------------------------------------------------------- 1 | .export __mul8 2 | .export __mul4 3 | 4 | .code 5 | 6 | __mul8: 7 | add r3,r3 8 | adc r2,r2 9 | __mul4: 10 | add r3,r3 11 | adc r2,r2 12 | add r3,r3 13 | adc r2,r2 14 | ret 15 | -------------------------------------------------------------------------------- /supporttms7000/__pluseqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; *TOS + AC 3 | ; 4 | .export __pluseqc 5 | .code 6 | 7 | 8 | __pluseqc: 9 | call @__pop12 10 | 11 | lda *r13 12 | add r5,a 13 | mov a,r5 14 | sta *r13 15 | rets 16 | -------------------------------------------------------------------------------- /supportz80/__bcor.s: -------------------------------------------------------------------------------- 1 | .export __bcor 2 | .export __bcorc 3 | .code 4 | 5 | __bcor: 6 | ; BC &= HL 7 | ld a,h 8 | or b 9 | ld b,a 10 | __bcorc: 11 | ld a,l 12 | or c 13 | ld c,a 14 | ret 15 | -------------------------------------------------------------------------------- /supportz80/__ccgtl.s: -------------------------------------------------------------------------------- 1 | .export __ccgtl 2 | .code 3 | 4 | __ccgtl: 5 | call __cmplws 6 | pop hl ; return address 7 | pop de ; value 8 | pop de 9 | push hl 10 | jp nc,__false 11 | jp __true 12 | -------------------------------------------------------------------------------- /support6303/__xplusplusuc.s: -------------------------------------------------------------------------------- 1 | .export __xplusplusuc 2 | .export __xplusplusc 3 | 4 | .code 5 | .setcpu 6803 6 | 7 | __xplusplusc: 8 | __xplusplusuc: 9 | tba 10 | ldab ,x 11 | aba 12 | staa ,x 13 | rts 14 | -------------------------------------------------------------------------------- /support65c816/__not.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __not 6 | .export __notc 7 | 8 | __notc: 9 | and #0xFF 10 | __not: 11 | tax 12 | lda #1 13 | cpx #0 14 | beq done 15 | txa 16 | done: rts 17 | -------------------------------------------------------------------------------- /support6803/__xplusplusuc.s: -------------------------------------------------------------------------------- 1 | .export __xplusplusuc 2 | .export __xplusplusc 3 | 4 | .code 5 | .setcpu 6803 6 | 7 | __xplusplusc: 8 | __xplusplusuc: 9 | tba 10 | ldab ,x 11 | aba 12 | staa ,x 13 | rts 14 | -------------------------------------------------------------------------------- /support6809/__xplusplusuc.s: -------------------------------------------------------------------------------- 1 | .export __xplusplusuc 2 | .export __xplusplusc 3 | .code 4 | 5 | __xplusplusc: 6 | __xplusplusuc: 7 | pshs b 8 | lda ,x 9 | tfr a,b 10 | adda ,s+ 11 | sta ,x 12 | rts 13 | 14 | -------------------------------------------------------------------------------- /supportz8/__jmpr2.s: -------------------------------------------------------------------------------- 1 | .export __jmpr2 2 | .code 3 | 4 | ; This way avoids messing with register indirection and working 5 | ; our what our working register bank is 6 | __jmpr2: 7 | push r3 8 | push r2 9 | ret 10 | -------------------------------------------------------------------------------- /supportz80/__bcand.s: -------------------------------------------------------------------------------- 1 | .export __bcand 2 | .export __bcandc 3 | .code 4 | 5 | __bcand: 6 | ; BC &= HL 7 | ld a,h 8 | and b 9 | ld b,a 10 | __bcandc: 11 | ld a,l 12 | and c 13 | ld c,a 14 | ret 15 | -------------------------------------------------------------------------------- /supportz80/__bcxor.s: -------------------------------------------------------------------------------- 1 | .export __bcxor 2 | .export __bcxorc 3 | .code 4 | 5 | __bcxor: 6 | ; BC &= HL 7 | ld a,h 8 | xor b 9 | ld b,a 10 | __bcxorc: 11 | ld a,l 12 | xor c 13 | ld c,a 14 | ret 15 | -------------------------------------------------------------------------------- /supportz80/__ccgtul.s: -------------------------------------------------------------------------------- 1 | .export __ccgtul 2 | .code 3 | 4 | __ccgtul: 5 | call __cmpulws 6 | pop hl ; return address 7 | pop de ; value 8 | pop de 9 | push hl 10 | jp nc,__false 11 | jp __true 12 | -------------------------------------------------------------------------------- /test/wtests/input002.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int main() 5 | { 6 | int fred; 7 | int jim; 8 | fred= 5; 9 | jim= 12; 10 | printint(fred + jim); 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /test/wtests/input006.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int main() 5 | { int i; 6 | i=1; 7 | while (i <= 10) { 8 | printint(i); 9 | i= i + 1; 10 | } 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /test/wtests/input012.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int fred() { 5 | return(5); 6 | } 7 | 8 | int main() { 9 | int x; 10 | x= fred(2); 11 | printint(x); 12 | return(0); 13 | } 14 | -------------------------------------------------------------------------------- /test/wtests/input090.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | int a = 23, b = 100; 4 | char y = 'H', *z = "Hello world"; 5 | 6 | int main() { 7 | cprintf("%d %d %c %s\n", a, b, y, z); 8 | return (0); 9 | } 10 | -------------------------------------------------------------------------------- /support6303/__xminusminusc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X - B 3 | ; 4 | .export __xmminusc 5 | .export __xmminusuc 6 | .code 7 | 8 | __xmminusc: 9 | __xmminusuc: 10 | ldaa ,x 11 | sba 12 | staa ,x 13 | aba 14 | tab 15 | rts 16 | -------------------------------------------------------------------------------- /support6502/__asp.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Return XA = A + SP 3 | ; 4 | ; Must preserve Y and @tmp 5 | ; 6 | .export __asp 7 | 8 | .code 9 | 10 | __asp: 11 | ldx @sp+1 12 | clc 13 | adc @sp 14 | bcc l1 15 | inx 16 | l1: rts 17 | -------------------------------------------------------------------------------- /support6502/__booll.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; 32bit boolean not 3 | ; 4 | .export __booll 5 | 6 | __booll: 7 | stx @tmp 8 | ldx #0 9 | ora @tmp 10 | ora @hireg 11 | ora @hireg+1 12 | beq zero 13 | lda #1 14 | zero: 15 | rts 16 | -------------------------------------------------------------------------------- /support65c816/__gtxu.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __gtxu 6 | 7 | ; A v X 8 | __gtxu: 9 | stx @tmp 10 | cmp @tmp 11 | beq false 12 | bcc false 13 | lda #1 14 | rts 15 | false: lda #0 16 | rts 17 | -------------------------------------------------------------------------------- /support6800/__xminusminusc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X - B 3 | ; 4 | .export __xmminusc 5 | .export __xmminusuc 6 | .code 7 | 8 | __xmminusc: 9 | __xmminusuc: 10 | ldaa ,x 11 | sba 12 | staa ,x 13 | aba 14 | tab 15 | rts 16 | -------------------------------------------------------------------------------- /support6803/__xminusminusc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X - B 3 | ; 4 | .export __xmminusc 5 | .export __xmminusuc 6 | .code 7 | 8 | __xmminusc: 9 | __xmminusuc: 10 | ldaa ,x 11 | sba 12 | staa ,x 13 | aba 14 | tab 15 | rts 16 | -------------------------------------------------------------------------------- /support68hc11/__xminusminusc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X - B 3 | ; 4 | .export __xmminusc 5 | .export __xmminusuc 6 | .code 7 | 8 | __xmminusc: 9 | __xmminusuc: 10 | ldaa ,x 11 | sba 12 | staa ,x 13 | aba 14 | tab 15 | rts 16 | -------------------------------------------------------------------------------- /support8070/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | #include 5 | 6 | #define NULL ((void *)0) 7 | 8 | #define offsetof(type, ident) ((size_t) &((type *)0)->ident) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /support8080/__booll.s: -------------------------------------------------------------------------------- 1 | .export __booll 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __booll: 7 | mov a,h 8 | ora l 9 | lhld __hireg 10 | ora h 11 | ora l 12 | lxi h,0 13 | rz 14 | inr l ; NZ 15 | ret 16 | -------------------------------------------------------------------------------- /support8080/__ccgtl.s: -------------------------------------------------------------------------------- 1 | .export __ccgtl 2 | .setcpu 8080 3 | .code 4 | 5 | __ccgtl: 6 | call __cmplws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jnc __false 12 | jmp __true 13 | -------------------------------------------------------------------------------- /support8080/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | #include 5 | 6 | #define NULL ((void *)0) 7 | 8 | #define offsetof(type, ident) ((size_t) &((type *)0)->ident) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /support8085/__booll.s: -------------------------------------------------------------------------------- 1 | .export __booll 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __booll: 7 | mov a,h 8 | ora l 9 | lhld __hireg 10 | ora h 11 | ora l 12 | lxi h,0 13 | rz 14 | inr l ; NZ 15 | ret 16 | -------------------------------------------------------------------------------- /support8085/__ccgtl.s: -------------------------------------------------------------------------------- 1 | .export __ccgtl 2 | .setcpu 8080 3 | .code 4 | 5 | __ccgtl: 6 | call __cmplws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jnc __false 12 | jmp __true 13 | -------------------------------------------------------------------------------- /support8085/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | #include 5 | 6 | #define NULL ((void *)0) 7 | 8 | #define offsetof(type, ident) ((size_t) &((type *)0)->ident) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /supporttms7000/__mul8.s: -------------------------------------------------------------------------------- 1 | .export __mul8 2 | .export __mul4 3 | 4 | .code 5 | 6 | __mul8: 7 | add r3,r3 8 | adc r2,r2 9 | __mul4: 10 | add r3,r3 11 | adc r2,r2 12 | add r3,r3 13 | adc r2,r2 14 | rets 15 | 16 | -------------------------------------------------------------------------------- /supportz8/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | #include 5 | 6 | #define NULL ((void *)0) 7 | 8 | #define offsetof(type, ident) ((size_t) &((type *)0)->ident) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /supportz80/__cclteql.s: -------------------------------------------------------------------------------- 1 | .export __cclteql 2 | .code 3 | 4 | __cclteql: 5 | call __cmplws 6 | pop hl ; return address 7 | pop de ; value 8 | pop de 9 | push hl 10 | jp nc,__true 11 | jp __false 12 | 13 | -------------------------------------------------------------------------------- /supportz80/__pushl.s: -------------------------------------------------------------------------------- 1 | .export __pushl 2 | .code 3 | 4 | __pushl: 5 | ex de,hl 6 | ld hl,(__hireg) 7 | ex (sp),hl ; swap return address with high byte 8 | push de ; push low byte 9 | jp (hl) ; and back 10 | -------------------------------------------------------------------------------- /supportz80/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | #include 5 | 6 | #define NULL ((void *)0) 7 | 8 | #define offsetof(type, ident) ((size_t) &((type *)0)->ident) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /test/testcrt0_nova3.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Nova 3 test 3 | ; 4 | .code 5 | start: 6 | lda 0,spinit,1 7 | mtsp 0 8 | jsr @1,1 9 | .word _main 10 | nio 0 ; our exit trap device 11 | spinit: 12 | .word 0x7000 ; grows upwards 13 | -------------------------------------------------------------------------------- /support6303/__notl.s: -------------------------------------------------------------------------------- 1 | .export __notl 2 | .code 3 | .setcpu 6803 4 | __notl: 5 | orab @hireg 6 | orab @hireg+1 7 | subd #0 8 | beq true 9 | clra 10 | clrb 11 | rts 12 | true: 13 | incb ; was already 0 14 | rts 15 | -------------------------------------------------------------------------------- /support6303/__xminuseq.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X -= D 3 | ; 4 | .export __xminuseq 5 | .export __xminusequ 6 | 7 | .setcpu 6803 8 | 9 | __xminuseq: 10 | __xminusequ: 11 | std @tmp 12 | ldd ,x 13 | subd @tmp 14 | std ,x 15 | rts 16 | -------------------------------------------------------------------------------- /support65c816/__lteqxu.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __lteqxu 6 | 7 | ; A v X 8 | __lteqxu: 9 | stx @tmp 10 | cmp @tmp 11 | beq true 12 | bcc true 13 | lda #0 14 | rts 15 | true: lda #1 16 | rts 17 | -------------------------------------------------------------------------------- /support6803/__notl.s: -------------------------------------------------------------------------------- 1 | .export __notl 2 | .code 3 | .setcpu 6803 4 | __notl: 5 | orab @hireg 6 | orab @hireg+1 7 | subd #0 8 | beq true 9 | clra 10 | clrb 11 | rts 12 | true: 13 | incb ; was already 0 14 | rts 15 | -------------------------------------------------------------------------------- /support6803/__xminuseq.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X -= D 3 | ; 4 | .export __xminuseq 5 | .export __xminusequ 6 | 7 | .setcpu 6803 8 | 9 | __xminuseq: 10 | __xminusequ: 11 | std @tmp 12 | ldd ,x 13 | subd @tmp 14 | std ,x 15 | rts 16 | -------------------------------------------------------------------------------- /support68hc11/__notl.s: -------------------------------------------------------------------------------- 1 | .export __notl 2 | .code 3 | __notl: 4 | cpy #0 5 | bne false 6 | subd #0 7 | beq true 8 | false: 9 | clra 10 | clrb 11 | rts 12 | true: incb ; D is 0 at this point so make it true 13 | rts 14 | -------------------------------------------------------------------------------- /support8080/__ccgtul.s: -------------------------------------------------------------------------------- 1 | .export __ccgtul 2 | .setcpu 8080 3 | .code 4 | 5 | __ccgtul: 6 | call __cmpulws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jnc __false 12 | jmp __true 13 | -------------------------------------------------------------------------------- /support8080/__cmpeqb.s: -------------------------------------------------------------------------------- 1 | .export __cmpeqb 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | ; 7 | ; Tighter version with the other value in DE 8 | ; 9 | __cmpeqb: 10 | mov a,l 11 | cmp e 12 | jnz __false 13 | jmp __true 14 | -------------------------------------------------------------------------------- /support8080/__cmpneb.s: -------------------------------------------------------------------------------- 1 | .export __cmpneb 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | ; 7 | ; Tighter version with the other value in DE 8 | ; 9 | __cmpneb: 10 | mov a,l 11 | cmp e 12 | jnz __true 13 | jmp __false 14 | -------------------------------------------------------------------------------- /support8085/__ccgtul.s: -------------------------------------------------------------------------------- 1 | .export __ccgtul 2 | .setcpu 8080 3 | .code 4 | 5 | __ccgtul: 6 | call __cmpulws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jnc __false 12 | jmp __true 13 | -------------------------------------------------------------------------------- /support8085/__cmpeqb.s: -------------------------------------------------------------------------------- 1 | .export __cmpeqb 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | ; 7 | ; Tighter version with the other value in DE 8 | ; 9 | __cmpeqb: 10 | mov a,l 11 | cmp e 12 | jnz __false 13 | jmp __true 14 | -------------------------------------------------------------------------------- /support8085/__cmpneb.s: -------------------------------------------------------------------------------- 1 | .export __cmpneb 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | ; 7 | ; Tighter version with the other value in DE 8 | ; 9 | __cmpneb: 10 | mov a,l 11 | cmp e 12 | jnz __true 13 | jmp __false 14 | -------------------------------------------------------------------------------- /supportsuper8/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | #include 5 | 6 | #define NULL ((void *)0) 7 | 8 | #define offsetof(type, ident) ((size_t) &((type *)0)->ident) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /supporttms7000/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | #include 5 | 6 | #define NULL ((void *)0) 7 | 8 | #define offsetof(type, ident) ((size_t) &((type *)0)->ident) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /supportz80/__ccltequl.s: -------------------------------------------------------------------------------- 1 | .export __ccltequl 2 | .code 3 | 4 | __ccltequl: 5 | call __cmpulws 6 | pop hl ; return address 7 | pop de ; value 8 | pop de 9 | push hl 10 | jp nc,__true 11 | jp __false 12 | 13 | -------------------------------------------------------------------------------- /supportz80/__cmpgt0.s: -------------------------------------------------------------------------------- 1 | .export __cmpgt0 2 | .code 3 | 4 | __cmpgt0: 5 | ld a,h 6 | or a 7 | jp m,__false 8 | jp nz,__true 9 | ; H was 0 so compare it with L 10 | cp l 11 | jp nz,__true 12 | jp __false 13 | -------------------------------------------------------------------------------- /test/debug-one-z8: -------------------------------------------------------------------------------- 1 | 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -mz8 -X -c tests/$b.c 5 | ldz8 -b -C0 -Z 48 testcrt0_z8.o tests/$b.o -o tests/$b /opt/fcc/lib/z8/libz8.a -m tests/$b.map 6 | ./emuz8 -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/testcrt0_6303.s: -------------------------------------------------------------------------------- 1 | .code ; (at 0x0100) 2 | 3 | .setcpu 6803 4 | start: 5 | clr @zero 6 | ldd #1 7 | std @one 8 | jsr _main 9 | ; return and exit (value is in XA) 10 | stab $FEFF 11 | ; Write to FEFF terminates 12 | -------------------------------------------------------------------------------- /test/testcrt0_6803.s: -------------------------------------------------------------------------------- 1 | .code ; (at 0x0100) 2 | 3 | .setcpu 6803 4 | start: 5 | clr @zero 6 | ldd #1 7 | std @one 8 | jsr _main 9 | ; return and exit (value is in XA) 10 | stab $FEFF 11 | ; Write to FEFF terminates 12 | -------------------------------------------------------------------------------- /test/testcrt0_nova.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Nova test 3 | ; 4 | .code 5 | start: 6 | lda 0,spinit,1 7 | sta 0,__sp,0 8 | jsr @1,1 9 | .word _main 10 | nio 0 ; our exit trap device 11 | spinit: 12 | .word 0x7000 ; grows upwards 13 | -------------------------------------------------------------------------------- /test/wtests/input080.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | int x; 4 | int y; 5 | 6 | int main() { 7 | 8 | for (x=0, y=1; x < 6; x++, y=y+2) { 9 | cprintf("%d %d\n", x, y); 10 | } 11 | 12 | return(0); 13 | } 14 | -------------------------------------------------------------------------------- /test/wtests/input119.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | int x; 4 | int y= 3; 5 | 6 | int main() { 7 | x= y != 3 ? 6 : 8; cprintf("%d\n", x); 8 | x= (y == 3) ? 6 : 8; cprintf("%d\n", x); 9 | return(0); 10 | } 11 | -------------------------------------------------------------------------------- /test/wtests/input152.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | void fred(int x) { 4 | int a = 2; 5 | int *b = &x; 6 | cprintf("%d %d %d\n", x, a, *b); 7 | } 8 | 9 | int main() { 10 | fred(4); 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /support6502/__cast_l.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Cast to long 3 | ; 4 | .export __cast_l 5 | 6 | __cast_l: 7 | ldy #0 8 | cpx #0 ; just force sign check 9 | bpl pve 10 | dey ; set Y to FF 11 | pve: sty @hireg 12 | sty @hireg+1 13 | rts 14 | -------------------------------------------------------------------------------- /support65c816/__notl.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __notl 6 | 7 | __notl: 8 | ora @hireg 9 | beq true 10 | stz @hireg 11 | lda #0 12 | rts 13 | true: 14 | stz @hireg 15 | inc a ; was 0 now 1 16 | rts 17 | -------------------------------------------------------------------------------- /support6800/__castl.s: -------------------------------------------------------------------------------- 1 | .export __cast_l 2 | .export __cast_ul 3 | .code 4 | 5 | __cast_ul: 6 | __cast_l: 7 | clr @hireg 8 | clr @hireg+1 9 | tsta 10 | bpl extpv 11 | dec @hireg 12 | dec @hireg+1 13 | extpv: 14 | rts 15 | -------------------------------------------------------------------------------- /support6809/__remul.s: -------------------------------------------------------------------------------- 1 | .export __remul 2 | .code 3 | __remul: 4 | std ,--s 5 | sty ,--s 6 | tfr s,x 7 | lbsr div32x32 8 | ; Result is in tmp2/tmp3 9 | ldy @tmp2 10 | ldd @tmp3 11 | ldx 4,x 12 | leas 10,s 13 | jmp ,x 14 | -------------------------------------------------------------------------------- /support6809/__xminusminusc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X - D 3 | ; 4 | .export __xmminusc 5 | .export __xmminusuc 6 | .code 7 | 8 | __xmminusc: 9 | __xmminusuc: 10 | stb ,-s 11 | ldb ,x 12 | tfr b,a 13 | suba ,s+ 14 | sta ,x 15 | rts 16 | -------------------------------------------------------------------------------- /support68hc11/__xminuseq.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X -= D 3 | ; 4 | .export __xminuseq 5 | .export __xminusequ 6 | 7 | __xminuseq: 8 | __xminusequ: 9 | pshb 10 | psha 11 | tsy 12 | ldd ,x 13 | subd ,y 14 | std ,x 15 | pulx 16 | rts 17 | -------------------------------------------------------------------------------- /support8070/__castc_.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Cast A into EA signed 3 | ; 4 | .export __castc_ 5 | 6 | __castc_: 7 | bp clre 8 | xch a,e 9 | ld a,=255 10 | xch a,e 11 | ret 12 | clre: 13 | xch a,e 14 | ld a,=0 15 | xch a,e 16 | ret 17 | -------------------------------------------------------------------------------- /support8080/__ccne.s: -------------------------------------------------------------------------------- 1 | .export __ccne 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __ccne: xchg 7 | pop h 8 | xthl 9 | mov a,l 10 | cmp e 11 | jnz __true 12 | mov a,h 13 | cmp d 14 | jnz __true 15 | jmp __false 16 | -------------------------------------------------------------------------------- /support8080/__cmpgt0.s: -------------------------------------------------------------------------------- 1 | .export __cmpgt0 2 | .setcpu 8080 3 | 4 | .code 5 | 6 | __cmpgt0: 7 | mov a,h 8 | ora a 9 | jm __false 10 | jnz __true 11 | mov a,l 12 | ora a 13 | jnz __true 14 | jmp __false 15 | -------------------------------------------------------------------------------- /support8080/__cpl.s: -------------------------------------------------------------------------------- 1 | .export __negate 2 | .export __cpl 3 | 4 | .setcpu 8080 5 | .code 6 | 7 | __negate: 8 | dcx h 9 | __cpl: 10 | mov a,h 11 | cma 12 | mov h,a 13 | mov a,l 14 | cma 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8085/__ccne.s: -------------------------------------------------------------------------------- 1 | .export __ccne 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __ccne: xchg 7 | pop h 8 | xthl 9 | mov a,l 10 | cmp e 11 | jnz __true 12 | mov a,h 13 | cmp d 14 | jnz __true 15 | jmp __false 16 | -------------------------------------------------------------------------------- /support8085/__cmpgt0.s: -------------------------------------------------------------------------------- 1 | .export __cmpgt0 2 | .setcpu 8080 3 | 4 | .code 5 | 6 | __cmpgt0: 7 | mov a,h 8 | ora a 9 | jm __false 10 | jnz __true 11 | mov a,l 12 | ora a 13 | jnz __true 14 | jmp __false 15 | -------------------------------------------------------------------------------- /support8085/__cpl.s: -------------------------------------------------------------------------------- 1 | .export __negate 2 | .export __cpl 3 | 4 | .setcpu 8080 5 | .code 6 | 7 | __negate: 8 | dcx h 9 | __cpl: 10 | mov a,h 11 | cma 12 | mov h,a 13 | mov a,l 14 | cma 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /test/debug-one-6809: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -m6809 -X -c tests/$b.c 5 | ld6809 -b -C256 testcrt0_6809.o tests/$b.o -o tests/$b /opt/fcc/lib/6809/lib6809.a 6 | ./emu6809 -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /support6502/__addyasp.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Add YA to SP (used for add and subtracts) 3 | ; 4 | .export __addyasp 5 | 6 | .code 7 | 8 | __addyasp: 9 | clc 10 | adc @sp 11 | sta @sp 12 | tya 13 | adc @sp+1 14 | sta @sp+1 15 | rts 16 | 17 | -------------------------------------------------------------------------------- /support65c816/__bool.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __bool 6 | .export __boolc 7 | 8 | __boolc: 9 | and #0xFF 10 | __bool: 11 | tax 12 | lda #1 13 | cpx #0 14 | bne done 15 | txa ; X is 0 16 | done: rts 17 | -------------------------------------------------------------------------------- /support65c816/__ltx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __ltx 6 | 7 | __ltx: 8 | stx @tmp 9 | sec 10 | sbc @tmp 11 | bvc t1 12 | eor #0x8000 13 | t1: bmi true 14 | lda #0 15 | rts 16 | true: lda #1 17 | rts 18 | 19 | -------------------------------------------------------------------------------- /support65c816/__orl.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __orl 6 | 7 | __orl: 8 | plx 9 | sta @tmp 10 | pla 11 | ora @tmp 12 | sta @tmp 13 | pla 14 | ora @hireg 15 | sta @hireg 16 | lda @tmp 17 | phx 18 | rts 19 | -------------------------------------------------------------------------------- /support68hc11/__xminusminus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X - D 3 | ; 4 | .export __xmminus 5 | .export __xmminusu 6 | .code 7 | 8 | __xmminus: 9 | __xmminusu: 10 | std @tmp 11 | ldd ,x 12 | subd @tmp 13 | std ,x 14 | addd @tmp 15 | rts 16 | 17 | -------------------------------------------------------------------------------- /support68hc11/__xplusplusu.s: -------------------------------------------------------------------------------- 1 | .export __xplusplusu 2 | .export __xplusplus 3 | .code 4 | 5 | __xplusplus: 6 | __xplusplusu: 7 | std @tmp 8 | ldd ,x 9 | pshb 10 | psha 11 | addd @tmp 12 | std ,x 13 | pula 14 | pulb 15 | rts 16 | -------------------------------------------------------------------------------- /support8080/__cceq.s: -------------------------------------------------------------------------------- 1 | .export __cceq 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __cceq: xchg 7 | pop h 8 | xthl 9 | mov a,l 10 | cmp e 11 | jnz __false 12 | mov a,h 13 | cmp d 14 | jnz __false 15 | jmp __true 16 | -------------------------------------------------------------------------------- /support8080/__cclteql.s: -------------------------------------------------------------------------------- 1 | .export __cclteql 2 | .setcpu 8080 3 | .code 4 | 5 | __cclteql: 6 | call __cmplws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jnc __true 12 | jmp __false 13 | 14 | -------------------------------------------------------------------------------- /support8080/__ccltequl.s: -------------------------------------------------------------------------------- 1 | .export __ccltequl 2 | .setcpu 8080 3 | .code 4 | 5 | __ccltequl: 6 | call __cmpulws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jnc __true 12 | jmp __false 13 | 14 | -------------------------------------------------------------------------------- /support8080/__pushl.s: -------------------------------------------------------------------------------- 1 | .export __pushl 2 | .setcpu 8080 3 | .code 4 | 5 | __pushl: 6 | xchg 7 | lhld __hireg 8 | xthl ; swap return address with high byte 9 | push d ; push low byte 10 | pchl ; and back 11 | 12 | 13 | -------------------------------------------------------------------------------- /support8085/__cceq.s: -------------------------------------------------------------------------------- 1 | .export __cceq 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | __cceq: xchg 7 | pop h 8 | xthl 9 | mov a,l 10 | cmp e 11 | jnz __false 12 | mov a,h 13 | cmp d 14 | jnz __false 15 | jmp __true 16 | -------------------------------------------------------------------------------- /support8085/__cclteql.s: -------------------------------------------------------------------------------- 1 | .export __cclteql 2 | .setcpu 8080 3 | .code 4 | 5 | __cclteql: 6 | call __cmplws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jnc __true 12 | jmp __false 13 | 14 | -------------------------------------------------------------------------------- /support8085/__ccltequl.s: -------------------------------------------------------------------------------- 1 | .export __ccltequl 2 | .setcpu 8080 3 | .code 4 | 5 | __ccltequl: 6 | call __cmpulws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jnc __true 12 | jmp __false 13 | 14 | -------------------------------------------------------------------------------- /support8085/__pushl.s: -------------------------------------------------------------------------------- 1 | .export __pushl 2 | .setcpu 8080 3 | .code 4 | 5 | __pushl: 6 | xchg 7 | lhld __hireg 8 | xthl ; swap return address with high byte 9 | push d ; push low byte 10 | pchl ; and back 11 | 12 | 13 | -------------------------------------------------------------------------------- /supportz80/__ccgteql.s: -------------------------------------------------------------------------------- 1 | .export __ccgteql 2 | .code 3 | 4 | __ccgteql: 5 | call __cmplws 6 | pop hl ; return address 7 | pop de ; value 8 | pop de 9 | push hl 10 | jp z,__true 11 | jp nc,__false 12 | jp __true 13 | -------------------------------------------------------------------------------- /supportz80/__ccltl.s: -------------------------------------------------------------------------------- 1 | .export __ccltl 2 | .code 3 | 4 | __ccltl: 5 | call __cmplws 6 | pop hl ; return address 7 | pop de ; value 8 | pop de 9 | push hl 10 | jp z,__false 11 | jp nc,__true 12 | jp __false 13 | 14 | -------------------------------------------------------------------------------- /test/debug-one-test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -X -m8085 -c tests/$b.c 5 | ld8080 -b -C0 testcrt0.o tests/$b.o -o tests/$b /opt/fcc/lib/8080/lib8085.a -m tests/$b.map 6 | ./emu85 -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/wtests/input120.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | int x; 4 | int y= 3; 5 | 6 | int main() { 7 | for (y= 0; y < 10; y++) { 8 | x= y > 4 ? y + 2 : y + 9; 9 | cprintf("%d\n", x); 10 | } 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /support65c816/__bandl.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __bandl 6 | 7 | __bandl: 8 | plx 9 | sta @tmp 10 | pla 11 | and @tmp 12 | sta @tmp 13 | pla 14 | and @hireg 15 | sta @hireg 16 | lda @tmp 17 | phx 18 | rts 19 | -------------------------------------------------------------------------------- /support65c816/__xorl.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __xorl 6 | 7 | __xorl: 8 | plx 9 | sta @tmp 10 | pla 11 | eor @tmp 12 | sta @tmp 13 | pla 14 | eor @hireg 15 | sta @hireg 16 | lda @tmp 17 | phx 18 | rts 19 | -------------------------------------------------------------------------------- /support8080/__cmplteq0.s: -------------------------------------------------------------------------------- 1 | .export __cmplteq0 2 | .setcpu 8080 3 | 4 | .code 5 | 6 | __cmplteq0: 7 | mov a,h 8 | ora a 9 | jm __true 10 | jnz __false 11 | mov a,l 12 | ora a 13 | jnz __false 14 | jmp __true 15 | 16 | -------------------------------------------------------------------------------- /support8085/__cmplteq0.s: -------------------------------------------------------------------------------- 1 | .export __cmplteq0 2 | .setcpu 8080 3 | 4 | .code 5 | 6 | __cmplteq0: 7 | mov a,h 8 | ora a 9 | jm __true 10 | jnz __false 11 | mov a,l 12 | ora a 13 | jnz __false 14 | jmp __true 15 | 16 | -------------------------------------------------------------------------------- /supportnova3/__minuseq.s: -------------------------------------------------------------------------------- 1 | .export f__minuseq 2 | .code 3 | 4 | f__minuseq: 5 | ; TOS is addr, AC1 value ot subtract 6 | sta 3,__tmp,0 7 | popa 2 8 | lda 0,0,2 9 | sub 1,0 10 | sta 0,0,2 11 | mov 0,1 12 | mffp 3 13 | jmp @__tmp,0 14 | -------------------------------------------------------------------------------- /supportz80/__ccgtequl.s: -------------------------------------------------------------------------------- 1 | .export __ccgtequl 2 | .code 3 | 4 | __ccgtequl: 5 | call __cmpulws 6 | pop hl ; return address 7 | pop de ; value 8 | pop de 9 | push hl 10 | jp z,__true 11 | jp nc,__false 12 | jp __true 13 | -------------------------------------------------------------------------------- /supportz80/__ccgtu.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; True if TOS < HL 3 | ; 4 | .export __ccgtu 5 | .code 6 | 7 | __ccgtu: 8 | ex de,hl 9 | pop hl 10 | ex (sp),hl 11 | or a 12 | sbc hl,de 13 | jp c,__false 14 | jp z,__false 15 | jp __true 16 | -------------------------------------------------------------------------------- /supportz80/__ccltul.s: -------------------------------------------------------------------------------- 1 | .export __ccltul 2 | .code 3 | 4 | __ccltul: 5 | call __cmpulws 6 | pop hl ; return address 7 | pop de ; value 8 | pop de 9 | push hl 10 | jp z,__false 11 | jp nc,__true 12 | jp __false 13 | 14 | -------------------------------------------------------------------------------- /supportz80/__cmpgtu.s: -------------------------------------------------------------------------------- 1 | .export __cmpgtu 2 | .export __cmpgtu0d 3 | .code 4 | 5 | ; true if HL > DE 6 | __cmpgtu0d: 7 | ld d,0 8 | __cmpgtu: 9 | or a 10 | sbc hl,de 11 | jp c,__false 12 | jp nz,__true 13 | jp __false 14 | -------------------------------------------------------------------------------- /test/debug-one-8080: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -X -m8080 -c tests/$b.c 5 | ld8080 -b -C0 testcrt0_8080.o tests/$b.o -o tests/$b /opt/fcc/lib/8080/lib8080.a -m tests/$b.map 6 | ./emu85 -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/debug-one-z80: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -O -X -mz80 -c tests/$b.c 5 | ldz80 -b -C0 testcrt0_8080.o tests/$b.o -o tests/$b /opt/fcc/lib/z80/libz80.a -m tests/$b.map 6 | ./emuz80 -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/tests/0005-for.c: -------------------------------------------------------------------------------- 1 | int main(int argc, char *argv[]) 2 | { 3 | int i; 4 | for (i = 0; i < 100; i++) { 5 | if (i == 50) 6 | break; 7 | } 8 | if (i != 50) 9 | return 1; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /test/wtests/input139.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | int same(int x) { return(x); } 4 | 5 | int main() { 6 | int a= 3; 7 | 8 | if (same(a) && same(a) >= same(a)) 9 | cprintf("same apparently\n"); 10 | return(0); 11 | } 12 | -------------------------------------------------------------------------------- /support6303/__booll.s: -------------------------------------------------------------------------------- 1 | .export __booll 2 | .code 3 | 4 | .setcpu 6803 5 | 6 | __booll: 7 | orab @hireg 8 | orab @hireg+1 9 | subd #0 10 | beq false ; If this passes then D is already zero 11 | true: 12 | ldd @one 13 | false: 14 | rts 15 | -------------------------------------------------------------------------------- /support6502/__netmpc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare A with @tmp 3 | ; 4 | .export __netmpc 5 | .export __netmpuc 6 | 7 | __netmpc: 8 | __netmpuc: 9 | ldx #0 10 | cmp @tmp 11 | beq false ; already 0 12 | true: lda #1 13 | false: 14 | rts 15 | 16 | 17 | -------------------------------------------------------------------------------- /support6502/__ytmpc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; __ytmpc. Put the contents of (@sp),y into A and the old A into 3 | ; @tmp. Prob should just inline all cases of this TODO FIXME 4 | ; 5 | .export __ytmpc 6 | 7 | __ytmpc: 8 | sta @tmp 9 | lda (@sp),y 10 | rts 11 | -------------------------------------------------------------------------------- /support65c816/__gteqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __gteqx 6 | 7 | __gteqx: 8 | stx @tmp 9 | sec 10 | sbc @tmp 11 | bvc t1 12 | eor #0x8000 13 | t1: bpl true 14 | lda #0 15 | rts 16 | true: lda #1 17 | rts 18 | 19 | -------------------------------------------------------------------------------- /support65c816/__gtx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __gtx 6 | 7 | ; A v X 8 | __gtx: 9 | stx @tmp 10 | clc 11 | sbc @tmp 12 | bvc t1 13 | eor #0x8000 14 | t1: bpl true 15 | lda #0 16 | rts 17 | true: lda #1 18 | rts 19 | -------------------------------------------------------------------------------- /support6803/__booll.s: -------------------------------------------------------------------------------- 1 | .export __booll 2 | .code 3 | 4 | .setcpu 6803 5 | 6 | __booll: 7 | orab @hireg 8 | orab @hireg+1 9 | subd #0 10 | beq false ; If this passes then D is already zero 11 | true: 12 | ldd @one 13 | false: 14 | rts 15 | -------------------------------------------------------------------------------- /support6809/__xminusminus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X - D 3 | ; 4 | .export __xmminus 5 | .export __xmminusu 6 | .code 7 | 8 | __xmminus: 9 | __xmminusu: 10 | std ,--s 11 | ldd ,x 12 | tfr d,y 13 | subd ,s++ 14 | std ,x 15 | tfr y,d 16 | rts 17 | 18 | -------------------------------------------------------------------------------- /support8080/__ccltl.s: -------------------------------------------------------------------------------- 1 | .export __ccltl 2 | .setcpu 8080 3 | .code 4 | 5 | __ccltl: 6 | call __cmplws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jz __false 12 | jnc __true 13 | jmp __false 14 | 15 | -------------------------------------------------------------------------------- /support8085/__ccltl.s: -------------------------------------------------------------------------------- 1 | .export __ccltl 2 | .setcpu 8080 3 | .code 4 | 5 | __ccltl: 6 | call __cmplws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jz __false 12 | jnc __true 13 | jmp __false 14 | 15 | -------------------------------------------------------------------------------- /supportee200/__bandl.s: -------------------------------------------------------------------------------- 1 | .setcpu 4 2 | .export __bandl 3 | 4 | .code 5 | 6 | __bandl: 7 | lda 4(s) 8 | nab 9 | stb 4(s) 10 | lda 2(s) 11 | ldb (__hireg) 12 | nab 13 | stb (__hireg) 14 | ldb 4(s) 15 | lda 4 16 | add a,s 17 | rsr 18 | -------------------------------------------------------------------------------- /supportee200/__orl.s: -------------------------------------------------------------------------------- 1 | .setcpu 4 2 | .export __orl 3 | 4 | .code 5 | 6 | __orl: 7 | lda 4(s) 8 | ori a,b 9 | stb 4(s) 10 | lda 2(s) 11 | ldb (__hireg) 12 | ori a,b 13 | stb (__hireg) 14 | ldb 4(s) 15 | lda 4 16 | add a,s 17 | rsr 18 | -------------------------------------------------------------------------------- /supportz80/__ccltequ.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; True if TOS < HL 3 | ; 4 | .export __ccltequ 5 | .code 6 | 7 | __ccltequ: 8 | ex de,hl 9 | pop hl 10 | ex (sp),hl 11 | or a 12 | sbc hl,de 13 | jp c,__true 14 | jp z,__true 15 | jp __false 16 | -------------------------------------------------------------------------------- /supportz80/__shl.s: -------------------------------------------------------------------------------- 1 | .export __shl 2 | .export __shlde 3 | .code 4 | 5 | __shl: 6 | ex de,hl 7 | pop hl 8 | ex (sp),hl 9 | __shlde: ld a,e 10 | and 15 11 | ret z 12 | shloop: add hl,hl 13 | dec a 14 | jr nz,shloop 15 | ret 16 | -------------------------------------------------------------------------------- /test/debug-one-6303: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -m6303 -O -X -c tests/$b.c 5 | ld6800 -b -Z64 -C256 testcrt0_6303.o tests/$b.o -o tests/$b /opt/fcc/lib/6303/lib6303.a 6 | ./emu6800 -d 6303 tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/debug-one-6803: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -m6803 -O -X -c tests/$b.c 5 | ld6800 -b -Z64 -C256 testcrt0_6803.o tests/$b.o -o tests/$b /opt/fcc/lib/6803/lib6803.a 6 | ./emu6800 -d 6803 tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/debug-one-8085: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -X -Os -m8085 -c tests/$b.c 5 | ld8080 -b -C0 testcrt0_8080.o tests/$b.o -o tests/$b /opt/fcc/lib/8085/lib8085.a -m tests/$b.map 6 | ./emu85 -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/debug-one-hc11: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -m68hc11 -O -X -c tests/$b.c 5 | ldhc11 -b -C32768 testcrt0_6803.o tests/$b.o -o tests/$b /opt/fcc/lib/hc11/libhc11.a 6 | ./emu6800 -d 6811 tests/$b tests/$b.map 2> $b.log 7 | 8 | -------------------------------------------------------------------------------- /support6502/__ytmp.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; __ytmp. Put the contents of (@sp),y/y-1 into XA and the old XA 3 | ; into @tmp 4 | 5 | .export __ytmp 6 | 7 | __ytmp: 8 | sta @tmp 9 | stx @tmp+1 10 | lda (@sp),y 11 | tax 12 | dey 13 | lda (@sp),y 14 | rts 15 | -------------------------------------------------------------------------------- /support6502/zeropage.s: -------------------------------------------------------------------------------- 1 | .export sp 2 | .export hireg 3 | .export tmp 4 | .export tmp1 5 | .export tmp2 6 | .export tmp3 7 | 8 | .zp 9 | sp: .word 0 10 | hireg: .word 0 11 | tmp: .word 0 12 | tmp1: .word 0 13 | tmp2: .word 0 14 | tmp3: .word 0 15 | -------------------------------------------------------------------------------- /support65c816/__negatel.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __negatel 6 | 7 | __negatel: 8 | eor #0xffff 9 | tax 10 | lda @hireg 11 | eor #0xffff 12 | sta @hireg 13 | txa 14 | inc a 15 | bne done 16 | inc @hireg 17 | done: rts 18 | -------------------------------------------------------------------------------- /support65c816/__plusl.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __plusl 6 | 7 | __plusl: 8 | plx 9 | sta @tmp 10 | clc 11 | pla 12 | adc @tmp 13 | sta @tmp 14 | pla 15 | adc @hireg 16 | sta @hireg 17 | lda @tmp 18 | phx 19 | rts 20 | -------------------------------------------------------------------------------- /support65c816/__shreqxu.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __shreqxu 6 | 7 | __shreqxu: 8 | ; Shift [A] X times 9 | stx @tmp 10 | tax 11 | lda 0,x 12 | phx 13 | ldx @tmp 14 | jsr __shrxu 15 | plx 16 | sta 0,x 17 | rts 18 | 19 | -------------------------------------------------------------------------------- /support6800/__notl.s: -------------------------------------------------------------------------------- 1 | .export __notl 2 | .code 3 | 4 | __notl: 5 | orab @hireg 6 | orab @hireg+1 7 | bne false 8 | tsta 9 | bne false1 10 | ; clra ; now AccA,B=0 11 | incb 12 | rts 13 | false: 14 | clrb 15 | false1: 16 | clra 17 | rts 18 | -------------------------------------------------------------------------------- /support8080/__ccltul.s: -------------------------------------------------------------------------------- 1 | .export __ccltul 2 | .setcpu 8080 3 | .code 4 | 5 | __ccltul: 6 | call __cmpulws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jz __false 12 | jnc __true 13 | jmp __false 14 | 15 | -------------------------------------------------------------------------------- /support8085/__ccltul.s: -------------------------------------------------------------------------------- 1 | .export __ccltul 2 | .setcpu 8080 3 | .code 4 | 5 | __ccltul: 6 | call __cmpulws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jz __false 12 | jnc __true 13 | jmp __false 14 | 15 | -------------------------------------------------------------------------------- /supportee200/__xorl.s: -------------------------------------------------------------------------------- 1 | .setcpu 4 2 | .export __xorl 3 | 4 | .code 5 | 6 | __xorl: 7 | lda 4(s) 8 | ore a,b 9 | stb 4(s) 10 | lda 2(s) 11 | ldb (__hireg) 12 | ore a,b 13 | stb (__hireg) 14 | ldb 4(s) 15 | lda 4 16 | add a,s 17 | rsr 18 | -------------------------------------------------------------------------------- /supportz80/__castc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Cast from char to int or uint 3 | ; 4 | .export __castc_ 5 | .export __castc_u 6 | 7 | .code 8 | 9 | __castc_: 10 | __castc_u: 11 | ld h,0 12 | ld a,l 13 | or a 14 | ret p 15 | dec h 16 | ret 17 | 18 | -------------------------------------------------------------------------------- /test/debug-one-6502: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -m6502 -O -X -c tests/$b.c 5 | ld6502 -b -C512 testcrt0_6502.o tests/$b.o -o tests/$b -m tests/$b.map /opt/fcc/lib/6502/lib6502.a 6 | ./emu6502 -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/debug-one-65c816: -------------------------------------------------------------------------------- 1 | 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -m65c816 -X -c tests/$b.c 5 | ld6502 -b -C512 testcrt0_65c816.o tests/$b.o -o tests/$b /opt/fcc/lib/65c816/lib65c816.a -m tests/$b.map 6 | ./emu65c816 -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/debug-one-nova: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -O2 -mnova -X -c tests/$b.c 5 | ldnova -b -C512 -Z80 testcrt0_nova.o tests/$b.o -o tests/$b /opt/fcc/lib/nova/libnova.a -m tests/$b.map 6 | ./nova -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/tests/0509-ptrarg.c: -------------------------------------------------------------------------------- 1 | 2 | void narg(char c, char *pb) 3 | { 4 | *pb |= c; 5 | } 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | char p = 0; 10 | narg(4, &p); 11 | if (p != 4) 12 | return 1; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /test/wtests/input005.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int main() 5 | { 6 | int i; int j; 7 | i=6; j=12; 8 | if (i < j) { 9 | printint(i); 10 | } else { 11 | printint(j); 12 | } 13 | return(0); 14 | } 15 | -------------------------------------------------------------------------------- /test/wtests/input016.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int c; 5 | int d; 6 | int *e; 7 | int f; 8 | 9 | int main() { 10 | c= 12; d=18; printint(c); 11 | e= &c + 1; f= *e; printint(f); 12 | return(0); 13 | } 14 | -------------------------------------------------------------------------------- /test/wtests/input112.c: -------------------------------------------------------------------------------- 1 | #define NULL ((void *)0) 2 | void cprintf(char *fmt, ...); 3 | 4 | char* y = NULL; 5 | int x= 10 + 6; 6 | int fred [ 2 + 3 ]; 7 | 8 | int main() { 9 | fred[2]= x; 10 | cprintf("%d\n", fred[2]); 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /test/wtests/input135.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | void fred() { 4 | int x= 5; 5 | cprintf("testing x\n"); 6 | if (x > 4) return; 7 | cprintf("x below 5\n"); 8 | } 9 | 10 | int main() { 11 | fred(); 12 | return(0); 13 | } 14 | -------------------------------------------------------------------------------- /test/wtests/input18a.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int a; 5 | int *b; 6 | char c; 7 | char *d; 8 | 9 | int main() 10 | { 11 | b= &a; *b= 15; printint(a); 12 | d= &c; *d= 16; printint(c); 13 | return(0); 14 | } 15 | -------------------------------------------------------------------------------- /support6303/__cpll.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Long complement. Possibly inlinable 3 | ; 4 | .export __cpll 5 | .setcpu 6803 6 | 7 | .code 8 | __cpll: 9 | coma 10 | comb 11 | std @tmp 12 | ldd @hireg 13 | coma 14 | comb 15 | std @hireg 16 | ldd @tmp 17 | rts 18 | -------------------------------------------------------------------------------- /support6303/__xminusminus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X - D 3 | ; 4 | .export __xmminus 5 | .export __xmminusu 6 | .code 7 | 8 | .setcpu 6803 9 | 10 | __xmminus: 11 | __xmminusu: 12 | std @tmp 13 | ldd ,x 14 | subd @tmp 15 | std ,x 16 | addd @tmp 17 | rts 18 | -------------------------------------------------------------------------------- /support6502/__lxaysptmp.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Very common pattern used as a straight 3 | ; peephole 4 | ; 5 | .export __lxaysptmp 6 | 7 | .code 8 | 9 | __lxaysptmp: 10 | lda (@sp),y 11 | tax 12 | dey 13 | lda (@sp),y 14 | sta @tmp 15 | stx @tmp+1 16 | rts 17 | -------------------------------------------------------------------------------- /support65c816/__lteqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __lteqx 6 | 7 | ; A v X 8 | __lteqx: 9 | stx @tmp 10 | clc 11 | sbc @tmp 12 | bvc t1 13 | eor #0x8000 14 | t1: bpl false 15 | lda #1 16 | rts 17 | false: lda #0 18 | rts 19 | -------------------------------------------------------------------------------- /support6803/__cpll.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Long complement. Possibly inlinable 3 | ; 4 | .export __cpll 5 | .setcpu 6803 6 | 7 | .code 8 | __cpll: 9 | coma 10 | comb 11 | std @tmp 12 | ldd @hireg 13 | coma 14 | comb 15 | std @hireg 16 | ldd @tmp 17 | rts 18 | -------------------------------------------------------------------------------- /support6803/__xminusminus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X - D 3 | ; 4 | .export __xmminus 5 | .export __xmminusu 6 | .code 7 | 8 | .setcpu 6803 9 | 10 | __xmminus: 11 | __xmminusu: 12 | std @tmp 13 | ldd ,x 14 | subd @tmp 15 | std ,x 16 | addd @tmp 17 | rts 18 | -------------------------------------------------------------------------------- /support8080/__ccgteql.s: -------------------------------------------------------------------------------- 1 | .export __ccgteql 2 | .setcpu 8080 3 | .code 4 | 5 | __ccgteql: 6 | call __cmplws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jz __true 12 | jnc __false 13 | jmp __true 14 | 15 | 16 | -------------------------------------------------------------------------------- /support8080/__pluseqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = amount 3 | ; 4 | .export __pluseqc 5 | 6 | .setcpu 8080 7 | .code 8 | __pluseqc: 9 | xchg 10 | pop h 11 | xthl 12 | mov a,m 13 | add e 14 | mov m,a 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8085/__ccgteql.s: -------------------------------------------------------------------------------- 1 | .export __ccgteql 2 | .setcpu 8080 3 | .code 4 | 5 | __ccgteql: 6 | call __cmplws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jz __true 12 | jnc __false 13 | jmp __true 14 | 15 | 16 | -------------------------------------------------------------------------------- /support8085/__pluseqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = amount 3 | ; 4 | .export __pluseqc 5 | 6 | .setcpu 8080 7 | .code 8 | __pluseqc: 9 | xchg 10 | pop h 11 | xthl 12 | mov a,m 13 | add e 14 | mov m,a 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /supportee200/__negatel.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Negate hireg:B 3 | ; 4 | .export __negatel 5 | 6 | .setcpu 4 7 | 8 | .code 9 | __negatel: 10 | lda (__hireg) 11 | ivr b 12 | iva 13 | inr b 14 | bnz nocarry 15 | ina 16 | nocarry: 17 | sta (__hireg) 18 | rsr 19 | -------------------------------------------------------------------------------- /supportz80/__ccequl.s: -------------------------------------------------------------------------------- 1 | .export __ccequl 2 | .export __cceql 3 | .code 4 | 5 | __cceql: 6 | __ccequl: 7 | call __cmpulws 8 | pop hl ; return address 9 | pop de ; value 10 | pop de 11 | push hl 12 | jp z,__true 13 | jp __false 14 | 15 | -------------------------------------------------------------------------------- /supportz80/__pluseqc.s: -------------------------------------------------------------------------------- 1 | 2 | ; 3 | ; TOS = lval of object L = amount 4 | ; 5 | .export __pluseqc 6 | .code 7 | 8 | __pluseqc: 9 | ex de,hl 10 | pop hl 11 | ex (sp),hl 12 | ld a,(hl) 13 | add a,e 14 | ld (hl),a 15 | ld l,a 16 | ret 17 | -------------------------------------------------------------------------------- /test/debug-one-8070: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -m8070 -O -X -c tests/$b.c 5 | ld8070 -b -Z0xFF00 -C1 -m tests/$b.map testcrt0_8070.o tests/$b.o -o tests/$b /opt/fcc/lib/8070/lib8070.a 6 | ./emu807x -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/debug-one-nova3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -O2 -mnova3 -X -c tests/$b.c 5 | ldnova -b -C512 -Z80 testcrt0_nova3.o tests/$b.o -o tests/$b /opt/fcc/lib/nova/libnova3.a -m tests/$b.map 6 | ./nova -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/tests/0105-forlong.c: -------------------------------------------------------------------------------- 1 | int main(int argc, char *argv[]) 2 | { 3 | long i; 4 | for (i = 0; i < 100000; i++) { 5 | if (i == 50000) 6 | break; 7 | } 8 | if (i != 50000) 9 | return 1; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /test/wtests/input019.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int a; 5 | int b; 6 | int c; 7 | int d; 8 | int e; 9 | int main() 10 | { 11 | a= 2; b= 4; c= 3; d= 2; 12 | e= (a+b) * (c+d); 13 | printint(e); 14 | return(0); 15 | } 16 | -------------------------------------------------------------------------------- /test/wtests/input136.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | int add(int x, int y) { 4 | return(x+y); 5 | } 6 | 7 | int main() { 8 | int result; 9 | result= 3 * add(2,3) - 5 * add(4,6); 10 | cprintf("%d\n", result); 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /support6303/__castl.s: -------------------------------------------------------------------------------- 1 | .export __cast_l 2 | .export __cast_ul 3 | .code 4 | 5 | .setcpu 6800 6 | 7 | __cast_ul: 8 | __cast_l: 9 | clr @hireg 10 | clr @hireg+1 11 | bita #0x80 12 | beq extpv 13 | dec @hireg 14 | dec @hireg+1 15 | extpv: 16 | rts 17 | -------------------------------------------------------------------------------- /support6303/__xplusplusu.s: -------------------------------------------------------------------------------- 1 | .export __xplusplusu 2 | .export __xplusplus 3 | .code 4 | 5 | .setcpu 6803 6 | 7 | __xplusplus: 8 | __xplusplusu: 9 | std @tmp 10 | ldd ,x 11 | pshb 12 | psha 13 | addd @tmp 14 | std ,x 15 | pula 16 | pulb 17 | rts 18 | -------------------------------------------------------------------------------- /support6502/__gteqtmpc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; a >= @tmp signed 3 | ; 4 | .export __gteqtmpc 5 | 6 | .code 7 | 8 | __gteqtmpc: 9 | ldx #0 10 | sec 11 | sbc @tmp 12 | bvc l1 13 | eor #$80 14 | l1: 15 | bpl true 16 | txa 17 | rts 18 | true: 19 | lda #1 20 | rts 21 | -------------------------------------------------------------------------------- /support65c816/__diveqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __diveqx 6 | 7 | ; A is ptr X is a value to divide by 8 | __diveqx: 9 | stx @tmp 10 | tax 11 | lda 0,x 12 | phx 13 | ldx @tmp 14 | jsr __divx 15 | plx 16 | sta 0,x 17 | rts 18 | -------------------------------------------------------------------------------- /support65c816/__diveqxu.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __diveqxu 6 | 7 | ; A is ptr X is a value to divide by 8 | __diveqxu: 9 | stx @tmp 10 | tax 11 | lda 0,x 12 | phx 13 | ldx @tmp 14 | jsr __divxu 15 | plx 16 | sta 0,x 17 | rts 18 | -------------------------------------------------------------------------------- /support65c816/__remeqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __remeqx 6 | 7 | ; A is ptr X is a value to divide by 8 | __remeqx: 9 | stx @tmp 10 | tax 11 | lda 0,x 12 | phx 13 | ldx @tmp 14 | jsr __remx 15 | plx 16 | sta 0,x 17 | rts 18 | -------------------------------------------------------------------------------- /support65c816/__remeqxu.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __remeqxu 6 | 7 | ; A is ptr X is a value to divide by 8 | __remeqxu: 9 | stx @tmp 10 | tax 11 | lda 0,x 12 | phx 13 | ldx @tmp 14 | jsr __remxu 15 | plx 16 | sta 0,x 17 | rts 18 | -------------------------------------------------------------------------------- /support6800/__plus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute TOS + D -> D 3 | ; 4 | .export __plus 5 | .export __plusu 6 | 7 | .code 8 | __plus: 9 | __plusu: 10 | tsx 11 | addb 3,x 12 | adca 2,x 13 | ldx 0,x 14 | ins 15 | ins 16 | ins 17 | ins 18 | jmp 0,x 19 | -------------------------------------------------------------------------------- /support6803/__castl.s: -------------------------------------------------------------------------------- 1 | .export __cast_l 2 | .export __cast_ul 3 | .code 4 | 5 | .setcpu 6800 6 | 7 | __cast_ul: 8 | __cast_l: 9 | clr @hireg 10 | clr @hireg+1 11 | bita #0x80 12 | beq extpv 13 | dec @hireg 14 | dec @hireg+1 15 | extpv: 16 | rts 17 | -------------------------------------------------------------------------------- /support6803/__xplusplusu.s: -------------------------------------------------------------------------------- 1 | .export __xplusplusu 2 | .export __xplusplus 3 | .code 4 | 5 | .setcpu 6803 6 | 7 | __xplusplus: 8 | __xplusplusu: 9 | std @tmp 10 | ldd ,x 11 | pshb 12 | psha 13 | addd @tmp 14 | std ,x 15 | pula 16 | pulb 17 | rts 18 | -------------------------------------------------------------------------------- /support8080/__castc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Cast from char to int or uint 3 | ; 4 | .export __castc_ 5 | .export __castc_u 6 | .setcpu 8080 7 | 8 | .code 9 | 10 | __castc_: 11 | __castc_u: 12 | mvi h,0 13 | mov a,l 14 | ora a 15 | rp 16 | dcr h 17 | ret 18 | -------------------------------------------------------------------------------- /support8080/__ccgtequl.s: -------------------------------------------------------------------------------- 1 | .export __ccgtequl 2 | .setcpu 8080 3 | .code 4 | 5 | __ccgtequl: 6 | call __cmpulws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jz __true 12 | jnc __false 13 | jmp __true 14 | 15 | 16 | -------------------------------------------------------------------------------- /support8085/__castc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Cast from char to int or uint 3 | ; 4 | .export __castc_ 5 | .export __castc_u 6 | .setcpu 8080 7 | 8 | .code 9 | 10 | __castc_: 11 | __castc_u: 12 | mvi h,0 13 | mov a,l 14 | ora a 15 | rp 16 | dcr h 17 | ret 18 | -------------------------------------------------------------------------------- /support8085/__ccgtequl.s: -------------------------------------------------------------------------------- 1 | .export __ccgtequl 2 | .setcpu 8080 3 | .code 4 | 5 | __ccgtequl: 6 | call __cmpulws 7 | pop h ; return address 8 | pop d ; value 9 | pop d 10 | push h 11 | jz __true 12 | jnc __false 13 | jmp __true 14 | 15 | 16 | -------------------------------------------------------------------------------- /supportz80/__ccneul.s: -------------------------------------------------------------------------------- 1 | .export __ccneul 2 | .export __ccnel 3 | .code 4 | 5 | __ccnel: 6 | __ccneul: 7 | call __cmpulws 8 | pop hl ; return address 9 | pop de ; value 10 | pop de 11 | push hl 12 | jp z,__false 13 | jp __true 14 | 15 | 16 | -------------------------------------------------------------------------------- /supportz80/__ldbyte.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Load byte from 8bit range of stack 3 | ; 4 | .export __ldbyte 5 | .code 6 | 7 | __ldbyte: 8 | pop hl 9 | ld a,(hl) 10 | inc hl 11 | push hl 12 | ld l,a 13 | ld h,0 14 | add hl,sp 15 | ld l,(hl) 16 | ret 17 | -------------------------------------------------------------------------------- /supportz80/__orc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute HL = TOS & HL 3 | ; 4 | .export __orc 5 | .export __oruc 6 | .code 7 | __orc: 8 | __oruc: 9 | ld a,l ; working register into A 10 | pop hl ; return address 11 | ex (sp),hl 12 | or e 13 | ld l,a 14 | ret 15 | -------------------------------------------------------------------------------- /test/debug-one-tms7000: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | b=$(basename $1 .c) 3 | echo $b":" 4 | fcc -mtms7000 -X -c tests/$b.c 5 | ld7000 -b -C0x200 -m tests/$b.map testcrt0_tms7000.o tests/$b.o -o tests/$b /opt/fcc/lib/tms7000/libtms7000.a 6 | ./emu7k -d tests/$b tests/$b.map 2> $b.log 7 | -------------------------------------------------------------------------------- /test/wtests/input147.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | int a; 4 | 5 | int main() { 6 | cprintf("%d\n", 24 % 9); 7 | cprintf("%d\n", 31 % 11); 8 | a= 24; a %= 9; cprintf("%d\n",a); 9 | a= 31; a %= 11; cprintf("%d\n",a); 10 | return(0); 11 | } 12 | -------------------------------------------------------------------------------- /test/wtests/out.input153.c: -------------------------------------------------------------------------------- 1 | class 1 prefix $ 2 | class 2 prefix % 3 | class 3 prefix % 4 | class 4 prefix $ 5 | class 5 prefix $ 6 | class 6 prefix % 7 | class 7 prefix % 8 | class 8 prefix % 9 | class 9 prefix % 10 | class 10 prefix % 11 | class 11 prefix % 12 | -------------------------------------------------------------------------------- /fp/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned __cceqf(uint32_t a1, uint32_t a2) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /fp/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned __ccnef(uint32_t a1, uint32_t a2) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support6502/__andeqtmp.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __andeqtmp 4 | .export __andeqtmpu 5 | __andeqtmp: 6 | __andeqtmpu: 7 | ldy #0 8 | and (@tmp),y 9 | sta (@tmp),y 10 | pha 11 | txa 12 | iny 13 | and (@tmp),y 14 | sta (@tmp),y 15 | tax 16 | pla 17 | rts 18 | -------------------------------------------------------------------------------- /support6502/__eoreqtmp.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __eoreqtmp 4 | .export __eoreqtmpu 5 | __eoreqtmp: 6 | __eoreqtmpu: 7 | ldy #0 8 | eor (@tmp),y 9 | sta (@tmp),y 10 | pha 11 | txa 12 | iny 13 | eor (@tmp),y 14 | sta (@tmp),y 15 | tax 16 | pla 17 | rts 18 | -------------------------------------------------------------------------------- /support6502/__eqeqtmpc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare A with @tmp 3 | ; 4 | .export __eqeqtmpc 5 | .export __eqeqtmpuc 6 | 7 | __eqeqtmpc: 8 | __eqeqtmpuc: 9 | ldx #0 10 | cmp @tmp 11 | bne false 12 | true: lda #1 13 | rts 14 | false: 15 | txa 16 | rts 17 | 18 | 19 | -------------------------------------------------------------------------------- /support6502/__notl.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; 32bit boolean not 3 | ; 4 | .export __notl 5 | 6 | __notl: 7 | stx @tmp 8 | ldx #0 9 | ora @tmp 10 | ora @hireg 11 | ora @hireg+1 12 | bne false 13 | ; Was zero so set to one 14 | lda #1 15 | rts 16 | false: txa 17 | rts 18 | -------------------------------------------------------------------------------- /support6502/__oraeqtmp.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __oraeqtmp 4 | .export __oraeqtmpu 5 | __oraeqtmp: 6 | __oraeqtmpu: 7 | ldy #0 8 | ora (@tmp),y 9 | sta (@tmp),y 10 | pha 11 | txa 12 | iny 13 | ora (@tmp),y 14 | sta (@tmp),y 15 | tax 16 | pla 17 | rts 18 | -------------------------------------------------------------------------------- /support65c816/__cast_l.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __cast_l 6 | 7 | ; TODO : inline ? 8 | 9 | __cast_l: 10 | ; cast A into hireg:A 11 | stz @hireg 12 | tax ; just to get the n flag set right 13 | beq done 14 | dec @hireg 15 | done: rts 16 | -------------------------------------------------------------------------------- /support65c816/__eqeqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __eqeqx 6 | .export __eqeqxu 7 | 8 | __eqeqx: 9 | __eqeqxu: 10 | stx @tmp 11 | sec 12 | sbc @tmp 13 | bne false 14 | inc a ; was 0 now 1 and ne 15 | rts 16 | false: lda #0 17 | rts 18 | -------------------------------------------------------------------------------- /support6800/__minus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Until we sort out optimizing this in the compiler proper 3 | ; 4 | .export __minus 5 | .code 6 | 7 | __minus: 8 | ; Subtract D from TOS 9 | tsx 10 | nega 11 | negb 12 | sbca #0 13 | addb 3,x 14 | adca 2,x 15 | jmp __pop2 16 | -------------------------------------------------------------------------------- /support6809/__minus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Until we sort out optimizing this in the compiler proper 3 | ; 4 | .export __minus 5 | .code 6 | 7 | __minus: 8 | ; Subtract D from TOS 9 | nega 10 | negb 11 | sbca #0 12 | addd 2,s 13 | ldx ,s 14 | leas 4,s 15 | jmp ,x 16 | -------------------------------------------------------------------------------- /support8070/__muleq.s: -------------------------------------------------------------------------------- 1 | .export __muleqtmp 2 | .export __muleqtmpu 3 | 4 | .code 5 | 6 | __muleqtmp: 7 | __muleqtmpu: 8 | ; tmp is the value, ea the pointer 9 | xch ea,p2 10 | ld ea,0,p2 11 | ld t,:__tmp 12 | jsr __mpyfix 13 | st ea,0,p2 14 | ret 15 | 16 | -------------------------------------------------------------------------------- /support8080/_strlen.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; strlen 3 | ; 4 | .export _strlen 5 | .setcpu 8080 6 | .code 7 | 8 | _strlen: 9 | pop h 10 | pop d 11 | push d 12 | push h 13 | lxi h,0 14 | loop: 15 | ldax d 16 | inx d 17 | ora a 18 | rz 19 | inx h 20 | jmp loop 21 | -------------------------------------------------------------------------------- /support8085/_strlen.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; strlen 3 | ; 4 | .export _strlen 5 | .setcpu 8080 6 | .code 7 | 8 | _strlen: 9 | pop h 10 | pop d 11 | push d 12 | push h 13 | lxi h,0 14 | loop: 15 | ldax d 16 | inx d 17 | ora a 18 | rz 19 | inx h 20 | jmp loop 21 | -------------------------------------------------------------------------------- /test/wtests/input116.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | 4 | static int counter=0; 5 | static int fred(void) { return(counter++); } 6 | 7 | int main(void) { 8 | int i; 9 | for (i=0; i < 5; i++) 10 | cprintf("%d\n", fred()); 11 | return(0); 12 | } 13 | -------------------------------------------------------------------------------- /test/wtests/input121.c: -------------------------------------------------------------------------------- 1 | void cprintf(char *fmt, ...); 2 | 3 | int x; 4 | int y= 3; 5 | 6 | int main() { 7 | for (y= 0; y < 10; y++) { 8 | x= (y < 4) ? y + 2 : 9 | (y > 7) ? 1000 : y + 9; 10 | cprintf("%d\n", x); 11 | } 12 | return(0); 13 | } 14 | -------------------------------------------------------------------------------- /Preprocessor/README: -------------------------------------------------------------------------------- 1 | This cpp is taken from dev86 and modified somewhat to swap out things to 2 | disk in order to allow it to run in a memory constrained system whilst 3 | still allowing for the fairly large number of macro definitions found in 4 | more modern C headers. 5 | 6 | -------------------------------------------------------------------------------- /support6502/__pluseq.s: -------------------------------------------------------------------------------- 1 | 2 | .export __pluseq 3 | 4 | ; (TOS) - EA 5 | __pluseq: 6 | jsr __poptmp 7 | ; poptmp set Y to 0 8 | clc 9 | adc (@tmp),y 10 | sta (@tmp),y 11 | pha 12 | iny 13 | txa 14 | adc (@tmp),y 15 | sta (@tmp),y 16 | tax 17 | pla 18 | rts 19 | -------------------------------------------------------------------------------- /support6502/__sbceqtmp.s: -------------------------------------------------------------------------------- 1 | .text 2 | 3 | .export __sbctmp 4 | .export __sbctmps 5 | __sbctmp: 6 | __sbctmps: 7 | ldy #0 8 | sec 9 | sbc (@tmp),y 10 | sta (@tmp),y 11 | pha 12 | txa 13 | iny 14 | sbc (@tmp),y 15 | sta (@tmp),y 16 | tax 17 | pla 18 | rts 19 | -------------------------------------------------------------------------------- /support6800/__xminuseq.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; ,X -= D 3 | ; 4 | .export __xminuseq 5 | .export __xminusequ 6 | 7 | __xminuseq: 8 | __xminusequ: 9 | staa @tmp 10 | stab @tmp+1 11 | ldaa ,x 12 | ldab 1,x 13 | subb @tmp+1 14 | sbca @tmp 15 | staa ,x 16 | stab 1,x 17 | rts 18 | -------------------------------------------------------------------------------- /support68hc11/__minus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Until we sort out optimizing this in the compiler proper 3 | ; 4 | .export __minus 5 | .code 6 | 7 | __minus: 8 | ; Subtract D from TOS 9 | tsx 10 | nega 11 | negb 12 | sbca #0 13 | addd 2,x 14 | pulx 15 | puly 16 | jmp ,x 17 | -------------------------------------------------------------------------------- /support68hc11/__remul.s: -------------------------------------------------------------------------------- 1 | .export __remul 2 | .code 3 | __remul: 4 | pshb 5 | psha 6 | pshy 7 | tsx 8 | jsr div32x32 9 | ; Result is in tmp2/tmp3 10 | ldy @tmp2 11 | ldd @tmp3 12 | pulx 13 | pulx 14 | pulx 15 | ins 16 | ins 17 | ins 18 | ins 19 | jmp ,x 20 | -------------------------------------------------------------------------------- /support8080/__ccequl.s: -------------------------------------------------------------------------------- 1 | .export __ccequl 2 | .export __cceql 3 | .setcpu 8080 4 | .code 5 | 6 | __cceql: 7 | __ccequl: 8 | call __cmpulws 9 | pop h ; return address 10 | pop d ; value 11 | pop d 12 | push h 13 | jz __true 14 | jmp __false 15 | 16 | -------------------------------------------------------------------------------- /support8080/__cmpeq.s: -------------------------------------------------------------------------------- 1 | .export __cmpeq 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | ; 7 | ; Tighter version with the other value in DE 8 | ; 9 | __cmpeq: 10 | mov a,l 11 | cmp e 12 | jnz __false 13 | mov a,h 14 | cmp d 15 | jnz __false 16 | jmp __true 17 | -------------------------------------------------------------------------------- /support8080/__cmpne.s: -------------------------------------------------------------------------------- 1 | .export __cmpne 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | ; 7 | ; Tighter version with the other value in DE 8 | ; 9 | __cmpne: 10 | mov a,l 11 | cmp e 12 | jnz __true 13 | mov a,h 14 | cmp d 15 | jnz __true 16 | jmp __false 17 | -------------------------------------------------------------------------------- /support8080/__ldbyte.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Load byte from 8bit range of stack 3 | ; 4 | .export __ldbyte 5 | 6 | .setcpu 8080 7 | .code 8 | 9 | __ldbyte: 10 | pop h 11 | mov a,m 12 | inx h 13 | push h 14 | mvi h,0 15 | mov l,a 16 | dad sp 17 | mov l,m 18 | ret 19 | -------------------------------------------------------------------------------- /support8080/__postdecc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object HL = amount 3 | ; 4 | .export __postdecc 5 | 6 | .setcpu 8080 7 | .code 8 | __postdecc: 9 | xchg 10 | pop h 11 | xthl 12 | mov a,m 13 | mov d,a 14 | sub e 15 | mov m,a 16 | mov l,d 17 | ret 18 | -------------------------------------------------------------------------------- /support8085/__ccequl.s: -------------------------------------------------------------------------------- 1 | .export __ccequl 2 | .export __cceql 3 | .setcpu 8080 4 | .code 5 | 6 | __cceql: 7 | __ccequl: 8 | call __cmpulws 9 | pop h ; return address 10 | pop d ; value 11 | pop d 12 | push h 13 | jz __true 14 | jmp __false 15 | 16 | -------------------------------------------------------------------------------- /support8085/__cmpeq.s: -------------------------------------------------------------------------------- 1 | .export __cmpeq 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | ; 7 | ; Tighter version with the other value in DE 8 | ; 9 | __cmpeq: 10 | mov a,l 11 | cmp e 12 | jnz __false 13 | mov a,h 14 | cmp d 15 | jnz __false 16 | jmp __true 17 | -------------------------------------------------------------------------------- /support8085/__cmpne.s: -------------------------------------------------------------------------------- 1 | .export __cmpne 2 | 3 | .setcpu 8080 4 | .code 5 | 6 | ; 7 | ; Tighter version with the other value in DE 8 | ; 9 | __cmpne: 10 | mov a,l 11 | cmp e 12 | jnz __true 13 | mov a,h 14 | cmp d 15 | jnz __true 16 | jmp __false 17 | -------------------------------------------------------------------------------- /support8085/__postdecc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object HL = amount 3 | ; 4 | .export __postdecc 5 | 6 | .setcpu 8080 7 | .code 8 | __postdecc: 9 | xchg 10 | pop h 11 | xthl 12 | mov a,m 13 | mov d,a 14 | sub e 15 | mov m,a 16 | mov l,d 17 | ret 18 | -------------------------------------------------------------------------------- /supportz80/__ldbytew.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Load byte from further off stack 3 | ; 4 | .export __ldbytew 5 | .code 6 | 7 | __ldbytew: 8 | pop hl 9 | ld e,(hl) 10 | inc hl 11 | ld d,(hl) 12 | inc hl 13 | push hl 14 | ex de,hl 15 | add hl,sp 16 | ld l,(hl) 17 | ret 18 | 19 | -------------------------------------------------------------------------------- /supportz80/__plus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute TOS + HL -> HL 3 | ; 4 | .export __plus 5 | .export __plusu 6 | 7 | .code 8 | __plus: 9 | __plusu: 10 | ex de,hl ; working register into DE 11 | pop hl ; return address 12 | ex (sp),hl 13 | add hl,de 14 | ret 15 | 16 | -------------------------------------------------------------------------------- /supportz80/__xorc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute HL = TOS & HL 3 | ; 4 | .export __xorc 5 | .export __xoruc 6 | 7 | .code 8 | __xorc: 9 | __xoruc: 10 | ld a,l ; working register into A 11 | pop hl ; return address 12 | ex (sp),hl 13 | xor l 14 | ld l,a 15 | ret 16 | -------------------------------------------------------------------------------- /Preprocessor/token1.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include "cc.h" 6 | 7 | #ifdef __GNUC__ 8 | __inline 9 | #endif 10 | static unsigned int hash1(register const char *, register unsigned int); 11 | 12 | #include "token1.h" 13 | -------------------------------------------------------------------------------- /Preprocessor/token2.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include "cc.h" 6 | 7 | #ifdef __GNUC__ 8 | __inline 9 | #endif 10 | static unsigned int hash2(register const char *, register unsigned int); 11 | 12 | #include "token2.h" 13 | -------------------------------------------------------------------------------- /support6303/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /support6303/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support6502/__adceqtmp.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __adceqtmp 4 | .export __adceqtmpu 5 | __adceqtmp: 6 | __adceqtmpu: 7 | ldy #0 8 | clc 9 | adc (@tmp),y 10 | sta (@tmp),y 11 | pha 12 | txa 13 | iny 14 | adc (@tmp),y 15 | sta (@tmp),y 16 | tax 17 | pla 18 | rts 19 | -------------------------------------------------------------------------------- /support6502/__andtmp.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __and 4 | .export __andu 5 | .export __andtmp 6 | .export __andtmpu 7 | __and: 8 | __andu: 9 | jsr __poptmp 10 | __andtmp: 11 | __andtmpu: 12 | and @tmp 13 | pha 14 | txa 15 | and @tmp+1 16 | tax 17 | pla 18 | rts 19 | -------------------------------------------------------------------------------- /support6502/__cpll.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Complement hireg:XA 3 | ; 4 | .export __cpll 5 | 6 | __cpll: 7 | pha 8 | txa 9 | eor #0xFF 10 | tax 11 | lda @hireg 12 | eor #0xFF 13 | sta @hireg 14 | lda @hireg+1 15 | eor #0xFF 16 | sta @hireg+1 17 | pla 18 | eor #0xFF 19 | rts 20 | -------------------------------------------------------------------------------- /support6502/__eortmp.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __eor 4 | .export __eoru 5 | .export __eortmp 6 | .export __eortmpu 7 | __eor: 8 | __eoru: 9 | jsr __poptmp 10 | __eortmp: 11 | __eortmpu: 12 | eor @tmp 13 | pha 14 | txa 15 | eor @tmp+1 16 | tax 17 | pla 18 | rts 19 | -------------------------------------------------------------------------------- /support6502/__lttmpuc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; a < @tmp unsigned 3 | ; 4 | .export __lttmpuc 5 | .export __l_lttmpuc 6 | 7 | .code 8 | 9 | __l_lttmpuc: 10 | jsr __ytmpc 11 | __lttmpuc: 12 | ldx #0 13 | cmp @tmp 14 | bcc true 15 | txa 16 | rts 17 | true: 18 | lda #1 19 | rts 20 | -------------------------------------------------------------------------------- /support6502/__oratmp.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __ora 4 | .export __orau 5 | .export __oratmp 6 | .export __oratmpu 7 | __ora: 8 | __orau: 9 | jsr __poptmp 10 | __oratmp: 11 | __oratmpu: 12 | ora @tmp 13 | pha 14 | txa 15 | ora @tmp+1 16 | tax 17 | pla 18 | rts 19 | -------------------------------------------------------------------------------- /support6502/__subysp.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Adjust stack frame by Y bytes the other direction 3 | ; 4 | .export __subysp 5 | 6 | .code 7 | 8 | __subysp: 9 | pha 10 | sty @tmp 11 | lda @sp 12 | sec 13 | sbc @tmp 14 | sta @sp 15 | bcs done 16 | dec @sp+1 17 | done: pla 18 | rts -------------------------------------------------------------------------------- /support65c816/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /support65c816/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support6800/__booll.s: -------------------------------------------------------------------------------- 1 | .export __booll 2 | .code 3 | 4 | __booll: 5 | orab @hireg 6 | orab @hireg+1 7 | bne true 8 | tsta 9 | beq false ; If this passes then D is already zero 10 | true: 11 | clra 12 | ldab #1 13 | rts 14 | false: 15 | clra 16 | clrb 17 | rts 18 | -------------------------------------------------------------------------------- /support6800/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /support6800/__cclt.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare D with TOS 3 | ; TOS < D 4 | ; 5 | .export __cclt 6 | 7 | __cclt: 8 | tsx 9 | suba 2,x 10 | bgt true 11 | bne false 12 | subb 3,x 13 | bhi true 14 | false: 15 | jmp __false2 16 | true: 17 | jmp __true2 18 | -------------------------------------------------------------------------------- /support6800/__ccltu.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare D with TOS 3 | ; TOS < D 4 | ; 5 | .export __ccltu 6 | 7 | __ccltu: 8 | tsx 9 | suba 2,x 10 | bhi true 11 | bne false 12 | subb 3,x 13 | bhi true 14 | false: 15 | jmp __false2 16 | true: 17 | jmp __true2 18 | -------------------------------------------------------------------------------- /support6800/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support6803/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /support6803/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support6809/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /support6809/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support68hc11/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /support68hc11/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support8070/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /support8070/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support8080/__andeqde.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; (HL) &= DE 3 | ; 4 | .export __andeqde 5 | .setcpu 8080 6 | .code 7 | 8 | __andeqde: 9 | mov a,m 10 | ana e 11 | mov m,a 12 | mov e,a 13 | inx h 14 | mov a,m 15 | ana d 16 | mov m,a 17 | mov d,a 18 | xchg 19 | ret 20 | 21 | -------------------------------------------------------------------------------- /support8080/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /support8080/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support8080/__ccneul.s: -------------------------------------------------------------------------------- 1 | .export __ccneul 2 | .export __ccnel 3 | .setcpu 8080 4 | .code 5 | 6 | __ccnel: 7 | __ccneul: 8 | call __cmpulws 9 | pop h ; return address 10 | pop d ; value 11 | pop d 12 | push h 13 | jz __false 14 | jmp __true 15 | 16 | 17 | -------------------------------------------------------------------------------- /support8080/__oreqde.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; (HL) &= DE 3 | ; 4 | .export __oreqde 5 | .setcpu 8080 6 | .code 7 | 8 | __oreqde: 9 | mov a,m 10 | ora e 11 | mov m,a 12 | mov e,a 13 | inx h 14 | mov a,m 15 | ora d 16 | mov m,a 17 | mov d,a 18 | xchg 19 | ret 20 | 21 | -------------------------------------------------------------------------------- /support8080/__xoreqde.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; (HL) &= DE 3 | ; 4 | .export __xoreqde 5 | .setcpu 8080 6 | .code 7 | 8 | __xoreqde: 9 | mov a,m 10 | xra e 11 | mov m,a 12 | mov e,a 13 | inx h 14 | mov a,m 15 | xra d 16 | mov m,a 17 | mov d,a 18 | xchg 19 | ret 20 | 21 | -------------------------------------------------------------------------------- /support8085/__andeqde.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; (HL) &= DE 3 | ; 4 | .export __andeqde 5 | .setcpu 8080 6 | .code 7 | 8 | __andeqde: 9 | mov a,m 10 | ana e 11 | mov m,a 12 | mov e,a 13 | inx h 14 | mov a,m 15 | ana d 16 | mov m,a 17 | mov d,a 18 | xchg 19 | ret 20 | 21 | -------------------------------------------------------------------------------- /support8085/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /support8085/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /support8085/__ccneul.s: -------------------------------------------------------------------------------- 1 | .export __ccneul 2 | .export __ccnel 3 | .setcpu 8080 4 | .code 5 | 6 | __ccnel: 7 | __ccneul: 8 | call __cmpulws 9 | pop h ; return address 10 | pop d ; value 11 | pop d 12 | push h 13 | jz __false 14 | jmp __true 15 | 16 | 17 | -------------------------------------------------------------------------------- /support8085/__oreqde.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; (HL) &= DE 3 | ; 4 | .export __oreqde 5 | .setcpu 8080 6 | .code 7 | 8 | __oreqde: 9 | mov a,m 10 | ora e 11 | mov m,a 12 | mov e,a 13 | inx h 14 | mov a,m 15 | ora d 16 | mov m,a 17 | mov d,a 18 | xchg 19 | ret 20 | 21 | -------------------------------------------------------------------------------- /support8085/__xoreqde.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; (HL) &= DE 3 | ; 4 | .export __xoreqde 5 | .setcpu 8080 6 | .code 7 | 8 | __xoreqde: 9 | mov a,m 10 | xra e 11 | mov m,a 12 | mov e,a 13 | inx h 14 | mov a,m 15 | xra d 16 | mov m,a 17 | mov d,a 18 | xchg 19 | ret 20 | 21 | -------------------------------------------------------------------------------- /supportnova/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /supportnova/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /supportnova3/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /supportnova3/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /supportnova3/__plusl.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; 32bit add of TOS and hireg:1 3 | ; 4 | .export __plusl 5 | .code 6 | __plusl: 7 | sta 3,__tmp,0 8 | popa 3 9 | popa 2 10 | lda 0,__hireg,0 11 | addz 3,1,szc 12 | inc 0,0 13 | add 2,0 14 | sta 0,__hireg,0 15 | mffp 3 16 | jmp @__tmp 17 | -------------------------------------------------------------------------------- /supportnova3/__postdec.s: -------------------------------------------------------------------------------- 1 | .export f__postdec 2 | .code 3 | ; TODO Should now be obsolete 4 | f__postdec: 5 | ; TOS is addr, AC1 value ot subtract 6 | sta 3,__tmp,0 7 | popa 2 8 | lda 0,0,2 9 | sub 1,0 10 | lda 1,0,2 11 | sta 0,0,2 12 | mffp 3 13 | jmp @__tmp,0 14 | -------------------------------------------------------------------------------- /supportsuper8/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /supportsuper8/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /supporttms7000/__pnref.s: -------------------------------------------------------------------------------- 1 | 2 | .export __pnref_2 3 | .code 4 | 5 | __pnref_2: 6 | ; Pointer is in r12/r13 7 | lda *r13 8 | mov a,b 9 | add %1,r13 10 | adc %0,r12 11 | lda *r13 12 | decd r15 13 | sta *r15 14 | mov a,b 15 | decd r15 16 | sta *r15 17 | rets 18 | 19 | -------------------------------------------------------------------------------- /supportz8/__bool.s: -------------------------------------------------------------------------------- 1 | .export __boolc 2 | .export __bool 3 | .export __booll 4 | 5 | .code 6 | 7 | __booll: 8 | or r3,r0 9 | or r3,r1 10 | __bool: 11 | or r3,r2 12 | __boolc: 13 | clr r2 14 | or r3,r3 15 | jr nz, set1 16 | ret 17 | set1: 18 | ld r3,#1 19 | ret 20 | -------------------------------------------------------------------------------- /supportz8/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /supportz8/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /supportz80/__cast_l.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; int to long 3 | ; 4 | .export __cast_l 5 | .code 6 | 7 | __cast_l: 8 | ld a,h 9 | ld de,0 ; upper word guess 0 10 | or a 11 | jp p, is_p ; positive 12 | dec de ; extend with FFFF 13 | is_p: 14 | ld (__hireg),de 15 | ret 16 | -------------------------------------------------------------------------------- /supportz80/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /supportz80/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /supportz80/__minus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute TOS - HL -> HL 3 | ; 4 | .export __minus 5 | .export __minusu 6 | .code 7 | __minus: 8 | __minusu: 9 | ex de,hl ; working register into DE 10 | pop hl ; return address 11 | ex (sp),hl 12 | or a 13 | sbc hl,de 14 | ret 15 | -------------------------------------------------------------------------------- /supportz80/__xoreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = mask 3 | ; 4 | .export __xoreqc 5 | .code 6 | __xoreqc: 7 | ex de,hl 8 | pop hl ; return address 9 | ex (sp),hl ; swap it for the lval 10 | ld a,e 11 | xor (hl) 12 | ld (hl),a 13 | ld l,a 14 | ret 15 | -------------------------------------------------------------------------------- /test/lib65c816/config.mk: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | CCFLAGS := -c -O2 -fomit-frame-pointer $(CCOPTS) -DDEBUG -Werror 3 | LD := gcc 4 | LDFLAGS := 5 | 6 | PREFIX := /opt/v65c816/ 7 | LIBPATH := $(PREFIX)/lib 8 | INCPATH := $(PREFIX)/include 9 | 10 | DELETE := rm -rf 11 | 12 | -------------------------------------------------------------------------------- /test/run-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -Os -m8085 -c tests/$b.c 7 | ld8080 -b -C0 testcrt0.o tests/$b.o -o tests/$b /opt/fcc/lib/8085/lib8085.a -m tests/$b.map 8 | ./emu85 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/run-testz8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -mz8 -c tests/$b.c 7 | ldz8 -b -C0 -Z48 testcrt0_z8.o tests/$b.o -o tests/$b /opt/fcc/lib/z8/libz8.a -m tests/$b.map 8 | ./emuz8 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/tms7k.h: -------------------------------------------------------------------------------- 1 | extern uint8_t mem_read8(uint16_t addr); 2 | extern uint8_t mem_read8_debug(uint16_t addr); 3 | extern void mem_write8(uint16_t addr, uint8_t val); 4 | 5 | extern void tms7k_reset(void); 6 | extern int tms7k_execute(int clocks); 7 | extern void tms7k_trace(FILE *f); 8 | -------------------------------------------------------------------------------- /support6303/__divul.s: -------------------------------------------------------------------------------- 1 | .export __divul 2 | .code 3 | 4 | .setcpu 6803 5 | __divul: 6 | pshb 7 | psha 8 | ldd @hireg 9 | pshb 10 | psha 11 | tsx 12 | jsr div32x32 13 | pulx 14 | pulx 15 | pulx 16 | pula 17 | pulb 18 | std @hireg 19 | pula 20 | pulb 21 | jmp ,x 22 | -------------------------------------------------------------------------------- /support65c816/__oreqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __oreqx 6 | .export __oreqxu 7 | 8 | __oreqx: 9 | __oreqxu: 10 | ; A is the pointer X is the value - backwards to how we want! 11 | stx @tmp 12 | tax 13 | lda 0,x 14 | ora @tmp 15 | sta 0,x 16 | rts 17 | -------------------------------------------------------------------------------- /support6803/__divul.s: -------------------------------------------------------------------------------- 1 | .export __divul 2 | .code 3 | 4 | .setcpu 6803 5 | __divul: 6 | pshb 7 | psha 8 | ldd @hireg 9 | pshb 10 | psha 11 | tsx 12 | jsr div32x32 13 | pulx 14 | pulx 15 | pulx 16 | pula 17 | pulb 18 | std @hireg 19 | pula 20 | pulb 21 | jmp ,x 22 | -------------------------------------------------------------------------------- /support6809/__cceql.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare Y:D with TOS 3 | ; 4 | .export __cceql 5 | 6 | __cceql: 7 | cmpy 2,s 8 | bne false 9 | cmpd 4,s 10 | bne false 11 | ldd @one 12 | out: 13 | ldx ,s 14 | leas 6,s 15 | tstb 16 | jmp ,x 17 | false: 18 | clra 19 | clrb 20 | bra out 21 | -------------------------------------------------------------------------------- /support6809/__ccnel.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare Y:D with TOS 3 | ; 4 | .export __ccnel 5 | 6 | __ccnel: 7 | cmpy 2,s 8 | bne true 9 | cmpd 4,s 10 | bne true 11 | clra 12 | clrb 13 | out: 14 | ldx ,s 15 | leas 6,s 16 | tstb 17 | jmp ,x 18 | true: 19 | ldd @one 20 | bra out 21 | -------------------------------------------------------------------------------- /support8080/__plus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute TOS + HL -> HL 3 | ; 4 | .export __plus 5 | .export __plusu 6 | 7 | .setcpu 8080 8 | .code 9 | __plus: 10 | __plusu: 11 | xchg ; working register into DE 12 | pop h ; return address 13 | xthl 14 | dad d 15 | ret 16 | 17 | -------------------------------------------------------------------------------- /support8085/__plus.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute TOS + HL -> HL 3 | ; 4 | .export __plus 5 | .export __plusu 6 | 7 | .setcpu 8080 8 | .code 9 | __plus: 10 | __plusu: 11 | xchg ; working register into DE 12 | pop h ; return address 13 | xthl 14 | dad d 15 | ret 16 | 17 | -------------------------------------------------------------------------------- /supportnova3/__minusl.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; 32bit TOS minus hireg:1 3 | ; 4 | .export f__minusl 5 | .code 6 | f__minusl: 7 | sta 3,__tmp,0 8 | popa 3 9 | popa 2 10 | lda 0,__hireg,0 11 | subz 3,1,szc 12 | sub 2,0,skp 13 | adc 2,0 14 | sta 0,__hireg,0 15 | mffp 3 16 | jmp @__tmp 17 | -------------------------------------------------------------------------------- /supportsuper8/__bool.s: -------------------------------------------------------------------------------- 1 | .export __boolc 2 | .export __bool 3 | .export __booll 4 | 5 | .code 6 | 7 | __booll: 8 | or r3,r0 9 | or r3,r1 10 | __bool: 11 | or r3,r2 12 | __boolc: 13 | clr r2 14 | or r3,r3 15 | jr nz, set1 16 | ret 17 | set1: 18 | ld r3,#1 19 | ret 20 | -------------------------------------------------------------------------------- /supportsuper8/__jmpr2.s: -------------------------------------------------------------------------------- 1 | ; FIXME: we have call @irr so we should be ok 2 | 3 | .export __jmpr2 4 | .code 5 | 6 | ; This way avoids messing with register indirection and working 7 | ; our what our working register bank is 8 | __jmpr2: 9 | push r3 10 | push r2 11 | ret 12 | -------------------------------------------------------------------------------- /supporttms7000/__bool.s: -------------------------------------------------------------------------------- 1 | .export __boolc 2 | .export __bool 3 | .export __booll 4 | 5 | .code 6 | 7 | __booll: 8 | or r2,r4 9 | or r3,r4 10 | __bool: 11 | or r4,r5 12 | __boolc: 13 | clr r4 14 | or r5,r5 15 | jnz set1 16 | rets 17 | set1: 18 | mov %1,r5 19 | rets 20 | -------------------------------------------------------------------------------- /supporttms7000/__cceqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _cceqf(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 1; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 0; 11 | return 1; 12 | } 13 | -------------------------------------------------------------------------------- /supporttms7000/__ccnef.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | /* TODO; check rules on NaN etc */ 4 | 5 | unsigned _ccnef(uint32_t a2, uint32_t a1) 6 | { 7 | if (a1 == a2) 8 | return 0; 9 | if ((a1 | a2) & 0x7FFFFFFFUL) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /supportz80/__castu_l.s: -------------------------------------------------------------------------------- 1 | 2 | .export __castuc_l 3 | .export __castuc_ul 4 | .export __castu_l 5 | .export __castu_ul 6 | 7 | .code 8 | __castuc_l: 9 | __castuc_ul: 10 | ld h,0 11 | __castu_l: 12 | __castu_ul: 13 | ld de,0 14 | ld (__hireg),de 15 | ret 16 | 17 | -------------------------------------------------------------------------------- /supportz80/__oreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = mask 3 | ; 4 | .export __oreqc 5 | .code 6 | 7 | __oreqc: 8 | ex de,hl 9 | pop hl ; return address 10 | ex (sp),hl ; swap it for the lval 11 | ld a,e 12 | or (hl) 13 | ld (hl),a 14 | ld l,a 15 | ret 16 | -------------------------------------------------------------------------------- /test/testcrt0_6502.s: -------------------------------------------------------------------------------- 1 | .code ; (at 0x0200) 2 | 3 | start: ldx #0xFF 4 | txs ; stack at 01FF 5 | lda #0 6 | sta sp 7 | lda #0xFD ; user stack at FD00 8 | sta sp+1 9 | jsr _main 10 | ; return and exit (value is in XA) 11 | sta $FEFF 12 | ; Write to FEFF terminates 13 | 14 | -------------------------------------------------------------------------------- /fp/__ccgtf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned __ccgtf(uint32_t a1, uint32_t a2) 4 | { 5 | if ((a1 & a2) & 0x80000000UL) { 6 | if (a2 > a1) 7 | return 1; 8 | return 0; 9 | } 10 | if (a1 > a2) 11 | return 1; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /fp/__cclteq.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned __cclteqf(uint32_t a1, uint32_t a2) 4 | { 5 | if (a1 & a2 & 0x80000000UL) { 6 | if (a2 > a1) 7 | return 1; 8 | return 0; 9 | } 10 | if (a1 > a2) 11 | return 1; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /fp/__ccltf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned __ccltf(uint32_t a1, uint32_t a2) 4 | { 5 | if (a1 & a2 & 0x80000000UL) { 6 | if (a2 < a1) 7 | return 1; 8 | return 0; 9 | } 10 | if (a1 < a2) 11 | return 1; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /support6502/__adctmp.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __adc 4 | .export __adcu 5 | .export __adctmp 6 | .export __adctmpu 7 | __adc: 8 | __adcu: 9 | jsr __poptmp 10 | __adctmp: 11 | __adctmpu: 12 | clc 13 | adc @tmp 14 | pha 15 | txa 16 | adc @tmp+1 17 | tax 18 | pla 19 | rts 20 | -------------------------------------------------------------------------------- /support6502/__gteqtmpuc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; a >= @tmp unsigned 3 | ; 4 | .export __gteqtmpuc 5 | .export __l_gteqtmpuc 6 | 7 | .code 8 | 9 | __l_gteqtmpuc: 10 | jsr __ytmpc 11 | __gteqtmpuc: 12 | ldx #0 13 | cmp @tmp 14 | bcs true 15 | txa 16 | rts 17 | true: 18 | lda #1 19 | rts 20 | -------------------------------------------------------------------------------- /support65c816/__andeqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __andeqx 6 | .export __andeqxu 7 | 8 | __andeqx: 9 | __andeqxu: 10 | ; A is the pointer X is the value - backwards to how we want! 11 | stx @tmp 12 | tax 13 | lda 0,x 14 | and @tmp 15 | sta 0,x 16 | rts 17 | -------------------------------------------------------------------------------- /support65c816/__muleqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __muleqx 6 | .export __muleqxu 7 | 8 | ; A is ptr X is a value 9 | __muleqxu: 10 | __muleqx: 11 | stx @tmp 12 | tax 13 | lda 0,x 14 | phx 15 | ldx @tmp 16 | jsr __mulx 17 | plx 18 | sta 0,x 19 | rts 20 | -------------------------------------------------------------------------------- /support65c816/__shleqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __shleqx 6 | .export __shleqxu 7 | 8 | __shleqx: 9 | __shleqxu: 10 | ; Shift [A] X times 11 | stx @tmp 12 | tax 13 | lda 0,x 14 | ldx @tmp 15 | phx 16 | jsr __lsx 17 | plx 18 | sta 0,x 19 | rts 20 | 21 | -------------------------------------------------------------------------------- /support6800/__pop2.s: -------------------------------------------------------------------------------- 1 | .export __pop2 2 | .export __true2 3 | .export __false2 4 | .code 5 | 6 | __false2: 7 | clra 8 | clrb 9 | bra __pop2 10 | __true2: 11 | clra 12 | ldab #1 13 | __pop2: 14 | tsx 15 | ldx ,x 16 | ins 17 | ins 18 | ins 19 | ins 20 | tstb 21 | jmp ,x 22 | -------------------------------------------------------------------------------- /support68hc11/__negatel.s: -------------------------------------------------------------------------------- 1 | .export __negatel 2 | .code 3 | 4 | ; The compiler has internal knowledge that this does not affect X 5 | __negatel: 6 | xgdy 7 | coma 8 | comb 9 | xgdy 10 | coma 11 | comb 12 | addd @one 13 | bcc nocarry 14 | iny 15 | nocarry: 16 | rts 17 | 18 | -------------------------------------------------------------------------------- /support8080/__cmpltu.s: -------------------------------------------------------------------------------- 1 | .export __cmpltu 2 | .export __cmpltub 3 | .setcpu 8080 4 | .code 5 | 6 | ; true if HL < DE 7 | __cmpltu: 8 | mov a,h 9 | cmp d 10 | jc __true 11 | jnz __false 12 | __cmpltub: 13 | mov a,l 14 | cmp e 15 | jc __true 16 | jmp __false 17 | -------------------------------------------------------------------------------- /support8080/__ldbytew.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Load byte from further off stack 3 | ; 4 | .export __ldbytew 5 | 6 | .setcpu 8080 7 | .code 8 | 9 | __ldbytew: 10 | pop h 11 | mov e,m 12 | inx h 13 | mov d,m 14 | inx h 15 | push h 16 | xchg 17 | dad sp 18 | mov l,m 19 | ret 20 | 21 | -------------------------------------------------------------------------------- /support8080/__orc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute HL = TOS & HL 3 | ; 4 | .export __orc 5 | .export __oruc 6 | 7 | .setcpu 8080 8 | .code 9 | __orc: 10 | __oruc: 11 | mov a,l ; working register into A 12 | pop h ; return address 13 | xthl 14 | ora e 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8085/__cmpltu.s: -------------------------------------------------------------------------------- 1 | .export __cmpltu 2 | .export __cmpltub 3 | .setcpu 8080 4 | .code 5 | 6 | ; true if HL < DE 7 | __cmpltu: 8 | mov a,h 9 | cmp d 10 | jc __true 11 | jnz __false 12 | __cmpltub: 13 | mov a,l 14 | cmp e 15 | jc __true 16 | jmp __false 17 | -------------------------------------------------------------------------------- /support8085/__orc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute HL = TOS & HL 3 | ; 4 | .export __orc 5 | .export __oruc 6 | 7 | .setcpu 8080 8 | .code 9 | __orc: 10 | __oruc: 11 | mov a,l ; working register into A 12 | pop h ; return address 13 | xthl 14 | ora e 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /supportnova/__minuseq.s: -------------------------------------------------------------------------------- 1 | .export f__minuseq 2 | .code 3 | 4 | f__minuseq: 5 | ; TOS is addr, AC1 value ot subtract 6 | sta 3,__tmp,0 7 | lda 2,__sp,0 8 | lda 2,0,2 9 | dsz __sp,0 10 | lda 0,0,2 11 | sub 1,0 12 | sta 0,0,2 13 | mov 0,1 14 | lda 3,__fp,0 15 | jmp @__tmp,0 16 | -------------------------------------------------------------------------------- /supportz80/__andeqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = mask 3 | ; 4 | .export __andeqc 5 | 6 | .code 7 | __andeqc: 8 | ex de,hl 9 | pop hl ; return address 10 | ex (sp),hl ; swap it for the lval 11 | ld a,e 12 | and (hl) 13 | ld (hl),a 14 | ld l,a 15 | ret 16 | -------------------------------------------------------------------------------- /supportz80/__cast_ul.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; int to unsigned long 3 | ; 4 | .export __cast_ul 5 | .code 6 | 7 | __cast_ul: 8 | ld a,h 9 | ld de,0 ; upper word guess 0 10 | or a 11 | jp is_p ; positive 12 | dec de ; extend with FFFF 13 | is_p: 14 | ld (__hireg),de 15 | ret 16 | -------------------------------------------------------------------------------- /supportz80/__ccltu.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; True if TOS < HL 3 | ; 4 | .export __ccltu 5 | .code 6 | 7 | __ccltu: 8 | ex de,hl 9 | pop hl 10 | ex (sp),hl 11 | or a 12 | sbc hl,de 13 | ld hl,0 14 | ld a,l 15 | adc a,a ; 1 if original carried, 0 if not 16 | ld l,a 17 | ret 18 | -------------------------------------------------------------------------------- /test/run-test6502.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -m6502 -c tests/$b.c 7 | ld6502 -b -C512 testcrt0_6502.o tests/$b.o -o tests/$b /opt/fcc/lib/6502/lib6502.a -m tests/$b.map 8 | ./emu6502 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/run-test6809.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -m6809 -c tests/$b.c 7 | ld6809 -b -C512 testcrt0_6809.o tests/$b.o -o tests/$b /opt/fcc/lib/6809/lib6809.a -m tests/$b.map 8 | ./emu6809 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/run-test8080.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -Os -m8080 -c tests/$b.c 7 | ld8080 -b -C0 testcrt0_8080.o tests/$b.o -o tests/$b /opt/fcc/lib/8080/lib8080.a -m tests/$b.map 8 | ./emu85 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/run-test8085.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -Os -m8085 -c tests/$b.c 7 | ld8080 -b -C0 testcrt0_8080.o tests/$b.o -o tests/$b /opt/fcc/lib/8085/lib8085.a -m tests/$b.map 8 | ./emu85 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/wtests/input003.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int main() 5 | { 6 | int x; 7 | x= 1; printint(x); 8 | x= x + 1; printint(x); 9 | x= x + 1; printint(x); 10 | x= x + 1; printint(x); 11 | x= x + 1; printint(x); 12 | return(0); 13 | } 14 | -------------------------------------------------------------------------------- /test/wtests/input013.c: -------------------------------------------------------------------------------- 1 | int printint(int x); 2 | void putchar(int ch); 3 | 4 | int fred() { 5 | return(56); 6 | } 7 | 8 | int main() { 9 | int dummy; 10 | int result; 11 | dummy= printint(23); 12 | result= fred(10); 13 | dummy= printint(result); 14 | return(0); 15 | } 16 | -------------------------------------------------------------------------------- /test/wtests/input014.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int fred() { 5 | return(20); 6 | } 7 | 8 | int main() { 9 | int result; 10 | printint(10); 11 | result= fred(15); 12 | printint(result); 13 | printint(fred(15)+10); 14 | return(0); 15 | } 16 | -------------------------------------------------------------------------------- /test/wtests/input021.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void printchar(int ch); 3 | 4 | char c; 5 | char *str; 6 | 7 | int main() { 8 | c= '\n'; printint(c); 9 | 10 | for (str= "Hello world\n"; *str != 0; str= str + 1) { 11 | printchar(*str); 12 | } 13 | return(0); 14 | } 15 | -------------------------------------------------------------------------------- /fp/__ccgteqf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned __ccgteqf(uint32_t a1, uint32_t a2) 4 | { 5 | if (a1 & a2 & 0x80000000UL) { 6 | if (a2 < a1) 7 | return 0; 8 | return 1; 9 | } 10 | if (a1 < a2) 11 | return 0; 12 | return 1; 13 | } 14 | -------------------------------------------------------------------------------- /support6303/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /support6303/__xshreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshreqc 5 | .code 6 | 7 | __xshreqc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tba 12 | ldab ,x 13 | right8: 14 | asrb 15 | deca 16 | bne right8 17 | stab ,x 18 | rts 19 | nowork: 20 | ldab ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support6502/__orl.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS | hireg:XA 3 | ; 4 | .export __orl 5 | 6 | __orl: 7 | jsr __pop32 8 | ora @tmp 9 | pha 10 | txa 11 | ora @tmp+1 12 | tax 13 | lda @tmp1 14 | ora @hireg 15 | sta @hireg 16 | lda @tmp1+1 17 | ora @hireg+1 18 | sta @hireg+1 19 | pla 20 | rts 21 | -------------------------------------------------------------------------------- /support6502/__xorl.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS ^ hireg:XA 3 | ; 4 | .export __xorl 5 | 6 | __xorl: 7 | jsr __pop32 8 | eor @tmp 9 | pha 10 | txa 11 | eor @tmp+1 12 | tax 13 | lda @tmp1 14 | eor @hireg 15 | sta @hireg 16 | lda @tmp1+1 17 | eor @hireg+1 18 | sta @hireg+1 19 | pla 20 | rts 21 | -------------------------------------------------------------------------------- /support65c816/__andeql.s: -------------------------------------------------------------------------------- 1 | .export __andeql 2 | 3 | .code 4 | 5 | __andeql: 6 | ; X is the pointer 7 | ; hireg:A is the value 8 | sta @tmp 9 | lda 0,x 10 | and @tmp 11 | sta 0,x 12 | pha 13 | lda @hireg 14 | and 2,x 15 | sta @hireg 16 | sta 2,x 17 | tax 18 | pla 19 | rts 20 | -------------------------------------------------------------------------------- /support65c816/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /support65c816/__eoreql.s: -------------------------------------------------------------------------------- 1 | .export __eoreql 2 | 3 | .code 4 | 5 | __eoreql: 6 | ; X is the pointer 7 | ; hireg:A is the value 8 | sta @tmp 9 | lda 0,x 10 | eor @tmp 11 | sta 0,x 12 | pha 13 | lda @hireg 14 | eor 2,x 15 | sta @hireg 16 | sta 2,x 17 | tax 18 | pla 19 | rts 20 | -------------------------------------------------------------------------------- /support65c816/__minusl.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __minusl 6 | 7 | __minusl: 8 | ; TOS - hireg:a 9 | plx 10 | sta @tmp 11 | sec 12 | pla ; low word 13 | sbc @tmp 14 | sta @tmp 15 | pla 16 | sbc @hireg 17 | sta @hireg 18 | lda @tmp 19 | phx 20 | rts 21 | -------------------------------------------------------------------------------- /support65c816/__oreql.s: -------------------------------------------------------------------------------- 1 | .export __oraeql 2 | 3 | .code 4 | 5 | __oraeql: 6 | ; X is the pointer 7 | ; hireg:A is the value 8 | sta @tmp 9 | lda 0,x 10 | ora @tmp 11 | sta 0,x 12 | pha 13 | lda @hireg 14 | ora 2,x 15 | sta @hireg 16 | sta 2,x 17 | tax 18 | pla 19 | rts 20 | -------------------------------------------------------------------------------- /support6800/__abx.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Adds the value of the accumulator to X. 3 | ; messing up D 4 | ; 5 | .export __abx 6 | .code 7 | 8 | __abx: 9 | clra 10 | stx @tmp ; X where we can manipulate it 11 | addb @tmp+1 12 | adca @tmp 13 | stab @tmp+1 14 | staa @tmp 15 | ldx @tmp 16 | rts 17 | -------------------------------------------------------------------------------- /support6800/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /support6800/__xshreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshreqc 5 | .code 6 | 7 | __xshreqc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tba 12 | ldab ,x 13 | right8: 14 | asrb 15 | deca 16 | bne right8 17 | stab ,x 18 | rts 19 | nowork: 20 | ldab ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support6803/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /support6803/__xshreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshreqc 5 | .code 6 | 7 | __xshreqc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tba 12 | ldab ,x 13 | right8: 14 | asrb 15 | deca 16 | bne right8 17 | stab ,x 18 | rts 19 | nowork: 20 | ldab ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support6809/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /support6809/__xshreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshreqc 5 | .code 6 | 7 | __xshreqc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tfr b,a 12 | ldb ,x 13 | right8: 14 | asrb 15 | deca 16 | bne right8 17 | stb ,x 18 | rts 19 | nowork: 20 | ldb ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support68hc11/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /support8070/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /support8080/__andeqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = mask 3 | ; 4 | .export __andeqc 5 | 6 | .setcpu 8080 7 | .code 8 | __andeqc: 9 | xchg 10 | pop h ; return address 11 | xthl ; swap it for the lval 12 | mov a,e 13 | ana m 14 | mov m,a 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8080/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /support8080/__oreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = mask 3 | ; 4 | .export __oreqc 5 | 6 | .setcpu 8080 7 | .code 8 | __oreqc: 9 | xchg 10 | pop h ; return address 11 | xthl ; swap it for the lval 12 | mov a,e 13 | ora m 14 | mov m,a 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8080/__xorc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute HL = TOS & HL 3 | ; 4 | .export __xorc 5 | .export __xoruc 6 | 7 | .setcpu 8080 8 | .code 9 | __xorc: 10 | __xoruc: 11 | mov a,l ; working register into A 12 | pop h ; return address 13 | xthl 14 | xra l 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8080/__xoreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = mask 3 | ; 4 | .export __xoreqc 5 | 6 | .setcpu 8080 7 | .code 8 | __xoreqc: 9 | xchg 10 | pop h ; return address 11 | xthl ; swap it for the lval 12 | mov a,e 13 | xra m 14 | mov m,a 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8085/__andeqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = mask 3 | ; 4 | .export __andeqc 5 | 6 | .setcpu 8080 7 | .code 8 | __andeqc: 9 | xchg 10 | pop h ; return address 11 | xthl ; swap it for the lval 12 | mov a,e 13 | ana m 14 | mov m,a 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8085/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /support8085/__oreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = mask 3 | ; 4 | .export __oreqc 5 | 6 | .setcpu 8080 7 | .code 8 | __oreqc: 9 | xchg 10 | pop h ; return address 11 | xthl ; swap it for the lval 12 | mov a,e 13 | ora m 14 | mov m,a 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8085/__xorc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute HL = TOS & HL 3 | ; 4 | .export __xorc 5 | .export __xoruc 6 | 7 | .setcpu 8080 8 | .code 9 | __xorc: 10 | __xoruc: 11 | mov a,l ; working register into A 12 | pop h ; return address 13 | xthl 14 | xra l 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /support8085/__xoreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = mask 3 | ; 4 | .export __xoreqc 5 | 6 | .setcpu 8080 7 | .code 8 | __xoreqc: 9 | xchg 10 | pop h ; return address 11 | xthl ; swap it for the lval 12 | mov a,e 13 | xra m 14 | mov m,a 15 | mov l,a 16 | ret 17 | -------------------------------------------------------------------------------- /supportnova/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /supportnova3/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /supportsuper8/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /supportz8/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /supportz80/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /test/run-testnova.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -O2 -mnova -c tests/$b.c 7 | ldnova -b -C512 -Z80 testcrt0_nova.o tests/$b.o -o tests/$b /opt/fcc/lib/nova/libnova.a -m tests/$b.map 8 | ./nova tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /support6303/__xshrequc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshrequc 5 | .code 6 | 7 | __xshrequc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tba 12 | ldab ,x 13 | right8: 14 | lsrb 15 | deca 16 | bne right8 17 | stab ,x 18 | rts 19 | nowork: 20 | ldab ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support6502/__bandl.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS & hireg:XA 3 | ; 4 | .export __bandl 5 | 6 | __bandl: 7 | jsr __pop32 8 | and @tmp 9 | pha 10 | txa 11 | and @tmp+1 12 | tax 13 | lda @tmp1 14 | and @hireg 15 | sta @hireg 16 | lda @tmp1+1 17 | and @hireg+1 18 | sta @hireg+1 19 | pla 20 | rts 21 | -------------------------------------------------------------------------------- /support6800/__xshrequc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshrequc 5 | .code 6 | 7 | __xshrequc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tba 12 | ldab ,x 13 | right8: 14 | lsrb 15 | deca 16 | bne right8 17 | stab ,x 18 | rts 19 | nowork: 20 | ldab ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support6803/__xshrequc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshrequc 5 | .code 6 | 7 | __xshrequc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tba 12 | ldab ,x 13 | right8: 14 | lsrb 15 | deca 16 | bne right8 17 | stab ,x 18 | rts 19 | nowork: 20 | ldab ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support6809/__negatel.s: -------------------------------------------------------------------------------- 1 | .export __negatel 2 | .code 3 | 4 | ; The compiler has internal knowledge that this does not affect X 5 | __negatel: 6 | exg d,y 7 | coma 8 | comb 9 | exg d,y 10 | coma 11 | comb 12 | addd @one 13 | bcc nocarry 14 | leay 1,y 15 | nocarry: 16 | rts 17 | 18 | -------------------------------------------------------------------------------- /support6809/__xshrequc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshrequc 5 | .code 6 | 7 | __xshrequc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tfr b,a 12 | ldb ,x 13 | right8: 14 | lsrb 15 | deca 16 | bne right8 17 | stb ,x 18 | rts 19 | nowork: 20 | ldb ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support68hc11/__ccnel.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare Y:D with TOS 3 | ; 4 | .export __ccnel 5 | 6 | __ccnel: 7 | tsx 8 | cpy 2,x 9 | bne true 10 | subd 4,x 11 | bne true 12 | clra 13 | clrb 14 | out: 15 | puly 16 | pulx 17 | pulx 18 | tstb 19 | jmp ,y 20 | true: 21 | ldd @one 22 | bra out 23 | -------------------------------------------------------------------------------- /support68hc11/__xshreqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshreqc 5 | .code 6 | 7 | __xshreqc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tba 12 | ldab ,x 13 | right8: 14 | asrb 15 | deca 16 | bne right8 17 | stab ,x 18 | rts 19 | nowork: 20 | ldab ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support68hc11/__xshrequc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X right by D 3 | ; 4 | .export __xshrequc 5 | .code 6 | 7 | __xshrequc: 8 | clra 9 | andb #7 10 | beq nowork 11 | tba 12 | ldab ,x 13 | right8: 14 | lsrb 15 | deca 16 | bne right8 17 | stab ,x 18 | rts 19 | nowork: 20 | ldab ,x 21 | rts 22 | -------------------------------------------------------------------------------- /support8085/__shr.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift the top of stack right by HL (arithemtic) 3 | ; 4 | .export __shr 5 | .setcpu 8085 6 | .code 7 | __shr: 8 | xchg 9 | pop h 10 | xthl 11 | mov a,e 12 | ani 15 13 | rz 14 | shift1: 15 | arhl 16 | dcr e 17 | jnz shift1 18 | ret 19 | 20 | -------------------------------------------------------------------------------- /supporttms7000/__boolf.c: -------------------------------------------------------------------------------- 1 | #include "libfp.h" 2 | 3 | unsigned _boolf(uint32_t a1) 4 | { 5 | if (a1 & 0x7FFFFFFFUL) 6 | return 1; 7 | return 0; 8 | } 9 | 10 | unsigned _notf(uint32_t a1) 11 | { 12 | if (a1 & 0x7FFFFFFFUL) 13 | return 0; 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /supportz8/__pnref.s: -------------------------------------------------------------------------------- 1 | 2 | .export __pnref_2 3 | .code 4 | 5 | __pnref_2: 6 | pop r12 7 | pop r13 8 | lde r14,@rr12 9 | incw rr12 10 | lde r15,@rr12 11 | incw rr12 12 | lde r2,@rr14 13 | incw rr14 14 | lde r3,@rr14 15 | push r3 16 | push r2 17 | push r13 18 | push r12 19 | ret 20 | -------------------------------------------------------------------------------- /supportz80/__andc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compute HL = TOS & HL 3 | ; 4 | .export __andc 5 | .export __anduc 6 | 7 | .code 8 | __andc: 9 | __anduc: 10 | ld a,l ; working register into A 11 | pop hl ; return address 12 | ex (sp),hl ; TOS value into HL 13 | and e 14 | ld l,a 15 | ret 16 | -------------------------------------------------------------------------------- /supportz80/__bcmul.s: -------------------------------------------------------------------------------- 1 | .export __bcmul 2 | .export __bcmulc 3 | 4 | .code 5 | 6 | ; HL has one value BNC the other.. so just use the helper 7 | __bcmulc: 8 | ld b,0 9 | __bcmul: 10 | ld e,c 11 | ld d,b 12 | call __mulde ; HL * DE into HL 13 | ld c,l 14 | ld b,h 15 | ret 16 | -------------------------------------------------------------------------------- /test/run-test6303.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -m6303 -c tests/$b.c 7 | ld6800 -b -C256 -Z64 testcrt0_6303.o tests/$b.o -o tests/$b /opt/fcc/lib/6303/lib6303.a -m tests/$b.map 8 | ./emu6800 6303 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/run-test65c816.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -m65c816 -c tests/$b.c 7 | ld6502 -b -C512 testcrt0_65c816.o tests/$b.o -o tests/$b /opt/fcc/lib/65c816/lib65c816.a -m tests/$b.map 8 | ./emu65c816 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/run-test6803.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -m6803 -c tests/$b.c 7 | ld6800 -b -C256 -Z64 testcrt0_6803.o tests/$b.o -o tests/$b /opt/fcc/lib/6803/lib6803.a -m tests/$b.map 8 | ./emu6800 6803 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/run-testhc11.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -m68hc11 -c tests/$b.c 7 | ld6800 -b -C32768 testcrt0_6803.o tests/$b.o -o tests/$b /opt/fcc/lib/hc11/libhc11.a -m tests/$b.map 8 | ./emu6800 6811 tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/run-testnova3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in tests/*.c 3 | do 4 | b=$(basename $i .c) 5 | echo $b":" 6 | fcc -O2 -mnova3 -c tests/$b.c 7 | ldnova -b -C512 -Z80 testcrt0_nova3.o tests/$b.o -o tests/$b /opt/fcc/lib/nova/libnova3.a -m tests/$b.map 8 | ./nova tests/$b tests/$b.map 9 | done 10 | -------------------------------------------------------------------------------- /test/wtests/input024.c: -------------------------------------------------------------------------------- 1 | void printint(int x); 2 | void putchar(int ch); 3 | 4 | int a; 5 | int b; 6 | int c; 7 | int main() { 8 | a= 42; b= 19; 9 | printint(a & b); 10 | printint(a | b); 11 | printint(a ^ b); 12 | printint(1 << 3); 13 | printint(63 >> 3); 14 | return(0); 15 | } 16 | -------------------------------------------------------------------------------- /support6502/__andspy.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __andspy0 4 | .export __andspy0s 5 | .export __andspy 6 | .export __andspys 7 | __andspy0: 8 | __andspy0s: 9 | ldy #0 10 | __andspy: 11 | __andspys: 12 | and (@sp),y 13 | pha 14 | txa 15 | iny 16 | and (@sp),y 17 | tax 18 | pla 19 | rts 20 | -------------------------------------------------------------------------------- /support6502/__eorspy.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __eorspy0 4 | .export __eorspy0s 5 | .export __eorspy 6 | .export __eorspys 7 | __eorspy0: 8 | __eorspy0s: 9 | ldy #0 10 | __eorspy: 11 | __eorspys: 12 | eor (@sp),y 13 | pha 14 | txa 15 | iny 16 | eor (@sp),y 17 | tax 18 | pla 19 | rts 20 | -------------------------------------------------------------------------------- /support6502/__ldaspy.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __ldaspy0 4 | .export __ldaspy0s 5 | .export __ldaspy 6 | .export __ldaspys 7 | __ldaspy0: 8 | __ldaspy0s: 9 | ldy #0 10 | __ldaspy: 11 | __ldaspys: 12 | lda (@sp),y 13 | pha 14 | txa 15 | iny 16 | lda (@sp),y 17 | tax 18 | pla 19 | rts 20 | -------------------------------------------------------------------------------- /support6502/__oraspy.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __oraspy0 4 | .export __oraspy0s 5 | .export __oraspy 6 | .export __oraspys 7 | __oraspy0: 8 | __oraspy0s: 9 | ldy #0 10 | __oraspy: 11 | __oraspys: 12 | ora (@sp),y 13 | pha 14 | txa 15 | iny 16 | ora (@sp),y 17 | tax 18 | pla 19 | rts 20 | -------------------------------------------------------------------------------- /support6502/__staspy.s: -------------------------------------------------------------------------------- 1 | .code 2 | 3 | .export __staspy0 4 | .export __staspy0s 5 | .export __staspy 6 | .export __staspys 7 | __staspy0: 8 | __staspy0s: 9 | ldy #0 10 | __staspy: 11 | __staspys: 12 | sta (@sp),y 13 | pha 14 | txa 15 | iny 16 | sta (@sp),y 17 | tax 18 | pla 19 | rts 20 | -------------------------------------------------------------------------------- /support65c816/__muln.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __mul16 6 | .export __mul32 7 | .export __mul64 8 | .export __mul128 9 | 10 | __mul128: 11 | asl a 12 | __mul64: 13 | asl a 14 | __mul32: 15 | asl a 16 | __mul16: 17 | asl a 18 | asl a 19 | asl a 20 | asl a 21 | rts 22 | -------------------------------------------------------------------------------- /support65c816/__pluseqx.s: -------------------------------------------------------------------------------- 1 | .65c816 2 | .a16 3 | .i16 4 | 5 | .export __pluseqx 6 | .export __pluseqxu 7 | 8 | __pluseqx: 9 | __pluseqxu: 10 | ; A is the pointer X is the value - backwards to how we want! 11 | stx @tmp 12 | tax 13 | lda 0,x 14 | clc 15 | adc @tmp 16 | sta 0,x 17 | rts 18 | -------------------------------------------------------------------------------- /support6809/__xshreql.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TODO optimize 3 | ; 4 | .export __xshreql 5 | .code 6 | 7 | __xshreql: 8 | clra 9 | andb #31 10 | beq load_only 11 | shlp: 12 | asr 0,x 13 | ror 1,x 14 | ror 2,x 15 | ror 3,x 16 | decb 17 | bne shlp 18 | load_only: 19 | ldd 2,x 20 | ldy 0,x 21 | rts 22 | -------------------------------------------------------------------------------- /support6809/__xshrequl.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TODO optimize 3 | ; 4 | .export __xshrequl 5 | .code 6 | 7 | __xshrequl: 8 | clra 9 | andb #31 10 | beq load_only 11 | shlp: 12 | lsr 0,x 13 | ror 1,x 14 | ror 2,x 15 | ror 3,x 16 | decb 17 | bne shlp 18 | load_only: 19 | ldd 2,x 20 | ldy 0,x 21 | rts 22 | -------------------------------------------------------------------------------- /support68hc11/__cceql.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Compare Y:D with TOS 3 | ; 4 | .export __cceql 5 | 6 | __cceql: 7 | tsx 8 | cpy 2,x 9 | bne false 10 | subd 4,x 11 | bne false 12 | ldd @one 13 | out: 14 | puly 15 | pulx 16 | pulx 17 | tstb 18 | jmp ,y 19 | false: 20 | clra 21 | clrb 22 | bra out 23 | -------------------------------------------------------------------------------- /support68hc11/__xshreq.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; Shift ,X left by D 3 | ; 4 | .export __xshreq 5 | .code 6 | 7 | __xshreq: 8 | clra 9 | andb #15 10 | beq nowork 11 | xgdy 12 | ldd ,x 13 | right16: 14 | asra 15 | rorb 16 | dey 17 | bne right16 18 | std ,x 19 | rts 20 | nowork: 21 | ldd ,x 22 | rts 23 | -------------------------------------------------------------------------------- /support68hc11/__xshreql.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TODO optimize 3 | ; 4 | .export __xshreql 5 | .code 6 | 7 | __xshreql: 8 | clra 9 | andb #31 10 | beq load_only 11 | shlp: 12 | asr 0,x 13 | ror 1,x 14 | ror 2,x 15 | ror 3,x 16 | decb 17 | bne shlp 18 | load_only: 19 | ldd 2,x 20 | ldy 0,x 21 | rts 22 | -------------------------------------------------------------------------------- /support8070/__orl.s: -------------------------------------------------------------------------------- 1 | .export __orl 2 | 3 | __orl: 4 | or a,2,p1 5 | xch a,e 6 | or a,3,p1 7 | xch a,e 8 | ld t,ea 9 | ld ea,:__hireg 10 | or a,4,p1 11 | xch a,e 12 | or a,5,p1 13 | xch a,e 14 | st ea,:__hireg 15 | ld ea,t 16 | pop p3 17 | pop p2 18 | pop p2 19 | push p3 20 | ret 21 | -------------------------------------------------------------------------------- /support8080/__cmpgtequ.s: -------------------------------------------------------------------------------- 1 | .export __cmpgtequ 2 | .export __cmpgtequb 3 | .setcpu 8080 4 | .code 5 | 6 | ; true if HL >= DE 7 | 8 | __cmpgtequ: 9 | mov a,h 10 | cmp d 11 | jc __false 12 | jnz __true 13 | __cmpgtequb: 14 | mov a,l 15 | cmp e 16 | jc __false 17 | jmp __true 18 | -------------------------------------------------------------------------------- /support8085/__cmpgtequ.s: -------------------------------------------------------------------------------- 1 | .export __cmpgtequ 2 | .export __cmpgtequb 3 | .setcpu 8080 4 | .code 5 | 6 | ; true if HL >= DE 7 | 8 | __cmpgtequ: 9 | mov a,h 10 | cmp d 11 | jc __false 12 | jnz __true 13 | __cmpgtequb: 14 | mov a,l 15 | cmp e 16 | jc __false 17 | jmp __true 18 | -------------------------------------------------------------------------------- /supportz80/__minuseqc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object L = amount 3 | ; 4 | .export __minuseqc 5 | .export __minusequc 6 | .code 7 | 8 | __minuseqc: 9 | __minusequc: 10 | ex de,hl 11 | pop hl 12 | ex (sp),hl 13 | ld a,(hl) 14 | sub e 15 | ld (hl),a 16 | ld l,a 17 | ret 18 | 19 | -------------------------------------------------------------------------------- /supportz80/__postdecc.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; TOS = lval of object HL = amount 3 | ; 4 | .export __postdecc 5 | .code 6 | 7 | __postdecc: 8 | ex de,hl 9 | pop hl 10 | ex (sp),hl 11 | ld a,(hl) 12 | ld d,a ; save old value 13 | sub e 14 | ld (hl),a 15 | ld l,d ; return old value 16 | ret 17 | -------------------------------------------------------------------------------- /test/run-test8070.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in tests/*.c 4 | do 5 | b=$(basename $i .c) 6 | echo $b":" 7 | fcc -X -m8070 -c tests/$b.c 8 | ld8070 -b -C1 -Z0xFF00 -m tests/$b.map -o tests/$b testcrt0_8070.o tests/$b.o /opt/fcc/lib/8070/lib8070.a 9 | ./emu807x tests/$b tests/$b.map 10 | done 11 | --------------------------------------------------------------------------------