mirror of https://github.com/RevCurtisP/C02.git
Various updates to py65/ test programs
This commit is contained in:
parent
251c5edb8b
commit
65b50c7003
|
@ -12,9 +12,11 @@ char key; //Key value
|
|||
main:
|
||||
while() {
|
||||
key = rdkey();
|
||||
if (key = $1B) break;
|
||||
prchr(key);
|
||||
if (key = $0D) prchr($0A);
|
||||
if (key = #ESCKEY) break;
|
||||
select (key) {
|
||||
case #DELKEY: delchr();
|
||||
case #RTNKEY: newlin();
|
||||
default: prchr(key);
|
||||
}
|
||||
}
|
||||
goto exit;
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
**********************************************/
|
||||
|
||||
#include <py65.h02>
|
||||
#include <stddef.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <stdio.h02>
|
||||
#include <stdiox.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <memory.h02>
|
||||
#include <string.h02>
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ char key; //Key read from keyboard
|
|||
|
||||
main:
|
||||
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
|
||||
prbyte(key); //Print ASCII value of key
|
||||
prchr(' '); // and a space
|
||||
|
|
|
@ -14,14 +14,13 @@
|
|||
#include <memory.h02>
|
||||
#include <block.h02>
|
||||
|
||||
|
||||
char c, i, n, r, z;
|
||||
char savlo,savhi,tmplo,tmphi; //Address Pointer
|
||||
char chkhi,chklo; //Address Check
|
||||
char number[5];
|
||||
char numbrs = "zero one two threefour five six seveneightnine ten";
|
||||
char sorted = {8,5,4,9,1,7,6,3,2,0};
|
||||
char name1 = "Dick", name2 = "Jane";
|
||||
const char numbrs = "zero one two threefour five six seveneightnine ten";
|
||||
const char sorted = {8,5,4,9,1,7,6,3,2,0};
|
||||
const char name1 = "Dick", name2 = "Jane";
|
||||
char block[255]; //Array to Use as Block
|
||||
char temp[127];
|
||||
char seglo[9],seghi[9];
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <stdiox.h02>
|
||||
|
||||
char c, i, j;
|
||||
char s = "string";
|
||||
const char s = "string";
|
||||
|
||||
main:
|
||||
|
||||
|
@ -53,6 +53,15 @@ do {
|
|||
} while (i);
|
||||
anykey();
|
||||
|
||||
putln("prtbin()");
|
||||
do {
|
||||
putbin(i);
|
||||
putc(':');
|
||||
i++;
|
||||
if (!i&7) newlin();
|
||||
} while (i);
|
||||
anykey();
|
||||
|
||||
putln("prtwrd()");
|
||||
do {
|
||||
j = i ^ $FF;
|
||||
|
@ -80,7 +89,7 @@ done:
|
|||
goto exit;
|
||||
|
||||
void pfchar(c) {
|
||||
if (c<32) printf(c," H='%h' R='%r' L='%l' D='%d'");
|
||||
else printf(c,"C='%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' B= '%b' H='%h' R='%r' L='%l' D='%d'");
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
****************************************/
|
||||
|
||||
#include <py65.h02>
|
||||
#include <stddef.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <stdio.h02>
|
||||
#include <stdiox.h02>
|
||||
|
@ -10,16 +11,16 @@
|
|||
#include <memio.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 passed; //Flags
|
||||
char f[255]; //Array to use as file
|
||||
char fp,mp,op; //Memory File Pointers
|
||||
char c, e, i; //Testing Variables
|
||||
char s[128]; //Array for String Read/Writes
|
||||
char digits = "0123456789";
|
||||
char upcase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
char locase = "abcdefghijklmnopqrstuvwxyz";
|
||||
const char digits = "0123456789";
|
||||
const char upcase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const char locase = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
alias char outfil = $9000; //Output File
|
||||
|
||||
|
@ -28,11 +29,11 @@ main:
|
|||
mp = 0; //Initialize Memory Pointer
|
||||
|
||||
putln("Opening memory file at $8000.");
|
||||
mp = mopen(zp, &$8000);
|
||||
mp = mopen(#ZP, &$8000);
|
||||
|
||||
puts(" Memory pointer: ");
|
||||
prbyte(mp);
|
||||
if (mp == zp) pass(); else fail();
|
||||
if (mp == #ZP) pass(); else fail();
|
||||
|
||||
puts(" Address: ");
|
||||
lsb, msb = maddr(mp);
|
||||
|
@ -60,7 +61,7 @@ newlin();
|
|||
anykey();
|
||||
|
||||
putln("Reading File using mgets()");
|
||||
mp = mopen(zp, &$8000);
|
||||
mp = mopen(#ZP, &$8000);
|
||||
while (!meof(mp)) {
|
||||
lsb, msb = maddr(mp);
|
||||
prbyte(msb); prbyte(lsb);
|
||||
|
@ -76,7 +77,7 @@ anykey();
|
|||
/* Test mputc() with mopen() to array */
|
||||
|
||||
putln("Opening array f as memory file");
|
||||
fp = mopen(zp+2, &f);
|
||||
fp = mopen(#ZP+2, &f);
|
||||
puts(" Memory pointer: "); prbyte(fp);
|
||||
if (merror(fp)) fail(); else pass();
|
||||
|
||||
|
@ -98,7 +99,7 @@ putln("Filling memory area outfil");
|
|||
for (i = 0; i<255; i++) outfil[i] = '@';
|
||||
|
||||
putln("Opening location outfil as memory file");
|
||||
op = mopen(zp+4, &outfil);
|
||||
op = mopen(#ZP+4, &outfil);
|
||||
puts(" Memory pointer: "); prbyte(op);
|
||||
if (merror(op)) fail(); else pass();
|
||||
|
||||
|
@ -122,7 +123,7 @@ anykey();
|
|||
/* Test mgetc(), and mgets() with mopen() to alias */
|
||||
|
||||
putln("Opening location outfil as memory file");
|
||||
op = mopen(zp+4, &outfil);
|
||||
op = mopen(#ZP+4, &outfil);
|
||||
puts(" Memory pointer: "); prbyte(op);
|
||||
if (merror(op)) fail(); else pass();
|
||||
|
||||
|
@ -155,7 +156,7 @@ memset(0, 255);
|
|||
mp = 0; //Initialize Memory Pointer
|
||||
|
||||
putln("Opening memory file at $9000.");
|
||||
mp = mopen(zp, &$9000);
|
||||
mp = mopen(#ZP, &$9000);
|
||||
|
||||
putln("Writing to memory file using mwrite()");
|
||||
msrc(&digits); mwrite(mp, 10);
|
||||
|
@ -164,18 +165,16 @@ msrc(&locase); mwrite(mp, 26);
|
|||
newlin();
|
||||
|
||||
putln("Opening memory file at $9000.");
|
||||
mp = mopen(zp, &$9000);
|
||||
mp = mopen(#ZP, &$9000);
|
||||
|
||||
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, 26); puts(&s); putc(':'); if (strcmp(&upcase)) pass(); else fail();
|
||||
iarray(&s); mread(mp, 26); puts(&s); putc(':'); if (strcmp(&locase)) 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)) fail(); else pass();
|
||||
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();
|
||||
|
||||
goto exit;
|
||||
|
||||
void anykey() {newlin(); putln("Press any key..."); getc(); newlin();}
|
||||
|
||||
void pass() { putln(" Passed"); }
|
||||
void fail() { putln(" Failed"); }
|
||||
|
||||
|
|
|
@ -148,24 +148,6 @@ caloop:
|
|||
prchr('K');
|
||||
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;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
************************************************/
|
||||
|
||||
#include <py65.h02>
|
||||
#include <stddef.h02>
|
||||
#include <stdio.h02>
|
||||
|
||||
char c;
|
||||
|
|
|
@ -11,13 +11,11 @@
|
|||
#include <memory.h02>
|
||||
#include <stack.h02>
|
||||
|
||||
char TRUE=$FF, FALSE=$00;
|
||||
|
||||
char c,f,g,i;
|
||||
char aa,xx,yy;
|
||||
char lo,hi;
|
||||
char r={6,7,8,9};
|
||||
char s="Test String";
|
||||
const char r={6,7,8,9};
|
||||
const char s="Test String";
|
||||
char t[255];
|
||||
|
||||
main:
|
||||
|
@ -73,7 +71,7 @@ puts("Pushing Array onto Stack\t");
|
|||
puts("stkpsh(@r,$r)\t");
|
||||
aa,hi,lo=stkptr(); //Save Stack Pointer
|
||||
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);
|
||||
chkptr(&$8004);
|
||||
|
||||
|
@ -81,7 +79,7 @@ puts("Duplicating Top of Stack\t");
|
|||
puts("stkdup()\t");
|
||||
aa,hi,lo=stkptr(); //Save Stack Pointer
|
||||
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);
|
||||
chkptr(&$8009);
|
||||
|
||||
|
@ -89,7 +87,7 @@ puts("Pushing String onto Stack\t");
|
|||
puts("stkstr(&s)\t");
|
||||
aa,hi,lo=stkptr(); //Save Stack Pointer
|
||||
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);
|
||||
chkptr(&$8016);
|
||||
|
||||
|
@ -97,7 +95,7 @@ puts("Duplicating Second Stack Entry\t");
|
|||
puts("stkovr()\t");
|
||||
aa,hi,lo=stkptr(); //Save Stack Pointer
|
||||
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);
|
||||
chkptr(&$801B);
|
||||
|
||||
|
@ -106,35 +104,35 @@ c = anykey(); if (c == #esckey) goto exit;
|
|||
puts("Dropping Duplicate off Stack\t");
|
||||
puts("stkdrp()\t");
|
||||
f=stkdrp(); printf(f,"bytes=%d:");
|
||||
g=(f==4) ? TRUE : FALSE;
|
||||
g=(f==4) ? #TRUE : #FALSE;
|
||||
psorfl(f & g);
|
||||
chkptr(&$8016);
|
||||
|
||||
puts("Copying String from Stack\t");
|
||||
puts("stktop(&t)\t");
|
||||
f=stktop(&t); setdst(&t); printf("\"%s\":");
|
||||
g=(strcmp(&s)==0) ? TRUE : FALSE;
|
||||
g=(strcmp(&s)==0) ? #TRUE : #FALSE;
|
||||
psorfl(f & g);
|
||||
chkptr(&$8016);
|
||||
|
||||
puts("Popping String off Stack\t");
|
||||
puts("stkpop(&t)\t");
|
||||
f=stkpop(&t); setdst(&t); printf("\"%s\":");
|
||||
g=(strcmp(&s)==0) ? TRUE : FALSE;
|
||||
g=(strcmp(&s)==0) ? #TRUE : #FALSE;
|
||||
psorfl(f & g);
|
||||
chkptr(&$8009);
|
||||
|
||||
puts("Dropping Duplicate off Stack\t");
|
||||
puts("stkdrp()\t");
|
||||
f=stkdrp(); printf(f,"bytes=%d:");
|
||||
g=(f==4) ? TRUE : FALSE;
|
||||
g=(f==4) ? #TRUE : #FALSE;
|
||||
psorfl(f & g);
|
||||
chkptr(&$8004);
|
||||
|
||||
puts("Popping Array off Stack\t\t");
|
||||
puts("stkpop(&t)\t");
|
||||
f=stkpop(&t); prtary(f); puts(": ");
|
||||
g=(memcmp(f,&r)==0) ? TRUE : FALSE;
|
||||
g=(memcmp(f,&r)==0) ? #TRUE : #FALSE;
|
||||
psorfl(f & g);
|
||||
chkptr(&$7FFF);
|
||||
|
||||
|
@ -157,8 +155,8 @@ goto exit;
|
|||
void chkptr(aa,yy,xx) {
|
||||
puts("\tChecking Stack Pointer\t\t\t");
|
||||
puts("address=$"); prbyte(stkhi); prbyte(stklo); putc(':');
|
||||
xx = (stklo == xx) ? TRUE : FALSE;
|
||||
yy = (stkhi == yy) ? TRUE : FALSE;
|
||||
xx = (stklo == xx) ? #TRUE : #FALSE;
|
||||
yy = (stkhi == yy) ? #TRUE : #FALSE;
|
||||
psorfl(xx & yy);
|
||||
}
|
||||
|
||||
|
@ -174,8 +172,8 @@ void prtary(aa) {
|
|||
void cklohi(aa,yy,xx) {
|
||||
putdst(); puts("lo=$"); prbyte(lo); putc(' ');
|
||||
putdst(); puts("hi=$"); prbyte(hi); putc(':');
|
||||
xx = (lo == xx) ? TRUE : FALSE;
|
||||
yy = (hi == yy) ? TRUE : FALSE;
|
||||
xx = (lo == xx) ? #TRUE : #FALSE;
|
||||
yy = (hi == yy) ? #TRUE : #FALSE;
|
||||
psorfl(xx & yy);
|
||||
}
|
||||
|
||||
|
@ -188,14 +186,14 @@ void fail() {putln(" Fail");}
|
|||
puts("Swapping Top and Second Entry\t");
|
||||
puts("stkswp()\t");
|
||||
f=stkswp(); printf(f,"bytes=%d:");
|
||||
g=(f==12) ? TRUE : FALSE;
|
||||
g=(f==12) ? #TRUE : #FALSE;
|
||||
psorfl(f & g);
|
||||
chkptr(&$801B);
|
||||
|
||||
puts("Dropping Swapped Entry off Stack\t");
|
||||
puts("stkdrp()\t");
|
||||
f=stkdrp(); printf(f,"bytes=%d:");
|
||||
g=(f==4) ? TRUE : FALSE;
|
||||
g=(f==4) ? #TRUE : #FALSE;
|
||||
psorfl(f & g);
|
||||
chkptr(&$8016);
|
||||
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
#include <string.h02>
|
||||
|
||||
char slen, scmp, spos, stot;
|
||||
char frst = "string one.";
|
||||
char scnd = "string two.";
|
||||
const char frst = "string one.";
|
||||
const char scnd = "string two.";
|
||||
char temp[32];
|
||||
char dest[32];
|
||||
char less = "less";
|
||||
char more = "more";
|
||||
char most = "most";
|
||||
char test = "test";
|
||||
char pass = "Pass ";
|
||||
char fail = "Fail ";
|
||||
const char less = "less";
|
||||
const char more = "more";
|
||||
const char most = "most";
|
||||
const char test = "test";
|
||||
const char pass = "Pass ";
|
||||
const char fail = "Fail ";
|
||||
|
||||
main:
|
||||
//Test strchr
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
********************************************/
|
||||
|
||||
#include <py65.h02>
|
||||
#include <stddef.h02>
|
||||
#include <stdio.h02>
|
||||
#include <string.h02>
|
||||
#include <stringx.h02>
|
||||
|
||||
char slen, sres;
|
||||
char span = "abcdef";
|
||||
const char span = "abcdef";
|
||||
char smax[128];
|
||||
char scba = "cba";
|
||||
char sfed = "fed";
|
||||
char sxyz = "xyz";
|
||||
char snul = "";
|
||||
char pass = "Pass ";
|
||||
char fail = "Fail ";
|
||||
|
||||
const char scba = "cba";
|
||||
const char sfed = "fed";
|
||||
const char sxyz = "xyz";
|
||||
const char snul = "";
|
||||
const char pass = "Pass ";
|
||||
const char fail = "Fail ";
|
||||
|
||||
void tests(slen) {
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
char c,f,g,i;
|
||||
char aa,xx,yy;
|
||||
char lo,hi;
|
||||
char r={6,7,8,9};
|
||||
char s="Test String";
|
||||
const char r={6,7,8,9};
|
||||
const char s="Test String";
|
||||
char t[255];
|
||||
|
||||
main:
|
||||
|
@ -70,7 +70,7 @@ puts("stkend($8013)\t");
|
|||
stkend(&$8013 ); lo=stkelo; hi=stkehi;
|
||||
setdst("stke"); cklohi(&$8013);
|
||||
|
||||
puts("Swapping with Unsufficient Space\t");
|
||||
puts("Swapping w/ Unsufficient Space\t");
|
||||
puts("stkswp()\t");
|
||||
f=stkswp(); printf(f,"bytes=%d:");
|
||||
g=(f==0) ? #TRUE : #FALSE;
|
||||
|
|
Loading…
Reference in New Issue