1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-08 21:29:30 +00:00

Various updates to py65/ test programs

This commit is contained in:
Curtis F Kaylor 2019-03-22 19:32:08 -04:00
parent 251c5edb8b
commit 65b50c7003
12 changed files with 77 additions and 86 deletions

View File

@ -12,9 +12,11 @@ char key; //Key value
main: main:
while() { while() {
key = rdkey(); key = rdkey();
if (key = $1B) break; if (key = #ESCKEY) break;
prchr(key); select (key) {
if (key = $0D) prchr($0A); case #DELKEY: delchr();
case #RTNKEY: newlin();
default: prchr(key);
}
} }
goto exit; goto exit;

View File

@ -3,9 +3,10 @@
**********************************************/ **********************************************/
#include <py65.h02> #include <py65.h02>
#include <stddef.h02>
#include <stdlib.h02>
#include <stdio.h02> #include <stdio.h02>
#include <stdiox.h02> #include <stdiox.h02>
#include <stdlib.h02>
#include <memory.h02> #include <memory.h02>
#include <string.h02> #include <string.h02>

View File

@ -9,7 +9,7 @@ char key; //Key read from keyboard
main: main:
key = getkey(); //Read key from console key = getkey(); //Read key from console
if (key = $1B) //If Escape was pressed if (key = #ESCKEY) //If Escape was pressed
goto exit; // return to monitor goto exit; // return to monitor
prbyte(key); //Print ASCII value of key prbyte(key); //Print ASCII value of key
prchr(' '); // and a space prchr(' '); // and a space

View File

@ -14,14 +14,13 @@
#include <memory.h02> #include <memory.h02>
#include <block.h02> #include <block.h02>
char c, i, n, r, z; char c, i, n, r, z;
char savlo,savhi,tmplo,tmphi; //Address Pointer char savlo,savhi,tmplo,tmphi; //Address Pointer
char chkhi,chklo; //Address Check char chkhi,chklo; //Address Check
char number[5]; char number[5];
char numbrs = "zero one two threefour five six seveneightnine ten"; const char numbrs = "zero one two threefour five six seveneightnine ten";
char sorted = {8,5,4,9,1,7,6,3,2,0}; const char sorted = {8,5,4,9,1,7,6,3,2,0};
char name1 = "Dick", name2 = "Jane"; const char name1 = "Dick", name2 = "Jane";
char block[255]; //Array to Use as Block char block[255]; //Array to Use as Block
char temp[127]; char temp[127];
char seglo[9],seghi[9]; char seglo[9],seghi[9];

View File

@ -9,7 +9,7 @@
#include <stdiox.h02> #include <stdiox.h02>
char c, i, j; char c, i, j;
char s = "string"; const char s = "string";
main: main:
@ -53,6 +53,15 @@ do {
} while (i); } while (i);
anykey(); anykey();
putln("prtbin()");
do {
putbin(i);
putc(':');
i++;
if (!i&7) newlin();
} while (i);
anykey();
putln("prtwrd()"); putln("prtwrd()");
do { do {
j = i ^ $FF; j = i ^ $FF;
@ -80,7 +89,7 @@ done:
goto exit; goto exit;
void pfchar(c) { void pfchar(c) {
if (c<32) printf(c," H='%h' R='%r' L='%l' D='%d'"); if (c<32) printf(c," B='%b' H='%h' R='%r' L='%l' D='%d'");
else printf(c,"C='%c' H='%h' R='%r' L='%l' D='%d'"); else printf(c,"C='%c' B= '%b' H='%h' R='%r' L='%l' D='%d'");
} }

View File

@ -3,6 +3,7 @@
****************************************/ ****************************************/
#include <py65.h02> #include <py65.h02>
#include <stddef.h02>
#include <stdlib.h02> #include <stdlib.h02>
#include <stdio.h02> #include <stdio.h02>
#include <stdiox.h02> #include <stdiox.h02>
@ -10,16 +11,16 @@
#include <memio.h02> #include <memio.h02>
#include <string.h02> #include <string.h02>
char zp = $80; //Zero Page Location for Memory Pointer #define ZP $80 //Zero Page Location for Memory Pointer
char lsb, msb; //Memory Pointer Contents char lsb, msb; //Memory Pointer Contents
char passed; //Flags char passed; //Flags
char f[255]; //Array to use as file char f[255]; //Array to use as file
char fp,mp,op; //Memory File Pointers char fp,mp,op; //Memory File Pointers
char c, e, i; //Testing Variables char c, e, i; //Testing Variables
char s[128]; //Array for String Read/Writes char s[128]; //Array for String Read/Writes
char digits = "0123456789"; const char digits = "0123456789";
char upcase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const char upcase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char locase = "abcdefghijklmnopqrstuvwxyz"; const char locase = "abcdefghijklmnopqrstuvwxyz";
alias char outfil = $9000; //Output File alias char outfil = $9000; //Output File
@ -28,11 +29,11 @@ main:
mp = 0; //Initialize Memory Pointer mp = 0; //Initialize Memory Pointer
putln("Opening memory file at $8000."); putln("Opening memory file at $8000.");
mp = mopen(zp, &$8000); mp = mopen(#ZP, &$8000);
puts(" Memory pointer: "); puts(" Memory pointer: ");
prbyte(mp); prbyte(mp);
if (mp == zp) pass(); else fail(); if (mp == #ZP) pass(); else fail();
puts(" Address: "); puts(" Address: ");
lsb, msb = maddr(mp); lsb, msb = maddr(mp);
@ -60,7 +61,7 @@ newlin();
anykey(); anykey();
putln("Reading File using mgets()"); putln("Reading File using mgets()");
mp = mopen(zp, &$8000); mp = mopen(#ZP, &$8000);
while (!meof(mp)) { while (!meof(mp)) {
lsb, msb = maddr(mp); lsb, msb = maddr(mp);
prbyte(msb); prbyte(lsb); prbyte(msb); prbyte(lsb);
@ -76,7 +77,7 @@ anykey();
/* Test mputc() with mopen() to array */ /* Test mputc() with mopen() to array */
putln("Opening array f as memory file"); putln("Opening array f as memory file");
fp = mopen(zp+2, &f); fp = mopen(#ZP+2, &f);
puts(" Memory pointer: "); prbyte(fp); puts(" Memory pointer: "); prbyte(fp);
if (merror(fp)) fail(); else pass(); if (merror(fp)) fail(); else pass();
@ -98,7 +99,7 @@ putln("Filling memory area outfil");
for (i = 0; i<255; i++) outfil[i] = '@'; for (i = 0; i<255; i++) outfil[i] = '@';
putln("Opening location outfil as memory file"); putln("Opening location outfil as memory file");
op = mopen(zp+4, &outfil); op = mopen(#ZP+4, &outfil);
puts(" Memory pointer: "); prbyte(op); puts(" Memory pointer: "); prbyte(op);
if (merror(op)) fail(); else pass(); if (merror(op)) fail(); else pass();
@ -122,7 +123,7 @@ anykey();
/* Test mgetc(), and mgets() with mopen() to alias */ /* Test mgetc(), and mgets() with mopen() to alias */
putln("Opening location outfil as memory file"); putln("Opening location outfil as memory file");
op = mopen(zp+4, &outfil); op = mopen(#ZP+4, &outfil);
puts(" Memory pointer: "); prbyte(op); puts(" Memory pointer: "); prbyte(op);
if (merror(op)) fail(); else pass(); if (merror(op)) fail(); else pass();
@ -155,7 +156,7 @@ memset(0, 255);
mp = 0; //Initialize Memory Pointer mp = 0; //Initialize Memory Pointer
putln("Opening memory file at $9000."); putln("Opening memory file at $9000.");
mp = mopen(zp, &$9000); mp = mopen(#ZP, &$9000);
putln("Writing to memory file using mwrite()"); putln("Writing to memory file using mwrite()");
msrc(&digits); mwrite(mp, 10); msrc(&digits); mwrite(mp, 10);
@ -164,18 +165,16 @@ msrc(&locase); mwrite(mp, 26);
newlin(); newlin();
putln("Opening memory file at $9000."); putln("Opening memory file at $9000.");
mp = mopen(zp, &$9000); mp = mopen(#ZP, &$9000);
putln("Reading from memory file using mread()"); putln("Reading from memory file using mread()");
iarray(&s); mread(mp, 10); puts(&s); putc(':'); if (strcmp(&digits)) pass(); else fail(); iarray(&s); mread(mp, 10); puts(&s); putc(':'); if (strcmp(&digits)) fail(); else pass();
iarray(&s); mread(mp, 26); puts(&s); putc(':'); if (strcmp(&upcase)) pass(); else fail(); iarray(&s); mread(mp, 26); puts(&s); putc(':'); if (strcmp(&upcase)) fail(); else pass();
iarray(&s); mread(mp, 26); puts(&s); putc(':'); if (strcmp(&locase)) pass(); else fail(); iarray(&s); mread(mp, 26); puts(&s); putc(':'); if (strcmp(&locase)) fail(); else pass();
mread(mp,0); putdec(s); putc(':'); if (s) fail(); else pass(); mread(mp,0); putdec(s); putc(':'); if (s) fail(); else pass();
goto exit; goto exit;
void anykey() {newlin(); putln("Press any key..."); getc(); newlin();}
void pass() { putln(" Passed"); } void pass() { putln(" Passed"); }
void fail() { putln(" Failed"); } void fail() { putln(" Failed"); }

View File

@ -148,24 +148,6 @@ caloop:
prchr('K'); prchr('K');
newlin(); newlin();
doswap:
char i,j,m,n,p,r;
for (i=0;i<16;i++) {
for (j=0;j<16;j++) {
m = shiftl(i,4)+j; prbyte(m);
n = shiftl(j,5)+i; prchr('~');
p = swap(m); prbyte(p);
prchr(' ');
}
newlin();
}
prchr('s');
prchr('w');
prchr('a');
prchr('p');
prchr(' ');
prchr('O');
prchr('K');
goto exit; goto exit;

View File

@ -3,6 +3,7 @@
************************************************/ ************************************************/
#include <py65.h02> #include <py65.h02>
#include <stddef.h02>
#include <stdio.h02> #include <stdio.h02>
char c; char c;

View File

@ -11,13 +11,11 @@
#include <memory.h02> #include <memory.h02>
#include <stack.h02> #include <stack.h02>
char TRUE=$FF, FALSE=$00;
char c,f,g,i; char c,f,g,i;
char aa,xx,yy; char aa,xx,yy;
char lo,hi; char lo,hi;
char r={6,7,8,9}; const char r={6,7,8,9};
char s="Test String"; const char s="Test String";
char t[255]; char t[255];
main: main:
@ -73,7 +71,7 @@ puts("Pushing Array onto Stack\t");
puts("stkpsh(@r,$r)\t"); puts("stkpsh(@r,$r)\t");
aa,hi,lo=stkptr(); //Save Stack Pointer aa,hi,lo=stkptr(); //Save Stack Pointer
f=stkpsh(@r,&r); printf(f,"bytes=%d:"); f=stkpsh(@r,&r); printf(f,"bytes=%d:");
setdst(*,hi,lo); g=(memcmp(@r, &r)==0) ? TRUE : FALSE; setdst(*,hi,lo); g=(memcmp(@r, &r)==0) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$8004); chkptr(&$8004);
@ -81,7 +79,7 @@ puts("Duplicating Top of Stack\t");
puts("stkdup()\t"); puts("stkdup()\t");
aa,hi,lo=stkptr(); //Save Stack Pointer aa,hi,lo=stkptr(); //Save Stack Pointer
f=stkdup(); printf(f,"bytes=%d:"); f=stkdup(); printf(f,"bytes=%d:");
setdst(*,hi,lo); g=(memcmp(@r, &r)==0) ? TRUE : FALSE; setdst(*,hi,lo); g=(memcmp(@r, &r)==0) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$8009); chkptr(&$8009);
@ -89,7 +87,7 @@ puts("Pushing String onto Stack\t");
puts("stkstr(&s)\t"); puts("stkstr(&s)\t");
aa,hi,lo=stkptr(); //Save Stack Pointer aa,hi,lo=stkptr(); //Save Stack Pointer
f=stkstr(&s); printf(f,"bytes=%d:"); f=stkstr(&s); printf(f,"bytes=%d:");
setdst(*,hi,lo); g=(strcmp(&s)==0) ? TRUE : FALSE; setdst(*,hi,lo); g=(strcmp(&s)==0) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$8016); chkptr(&$8016);
@ -97,7 +95,7 @@ puts("Duplicating Second Stack Entry\t");
puts("stkovr()\t"); puts("stkovr()\t");
aa,hi,lo=stkptr(); //Save Stack Pointer aa,hi,lo=stkptr(); //Save Stack Pointer
f=stkovr(); printf(f,"bytes=%d:"); f=stkovr(); printf(f,"bytes=%d:");
setdst(*,hi,lo); g=(memcmp(@r, &r)==0) ? TRUE : FALSE; setdst(*,hi,lo); g=(memcmp(@r, &r)==0) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$801B); chkptr(&$801B);
@ -106,35 +104,35 @@ c = anykey(); if (c == #esckey) goto exit;
puts("Dropping Duplicate off Stack\t"); puts("Dropping Duplicate off Stack\t");
puts("stkdrp()\t"); puts("stkdrp()\t");
f=stkdrp(); printf(f,"bytes=%d:"); f=stkdrp(); printf(f,"bytes=%d:");
g=(f==4) ? TRUE : FALSE; g=(f==4) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$8016); chkptr(&$8016);
puts("Copying String from Stack\t"); puts("Copying String from Stack\t");
puts("stktop(&t)\t"); puts("stktop(&t)\t");
f=stktop(&t); setdst(&t); printf("\"%s\":"); f=stktop(&t); setdst(&t); printf("\"%s\":");
g=(strcmp(&s)==0) ? TRUE : FALSE; g=(strcmp(&s)==0) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$8016); chkptr(&$8016);
puts("Popping String off Stack\t"); puts("Popping String off Stack\t");
puts("stkpop(&t)\t"); puts("stkpop(&t)\t");
f=stkpop(&t); setdst(&t); printf("\"%s\":"); f=stkpop(&t); setdst(&t); printf("\"%s\":");
g=(strcmp(&s)==0) ? TRUE : FALSE; g=(strcmp(&s)==0) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$8009); chkptr(&$8009);
puts("Dropping Duplicate off Stack\t"); puts("Dropping Duplicate off Stack\t");
puts("stkdrp()\t"); puts("stkdrp()\t");
f=stkdrp(); printf(f,"bytes=%d:"); f=stkdrp(); printf(f,"bytes=%d:");
g=(f==4) ? TRUE : FALSE; g=(f==4) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$8004); chkptr(&$8004);
puts("Popping Array off Stack\t\t"); puts("Popping Array off Stack\t\t");
puts("stkpop(&t)\t"); puts("stkpop(&t)\t");
f=stkpop(&t); prtary(f); puts(": "); f=stkpop(&t); prtary(f); puts(": ");
g=(memcmp(f,&r)==0) ? TRUE : FALSE; g=(memcmp(f,&r)==0) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$7FFF); chkptr(&$7FFF);
@ -157,8 +155,8 @@ goto exit;
void chkptr(aa,yy,xx) { void chkptr(aa,yy,xx) {
puts("\tChecking Stack Pointer\t\t\t"); puts("\tChecking Stack Pointer\t\t\t");
puts("address=$"); prbyte(stkhi); prbyte(stklo); putc(':'); puts("address=$"); prbyte(stkhi); prbyte(stklo); putc(':');
xx = (stklo == xx) ? TRUE : FALSE; xx = (stklo == xx) ? #TRUE : #FALSE;
yy = (stkhi == yy) ? TRUE : FALSE; yy = (stkhi == yy) ? #TRUE : #FALSE;
psorfl(xx & yy); psorfl(xx & yy);
} }
@ -174,8 +172,8 @@ void prtary(aa) {
void cklohi(aa,yy,xx) { void cklohi(aa,yy,xx) {
putdst(); puts("lo=$"); prbyte(lo); putc(' '); putdst(); puts("lo=$"); prbyte(lo); putc(' ');
putdst(); puts("hi=$"); prbyte(hi); putc(':'); putdst(); puts("hi=$"); prbyte(hi); putc(':');
xx = (lo == xx) ? TRUE : FALSE; xx = (lo == xx) ? #TRUE : #FALSE;
yy = (hi == yy) ? TRUE : FALSE; yy = (hi == yy) ? #TRUE : #FALSE;
psorfl(xx & yy); psorfl(xx & yy);
} }
@ -188,14 +186,14 @@ void fail() {putln(" Fail");}
puts("Swapping Top and Second Entry\t"); puts("Swapping Top and Second Entry\t");
puts("stkswp()\t"); puts("stkswp()\t");
f=stkswp(); printf(f,"bytes=%d:"); f=stkswp(); printf(f,"bytes=%d:");
g=(f==12) ? TRUE : FALSE; g=(f==12) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$801B); chkptr(&$801B);
puts("Dropping Swapped Entry off Stack\t"); puts("Dropping Swapped Entry off Stack\t");
puts("stkdrp()\t"); puts("stkdrp()\t");
f=stkdrp(); printf(f,"bytes=%d:"); f=stkdrp(); printf(f,"bytes=%d:");
g=(f==4) ? TRUE : FALSE; g=(f==4) ? #TRUE : #FALSE;
psorfl(f & g); psorfl(f & g);
chkptr(&$8016); chkptr(&$8016);

View File

@ -8,16 +8,16 @@
#include <string.h02> #include <string.h02>
char slen, scmp, spos, stot; char slen, scmp, spos, stot;
char frst = "string one."; const char frst = "string one.";
char scnd = "string two."; const char scnd = "string two.";
char temp[32]; char temp[32];
char dest[32]; char dest[32];
char less = "less"; const char less = "less";
char more = "more"; const char more = "more";
char most = "most"; const char most = "most";
char test = "test"; const char test = "test";
char pass = "Pass "; const char pass = "Pass ";
char fail = "Fail "; const char fail = "Fail ";
main: main:
//Test strchr //Test strchr

View File

@ -3,20 +3,20 @@
********************************************/ ********************************************/
#include <py65.h02> #include <py65.h02>
#include <stddef.h02>
#include <stdio.h02> #include <stdio.h02>
#include <string.h02> #include <string.h02>
#include <stringx.h02> #include <stringx.h02>
char slen, sres; char slen, sres;
char span = "abcdef"; const char span = "abcdef";
char smax[128]; char smax[128];
char scba = "cba"; const char scba = "cba";
char sfed = "fed"; const char sfed = "fed";
char sxyz = "xyz"; const char sxyz = "xyz";
char snul = ""; const char snul = "";
char pass = "Pass "; const char pass = "Pass ";
char fail = "Fail "; const char fail = "Fail ";
void tests(slen) { void tests(slen) {

View File

@ -14,8 +14,8 @@
char c,f,g,i; char c,f,g,i;
char aa,xx,yy; char aa,xx,yy;
char lo,hi; char lo,hi;
char r={6,7,8,9}; const char r={6,7,8,9};
char s="Test String"; const char s="Test String";
char t[255]; char t[255];
main: main:
@ -70,7 +70,7 @@ puts("stkend($8013)\t");
stkend(&$8013 ); lo=stkelo; hi=stkehi; stkend(&$8013 ); lo=stkelo; hi=stkehi;
setdst("stke"); cklohi(&$8013); setdst("stke"); cklohi(&$8013);
puts("Swapping with Unsufficient Space\t"); puts("Swapping w/ Unsufficient Space\t");
puts("stkswp()\t"); puts("stkswp()\t");
f=stkswp(); printf(f,"bytes=%d:"); f=stkswp(); printf(f,"bytes=%d:");
g=(f==0) ? #TRUE : #FALSE; g=(f==0) ? #TRUE : #FALSE;