From 2aac5dc4c971f24700ded37170ec96708bf45dad Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Sun, 4 Oct 2020 11:02:38 -0400 Subject: [PATCH] Reconstructed program test/testslib.c02 --- test/testslib.c02 | 132 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 test/testslib.c02 diff --git a/test/testslib.c02 b/test/testslib.c02 new file mode 100644 index 0000000..c5d8f0e --- /dev/null +++ b/test/testslib.c02 @@ -0,0 +1,132 @@ +/********************************* + * TESTSLIB - Test Module stdlib * + *********************************/ + +//Specify System Header using -H option +#include +#include + +void prtcma() {putchr(',');} +void prtlin() {putstr(); newlin();} +void prtok() {prtlin(" ok");} + +main: + +tstabs: + char onum, anum, cnum; + putstr("ABS()"); + onum = 0; +aploop: + anum = abs(onum); + if (onum <> anum) goto abserr; + onum++; + if (onum < $80) goto aploop; +anloop: + anum = abs(onum); + cnum = -onum; + if (anum <> cnum) goto abserr; + onum++; + if (onum > $00) goto anloop; + prtok(); + +tstmlt: + char mltplr, mltpnd, acmlsb, acmmsb, acmlst, prodct, ovrflw; + putstr("MULT()"); + mltplr = 1; +mrloop: + mltpnd = 1; acmlst = 0; acmlsb = 0; acmmsb = 0; +mdloop: + acmlsb = acmlsb + mltplr; + if (acmlsb < acmlst) acmmsb++; + acmlst = acmlsb; + prodct,ovrflw = mult(mltplr,mltpnd); + if (prodct <> acmlsb) goto merror; + mltpnd++; if (mltpnd > 0) goto mdloop; + mltplr++; if (mltplr > 0) goto mrloop; + prtok(); + +tstdiv: + char maxmpd, divdnd, divisr, quotnt; + putstr("DIV()"); + mltplr = 255; maxmpd = 1; +drloop: +mltpnd = 1; acmlsb = 0; +ddloop: + acmlsb = acmlsb + mltplr; + prodct = mult(mltplr, mltpnd); + quotnt = div(prodct, mltpnd); + if (quotnt <> mltplr) goto derror; + mltpnd++; if (mltpnd < maxmpd) goto ddloop; + mltplr>>; maxmpd<<; if (mltplr <> 0) goto drloop; + prtok(); + +tstrnd: + char countr, rndnum, rndtbl[255]; + putstr("RAND()"); + rands(1); countr = 0; +riloop: + rndtbl[countr] = 0; + countr++; if (countr <> 0) goto riloop; +rnloop: + rndnum = rand(); if (rndtbl[rndnum] > 0) goto rnderr; + rndtbl[rndnum] = $FF; + countr++; if (countr < 255) goto rnloop; + prtok(); + +tstcvb: + char cvbchr, cvblo, cvbhi; + putstr("CVBCD()"); + cvbchr = 0; cvblo = 0; cvbhi = 0; +cvloop: + cvbcd(cvbchr); if (temp1 <> cvblo or temp2 <> cvbhi) goto cvberr; + cvblo++; + if (cvblo & $0F > 9) { + cvblo = cvblo & $F0 + $10; + if (cvblo >= $A0) {cvblo = cvblo & $0F; cvbhi++;} + } + cvbchr++; if (cvbchr) goto cvloop; + prtok(); + +tstc2a: + char srcchr, dstchr, tststr[4]; + putstr("CTOA()"); + srcchr = 0; +caloop: + ctoa(srcchr, &tststr); + dstchr = atoc(&tststr); + if (srcchr <> dstchr) goto c2aerr; + srcchr++; if (srcchr <> 0) goto caloop; + prtok(); + + goto exit; + +abserr: + putstr("abs("); prbyte(onum); putchr(')'); putchr('='); + prbyte(anum); putchr(','); prbyte(cnum); newlin(); + goto exit; + +merror: + newlin(); + prbyte(mltplr); putchr('*'); prbyte(mltpnd); putchr('='); + prbyte(prodct); putchr(','); prbyte(acmlsb); newlin(); + goto exit; + +derror: + newlin(); + prbyte(divdnd); putchr('/'); prbyte(divisr); putchr('='); + prbyte(quotnt); putchr(','); prbyte(mltplr); newlin(); + goto exit; + +rnderr: + putstr("rand()="); prbyte(rndnum); putchr(','); prbyte(countr); newlin(); + goto exit; + +cvberr: + putstr(" !cvbcd("); prbyte(cvbchr); putstr(")=$"); + prbyte(temp2); prbyte(temp1); newlin(); + goto exit; + +c2aerr: + putstr(" !ctoa("); prbyte(srcchr); putstr(")="); + prbyte(dstchr); newlin(); + goto exit;