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
|
|
|
|
|
2020-10-23 22:15:36 +00:00
|
|
|
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
|
2020-10-23 22:15:36 +00:00
|
|
|
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
|
|
|
|
|
2020-10-23 22:15:36 +00:00
|
|
|
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(", ");
|
2020-10-23 22:15:36 +00:00
|
|
|
printf(setdst(xmbank,xmaddr),"PA=$%l, ");
|
|
|
|
printf(setdst(xgetad()),"LA=$%l ");
|
2019-11-19 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void perror() {
|
|
|
|
printf(); //Implied Arguments
|
2020-10-23 22:15:36 +00:00
|
|
|
paddrs(#FALSE);
|
2019-11-19 18:52:21 +00:00
|
|
|
newlin();
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2020-10-23 22:15:36 +00:00
|
|
|
/* Test xgetad() and xsetad() */
|
2019-11-19 18:52:21 +00:00
|
|
|
void tstgsl(ibank,ipage,ibank) {
|
|
|
|
while (ibank<=#XLBANK) {
|
|
|
|
putc('.');
|
|
|
|
while() {
|
|
|
|
while() {
|
2020-10-23 22:15:36 +00:00
|
|
|
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;
|
2020-10-23 22:15:36 +00:00
|
|
|
xsetad(ibank,ipage,ibyte);
|
2019-11-19 18:52:21 +00:00
|
|
|
i=0; do { xputc(i); i++; } while (i);
|
2020-10-23 22:15:36 +00:00
|
|
|
xsetad(ibank,ipage,ibyte);
|
2019-11-19 18:52:21 +00:00
|
|
|
i=0; do {
|
2020-10-23 22:15:36 +00:00
|
|
|
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;
|
2020-10-23 22:15:36 +00:00
|
|
|
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)
|
2020-10-23 22:15:36 +00:00
|
|
|
perror(setdst(xmbank,xmaddr),"%nERROR IN BANK $%x ADDRESS $%w");
|
2019-11-19 18:52:21 +00:00
|
|
|
i++;
|
|
|
|
} while (i);
|
2020-10-23 22:15:36 +00:00
|
|
|
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;
|
2020-10-23 22:15:36 +00:00
|
|
|
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);
|
2020-10-23 22:15:36 +00:00
|
|
|
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)
|
2020-10-23 22:15:36 +00:00
|
|
|
perror(setdst(xmbank,xmaddr),"%nERROR IN BANK $%x ADDRESS $%w");
|
2019-11-19 18:52:21 +00:00
|
|
|
i++;
|
|
|
|
} while (i);
|
2020-10-23 22:15:36 +00:00
|
|
|
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) {
|
2020-10-23 22:15:36 +00:00
|
|
|
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('.');
|
2020-10-23 22:15:36 +00:00
|
|
|
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);
|
2020-10-23 22:15:36 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-23 22:15:36 +00:00
|
|
|
savend: //End Address of Save
|
|
|
|
|
2019-11-19 18:52:21 +00:00
|
|
|
/* Test xload() and xsave() */
|
|
|
|
void tstxls(sbank,spage,sbyte) {
|
2020-10-23 22:15:36 +00:00
|
|
|
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) {
|
2020-10-23 22:15:36 +00:00
|
|
|
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");
|
|
|
|
|
2020-10-23 22:15:36 +00:00
|
|
|
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();
|
|
|
|
|
2020-10-23 22:15:36 +00:00
|
|
|
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();
|
|
|
|
|
2020-10-23 22:15:36 +00:00
|
|
|
puts("TESTING XLOAD() AND XSAVE()......");
|
2019-11-19 18:52:21 +00:00
|
|
|
tstxls($00,$00,$00);
|
|
|
|
passed();
|
|
|
|
|
2020-10-23 22:15:36 +00:00
|
|
|
goto exit;
|