mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-25 06:31:25 +00:00
Added py65 test programs conds.c02 and loops.c02
This commit is contained in:
parent
6f719908dc
commit
c3cc4be48c
57
py65/conds.c02
Normal file
57
py65/conds.c02
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/****************************************
|
||||||
|
* CONDS - Test Conditional Expressions *
|
||||||
|
****************************************/
|
||||||
|
|
||||||
|
#include <py65.h02>
|
||||||
|
#include <stdio.h02>
|
||||||
|
#include <stdlib.h02>
|
||||||
|
|
||||||
|
char passed = " Passed. ";
|
||||||
|
char failed = " Failed. ";
|
||||||
|
|
||||||
|
main:
|
||||||
|
puts("1==1 "); if (1==1) puts(&passed); else puts(&failed);
|
||||||
|
puts("1==2 "); if (1==2) puts(&failed); else puts(&passed);
|
||||||
|
puts("1+1=2"); if (1+1 == 2) puts(&passed); else puts(&failed);
|
||||||
|
puts("1<>2 "); if (1<>2) puts(&passed); else puts(&failed);
|
||||||
|
puts("1<>1 "); if (1<>1) putln(&failed); else putln(&passed);
|
||||||
|
|
||||||
|
puts("1<2 "); if (1<2) puts(&passed); else puts(&failed);
|
||||||
|
puts("2<1 "); if (2<1) puts(&failed); else puts(&passed);
|
||||||
|
puts("1<1 "); if (1<1) putln(&failed); else putln(&passed);
|
||||||
|
|
||||||
|
puts("1<=2 "); if (1<=2) puts(&passed); else puts(&failed);
|
||||||
|
puts("2<=1 "); if (2<=1) puts(&failed); else puts(&passed);
|
||||||
|
puts("1<=1 "); if (1<=1) putln(&passed); else putln(&failed);
|
||||||
|
|
||||||
|
puts("2>1 "); if (2>1) puts(&passed); else puts(&failed);
|
||||||
|
puts("1>2 "); if (1>2) puts(&failed); else puts(&passed);
|
||||||
|
puts("1>1 "); if (1>1) putln(&failed); else putln(&passed);
|
||||||
|
|
||||||
|
puts("2>=1 "); if (2>=1) puts(&passed); else puts(&failed);
|
||||||
|
puts("1>=2 "); if (1>=2) puts(&failed); else puts(&passed);
|
||||||
|
puts("1>=1 "); if (1>=1) putln(&passed); else putln(&failed);
|
||||||
|
|
||||||
|
puts("$FF "); if ($FF) puts(&passed); else puts(&failed);
|
||||||
|
puts("$00 "); if ($00) puts(&failed); else puts(&passed);
|
||||||
|
puts("1|0 "); if (1|0) puts(&passed); else puts(&failed);
|
||||||
|
puts("1&0 "); if (1&0) puts(&failed); else puts(&passed);
|
||||||
|
puts("1^1 "); if (1^1) putln(&failed); else putln(&passed);
|
||||||
|
|
||||||
|
puts("!$FF "); if (!$FF) puts(&failed); else puts(&passed);
|
||||||
|
puts("!$00 "); if (!$00) puts(&passed); else puts(&failed);
|
||||||
|
puts("!1|0 "); if (!1|0) puts(&failed); else puts(&failed);
|
||||||
|
puts("!1&0 "); if (!1&0) puts(&passed); else puts(&failed);
|
||||||
|
puts("!1^1 "); if (!1^1) putln(&passed); else putln(&failed);
|
||||||
|
|
||||||
|
puts("$FF:+"); if ($FF:+) puts(&failed); else puts(&passed);
|
||||||
|
puts("$FF:-"); if ($FF:-) puts(&passed); else puts(&failed);
|
||||||
|
puts("$00:+"); if ($00:+) puts(&passed); else puts(&failed);
|
||||||
|
puts("$00:-"); if ($00:-) puts(&failed); else puts(&passed);
|
||||||
|
puts("!0:+ "); if (!0:+) putln(&failed); else putln(&passed);
|
||||||
|
|
||||||
|
puts("atoc(\"0\")"); if (atoc("0")) puts(&failed); else puts(&passed);
|
||||||
|
puts("atoc(\"1\")"); if (atoc("1")) puts(&passed); else puts(&failed);
|
||||||
|
puts("atoc(\"128\"):-"); if (atoc("128"):-) putln(&passed); else putln(&failed);
|
||||||
|
|
||||||
|
goto exit;
|
109
py65/loops.c02
Normal file
109
py65/loops.c02
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/************************************
|
||||||
|
* LOOPS - Test C02 Loop Structures *
|
||||||
|
************************************/
|
||||||
|
|
||||||
|
#include <py65.h02>
|
||||||
|
#include <stdio.h02>
|
||||||
|
|
||||||
|
char i, b;
|
||||||
|
char failed = " Test Failed!";
|
||||||
|
|
||||||
|
main:
|
||||||
|
|
||||||
|
/* Test If/Goto Loop */
|
||||||
|
puts("IF ");
|
||||||
|
i = 0;
|
||||||
|
ifloop:
|
||||||
|
prbyte(i);
|
||||||
|
putc(' ');
|
||||||
|
i++;
|
||||||
|
if (i < 10) goto ifloop;
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
/* Test While Loop */
|
||||||
|
puts("WHILE ");
|
||||||
|
i = 0;
|
||||||
|
while (i < 10) {
|
||||||
|
prbyte(i);
|
||||||
|
putc(' ');
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
/* Test Do Loop */
|
||||||
|
puts("DO ");
|
||||||
|
i = 0;
|
||||||
|
do {
|
||||||
|
prbyte(i);
|
||||||
|
putc(' ');
|
||||||
|
i++;
|
||||||
|
} while (i<10);
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
/* Test For Loop */
|
||||||
|
puts("FOR ");
|
||||||
|
i = 0;
|
||||||
|
for (i=0;i<10;i++) {
|
||||||
|
prbyte(i);
|
||||||
|
putc(' ');
|
||||||
|
}
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
/* While with Break */
|
||||||
|
puts("BREAK ");
|
||||||
|
i = 0;
|
||||||
|
while ($FF) {
|
||||||
|
if (i = 10) break;
|
||||||
|
prbyte(i);
|
||||||
|
putc(' ');
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
/* For with Continue */
|
||||||
|
puts("CONT ");
|
||||||
|
for (i=0;i<10;i++) {
|
||||||
|
if (i & 1) continue;
|
||||||
|
prbyte(i);
|
||||||
|
putc(' ');
|
||||||
|
}
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
/* Test Block If */
|
||||||
|
putln("BLOCK IF");
|
||||||
|
b = 1;
|
||||||
|
if (b>0) {
|
||||||
|
prbyte(b);
|
||||||
|
puts(" is greater than ");
|
||||||
|
prbyte(0);
|
||||||
|
newlin();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
putln(&failed);
|
||||||
|
b = 0;
|
||||||
|
if (b>0) {
|
||||||
|
putln(&failed);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
prbyte(b);
|
||||||
|
puts(" is equal to ");
|
||||||
|
prbyte(0);
|
||||||
|
newlin();
|
||||||
|
}
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
/* Test If/Else in For Loop */
|
||||||
|
putln("FOR/IF/ELSE");
|
||||||
|
for(i = 0;i<4;i++) {
|
||||||
|
prbyte(i);
|
||||||
|
if (i & 1)
|
||||||
|
putln(" is odd");
|
||||||
|
else
|
||||||
|
putln(" is even");
|
||||||
|
}
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
|
||||||
|
goto exit;
|
Loading…
Reference in New Issue
Block a user