1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-22 16:34:15 +00:00
C02/work/test.c02

206 lines
3.7 KiB
Plaintext
Raw Normal View History

2018-01-28 19:47:06 +00:00
/********************************************
* C02 - C-like language for 6502 processor *
* Test file for Compiler *
********************************************/
2018-07-24 04:30:00 +00:00
#pragma padding 1
2018-01-28 19:47:06 +00:00
2018-03-07 16:38:22 +00:00
/* Constants */
#define TRUE $FF
#define FALSE 0
#define BITS %01010101
#define ZED 'Z'
2018-01-28 19:47:06 +00:00
2018-03-07 17:00:33 +00:00
/* Enumerations */
enum {SOLO};
enum {BLACK, WHITE, RED, CYAN, PURPLE, GREEN, BLUE, YELLOW};
enum {NONE, FIRST, SECOND, THIRD};
enum {ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN};
2018-01-28 19:47:06 +00:00
/* 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];
2018-08-04 22:29:04 +00:00
const char n = {1, 2, 3, 4, 5};
const char s = "This is a string.";
const char m = {"mixed", 1, "const", 2, "array", 3};
2018-01-28 19:47:06 +00:00
char aa,xx,yy ; //Function parameter variables
char STROBE; //Strobe Register
/* Aliased Variables */
alias char zp = $80; //aliased to zero page
alias char via = $D000; //aliased to i/o mapped device
alias char cc = c; //aliased to variable
alias char rr = r; //aliased to array
/* Aliased Function */
//alias void chrout() = $F000; //aliased to ROM routine
2018-01-28 19:47:06 +00:00
/* 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[i],b); //Two Parameters
f = testfn(r[b],r[c]); //Two Array Elements
2018-01-28 19:47:06 +00:00
f = testfn(r[1],r[2]); //Two Array Elements
f = testfn(r[1],r[2],b); //Three Parameters
f = testfn(s); //Implicit Address
f = testfn(&s); //Explicit Address
f = testfn(b,s); //Byte and Implicit Address
f = testfn(b,&s); //Byte and Explicit Address
f = testfn(r[i],s); //Array Element and Implicit Address
f = testfn(r[1],&s); //Array Element and Explicit Address
f = testfn(b+c+d,r); //Expression in Function Call
2018-01-28 19:47:06 +00:00
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); //Explicit Address Reference
testfn(s); //Implicit Address Reference
dofn(?,yy);
dofn(?,yy,xx);
dofn(aa,?,xx);
dofn(?,?,XX);
2018-01-28 19:47:06 +00:00
/*
defs:
c = CR;
echo(CR);
#error
*/
flwctl:
if (d<>f) i = b + c;
if (i=0)
i++;
else
i--;
2018-01-28 19:47:06 +00:00
here: if (getkey() & $7F == $1B) goto exit;
there: goto flwctl;
goto &$C000;
if (#TRUE) putln("TRUE");
else if (#FALSE) putln("FALSE");
2018-01-28 19:47:06 +00:00
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 (@z == @r)
for (i=0; i<=@z; i++)
z[i] = r[i];
2018-01-28 19:47:06 +00:00
if (d<f) i=b; else i=c; //Regular IF
i = (d<f) ? b : c; //Shortcut IF
char tstfnc() {
r[0] = 0;
z[0] = 0;
return i;
}
void vdfnc1(aa) {
aa = aa + 1;
}
void vdfnc2(aa, yy) {
aa = aa + yy;
}
void vdfnc3(aa, yy, xx) {
aa = aa + yy + xx;
}
push &s, b+c+d, r[i];
stkfnc(); //Push/Pop Parameters
pop d, ?, z[f];
2018-01-28 19:47:06 +00:00
iprint(); inline "Hello World";
irect(); inline 10,10,100,100;
isort(); inline &r;
blkbgn(&$C000);
blkend(&$C400);
while () {
i++;
break;
}
exit();