diff --git a/test/define.c02 b/test/define.c02 new file mode 100644 index 0000000..7cc2f4d --- /dev/null +++ b/test/define.c02 @@ -0,0 +1,8 @@ +/* Test C02 define directive */ + +#define TRUE = $FF +#define FALSE = 0 + +char b; + +b = #TRUE; diff --git a/test/if.c02 b/test/if.c02 new file mode 100644 index 0000000..cb608f6 --- /dev/null +++ b/test/if.c02 @@ -0,0 +1,12 @@ +/* Test If/Then/Else */ + +#pragma origin $0200 + +char b,c,d,e; + +if (b:-) b=c; +else if (!b) b=d; +else b=e; +goto exit; + + diff --git a/test/notes.txt b/test/notes.txt new file mode 100644 index 0000000..6b50581 --- /dev/null +++ b/test/notes.txt @@ -0,0 +1,8 @@ +OP VALUE += 1 +< 2 +<= 3 +> 4 +>= 5 +<> 6 + diff --git a/test/test.c02 b/test/test.c02 new file mode 100644 index 0000000..230ae66 --- /dev/null +++ b/test/test.c02 @@ -0,0 +1,173 @@ +/******************************************** + * C02 - C-like language for 6502 processor * + * Test file for Compiler * + ********************************************/ + +#include "testhdr.h02" + +//#define CR $0D -- DEFINE needs to be reimplimented + +/* Variable Types */ +char b , i; //byte type has been removed +char c,d,f; //a char is an unsigned 8 bit number +char r[15]; //reserves dimension bytes +char z[15]; +char t = {1, 2, 3, 4, 5}; //Not Implemented? +char s = "This is a string."; +char aa,xx,yy ; //Function parameter variables +char STROBE; //Strobe Register + +/* Function Declaration */ +char myfunc(); + return b-c-d; + return; + +main: + +/* Register Assignments */ +b = A; +c = X + 1; +d = Y - 1; +A = 'A'; +A = c - 1; +A = strlen(s); +X = 0; +Y = 'Y'; +X = c; + +/* Variable Assignments */ +b=-1+2-3; +c='@' & 5; +d = b|c^$FF; +f = %10100101; + +/* Write to Strobe Register */ +STROBE; + +/* Variable Post-Operators */ +d++; +d--; +b<<; +c>>; + +/* Register Post-Operators */ +X++; +Y++; +X--; +Y--; +A>>; +A<<; + +i = 0; +r[i] = i; +r[i]++; +z[i]=r[i]; +b=z[A]+z[X]+z[Y]+z[0]+z[i]; + +funcx: +f = testfn(b); //Simple Variable +f = testfn(r[i]); //Array Element +f = testfn(r[i],b); //Two Parameters +f = testfn(r[1],r[2]); //Two Array Elements +f = testfn(r[1],r[2],b); //Three Parameters +f = testfn(&s); //Pointer +f = testfn(b,&s); //Byte and Pointer +f = testfn(r[i],&s); //Array Element and Pointer +f = testfn(r[1],&s); //Array Element and Pointer +f = testfn(b+c+d,&s); //Expression in Function Call +f = testfn(getkey(b)+c); //Nested Function Call + +funcs: +prchr(b+c+d); +testfn(prchr(b)); +testfn(b,c,d); +testfn(b+c+d,r[i],f); +testfn(&s); //Print a String +dofn(*,yy); +dofn(*,yy,xx); +dofn(aa,*,xx); +dofn(*,*,XX); + +/* +defs: +c = CR; +echo(CR); +#error +*/ + +flwctl: +if (d<>f) i = b + c; + +if (i=0) + i++; +else + i--; + +here: if (getkey() & $7F == $1B) goto exit; + +there: goto flwctl; + +i = 0; +while (i < 10) { + i++; +} +while (i:+) { + i--; +} + + + +do { + c = rdkey(); +} while (c=0); + +do { + c = rdkey(); + if (c=0) continue; + if (c=27) break; +} while (c<>13); + + +for (i=1; i<9; i++) + prchr(i); + +if (d