1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-28 10:51:14 +00:00
C02/test/xmemtest.c02

190 lines
5.1 KiB
Plaintext
Raw Normal View History

2019-11-19 18:52:21 +00:00
/**************************************
* TESTXMEM - Test Library xmemory.h02 *
**************************************/
//use -h option on command line
#include <screen.h02>
#include <stddef.h02>
#include <stdlib.h02>
#include <intlib.h02>
#include <stdio.h02>
#include <stdiox.h02>
#include <xmemory.h02>
char aa; //Function Arguments
int icount, isize; //Load/Save Index and Size
2019-11-19 18:52:21 +00:00
char i; //Index Variable
char chrctr; //Get/Put Character
int intger; //Get/Put Integer
char r[255],w[255],s[255]; //Read/Write/Swap Arrays
2019-11-19 18:52:21 +00:00
char ibank, ipage, ibyte; //Index Bank, Page, and Byte
char lbank, lpage, lbyte; //Logical Bank, Page, and Byte
char mbank, mpage, mbyte; //Memory Bank, Page, and Byte
char pbank, ppage, pbyte; //Physical Bank, Page, and Byte
char sbank, spage, sbyte; //Starting Bank, Page, and Byte
char ebank, epage, ebyte; //Starting Bank, Page, and Byte
char varend;
savbgn: //Start Address of Save
2019-11-19 18:52:21 +00:00
void passed() { putln("PASSED");}
void paddrs(aa) {
if (aa) newlin(); else puts(", ");
printf(setdst(xmbank,xmaddr),"PA=$%l, ");
printf(setdst(xgetad()),"LA=$%l ");
2019-11-19 18:52:21 +00:00
}
void perror() {
printf(); //Implied Arguments
paddrs(#FALSE);
2019-11-19 18:52:21 +00:00
newlin();
goto exit;
}
/* Test xgetad() and xsetad() */
2019-11-19 18:52:21 +00:00
void tstgsl(ibank,ipage,ibank) {
while (ibank<=#XLBANK) {
putc('.');
while() {
while() {
xsetad(ibank,ipage,ibyte); lbank,lpage,lbyte = xgetad();
if (lbank<>ibank or lpage<>ipage or ibyte<>lbyte) {
printf(setdst(ibank,ipage,ibyte),"%nERROR: XSETAD($%x,$%w); ");
printf(setdst(lbank,lpage,lbyte),"XGETAD($%x,$%w);%n");
goto exit;
}
2019-11-19 18:52:21 +00:00
ibyte=ibyte+$10; if (!ibyte) break;
} ipage++; if (!ipage) break;
} ibank++; if (!ibank) break;
}
}
/* Test xgetc() and xputc() */
void tstgpc(sbank,spage,sbyte) {
while() {
putc('.');
ibank=sbank; ipage=spage; ibyte=sbyte;
xsetad(ibank,ipage,ibyte);
2019-11-19 18:52:21 +00:00
i=0; do { xputc(i); i++; } while (i);
xsetad(ibank,ipage,ibyte);
2019-11-19 18:52:21 +00:00
i=0; do {
if (xgetc()<>i)
perror(setdst(xmbank,xmaddr),"%nERROR IN BANK $%x ADDRESS $%w");
2019-11-19 18:52:21 +00:00
i++;
} while (i);
sbank++;spage++;sbyte++;
if (!sbank or sbank>#XLBANK) break;
}
}
/* Test xgeti() and xputi() */
void tstgpi(sbank,spage,sbyte) {
while() {
putc('.');
ibank=sbank; ipage=spage; ibyte=sbyte;
xsetad(ibank,ipage,ibyte); //Write 256 Integers
i=0; do {mpage=i;mbyte=i^$FF; xputi(.,mpage,mbyte); i++;} while (i);
xsetad(ibank,ipage,ibyte); //Read 256 Integers
2019-11-19 18:52:21 +00:00
i=0; do {
mpage=i;mbyte=i^$FF;
intger = xgeti();
if (<intger<>mbyte or >intger<>mpage)
perror(setdst(xmbank,xmaddr),"%nERROR IN BANK $%x ADDRESS $%w");
2019-11-19 18:52:21 +00:00
i++;
} while (i);
sbank++;spage++;sbyte++; if (!sbank or sbank>#XLBANK) break;
2019-11-19 18:52:21 +00:00
}
}
/* Test xgetl() and xputl() */
void tstgpl(sbank,spage,sbyte) {
while() {
putc('.');
ibank=sbank; ipage=spage; ibyte=sbyte;
xsetad(ibank,ipage,ibyte); //Write 256 Longs
2019-11-19 18:52:21 +00:00
i=0; do {
mbyte=i; mpage=i^$FF; mbank = -i;
xputi(mbank,mpage,mbyte);
i++;
} while (i);
xsetad(ibank,ipage,ibyte); //Read 256 Longs
2019-11-19 18:52:21 +00:00
i=0; do {
mbyte=i; mpage=i^$FF; mbank = -i;
intger = xgeti();
if (<intger<>mbyte or >intger<>mpage)
perror(setdst(xmbank,xmaddr),"%nERROR IN BANK $%x ADDRESS $%w");
2019-11-19 18:52:21 +00:00
i++;
} while (i);
sbank++;spage++;sbyte++; if (!sbank or sbank>#XLBANK) break;
2019-11-19 18:52:21 +00:00
}
}
/* Test xread() and xwrite() */
void tstxrw(sbank,spage,epage) {
i=0; do {w[i]=i;s[i]=i^$FF;i++;} while (i); //Fill Write/Swap Arrays
2019-11-19 18:52:21 +00:00
ibank=sbank;
while (ibank<=#XLBANK) {
putc('.');
ipage=spage; xsetad(ibank,0,ipage); //Write 256,1-255 bytes of Array
do {xwrite(ipage,&w); ipage++; } while (ipage<>epage);
ipage=spage; xsetad(ibank,0,ipage);
2019-11-19 18:52:21 +00:00
do {
xread(ipage,&r);
i=0; do {if (r[i]<>w[i]) perror(i,"ERROR IN INDEX %d");i++;} while(i<>ipage);
2019-11-19 18:52:21 +00:00
ipage++;
} while (ipage<>epage);
ibank++; if (!ibank) break;
}
}
savend: //End Address of Save
2019-11-19 18:52:21 +00:00
/* Test xload() and xsave() */
void tstxls(sbank,spage,sbyte) {
savrxy(&savbgn); isize = subtxy(&savend); //Load/Save Length
xsetad(sbank,spage,sbyte); setsrc(&savbgn); xsave(isize);
xsetad(sbank,spage,sbyte); setdst(&varend); xload(isize);
srcptr = &savbgn; dstptr = &varend; icount = isize;
2019-11-19 18:52:21 +00:00
while (<icount or >icount) {
if (*srcptr <> *dstptr)
perror("ERROR IN XLOAD() AND/OR XSAVE()\n");
if (!<icount&63) putc('.');
2019-11-19 18:52:21 +00:00
srcptr++; dstptr++; icount--;
}
}
main:
if (!#XLBANK) perror("Extended Memory Not Supported");
puts("TESTING XGETAD() AND XSETAD()");
2019-11-19 18:52:21 +00:00
tstgsl($00,$00,$00);
passed();
puts("TESTING XPUTC() AND XGETC()..");
tstgpc($00,$00,$00);
passed();
puts("TESTING XPUTI() AND XGETI()..");
tstgpi($00,$00,$00);
passed();
puts("TESTING XPUTL() AND XGETL()..");
tstgpi($00,$00,$00);
passed();
2019-11-19 18:52:21 +00:00
puts("TESTING XREAD() AND XWRITE().");
tstxrw($00,$00,$7F);
passed();
puts("TESTING XLOAD() AND XSAVE()......");
2019-11-19 18:52:21 +00:00
tstxls($00,$00,$00);
passed();
goto exit;