/*********************************************** * TESTSTK - Test Stack Manipulation Functions * ***********************************************/ #include #include #include #include #include #include #include char TRUE=$FF, FALSE=$00; char f,g,i; char aa,xx,yy; char lo,hi; char r={6,7,8,9}; char s="Test String"; char t[255]; main: for (i=0;i<$20;i++) srclo[i]=0; //Initialize Pointers puts("Setting Stack Start to $7FFF\t"); stkbgn(&$7FFF); lo=stkslo; hi=stkshi; setdst("stks"); cklohi(&$7FFF); puts("Setting Stack End to $807E\t"); stkend(&$807E); lo=stkelo; hi=stkehi; setdst("stke"); cklohi(&$807E); puts("Setting Stack Pointer to $8765\t"); stkset(&$8765); lo=stklo; hi=stkhi; setdst("stk"); cklohi(0,&$8765); puts("Resetting Stack Pointer\t\t"); stkrst(); lo=stklo; hi=stkhi; setdst("stk"); cklohi(0,&$7FFF); puts("Getting Stack Pointer Address\t"); aa, hi, lo = stkptr(); setdst(""); cklohi(0,&$7FFF); puts("Setting Source to Stack Pointer\t"); stksrc(); lo=srclo; hi=srchi; setdst("src"); cklohi(0,&$7FFF); puts("Setting Dest. to Stack Pointer\t"); stkdst(); lo=dstlo; hi=dsthi; setdst("src"); cklohi(0,&$7FFF); puts("Incrementing Stack Pointer\t"); stkinc(); lo=stklo; hi=stkhi; setdst("stk"); cklohi(0,&$8000); puts("Decrementing Stack Pointer\t"); stkdec(); lo=stklo; hi=stkhi; setdst("stk"); cklohi(0,&$7FFF); puts("Pushing Array onto Stack\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; psorfl(f & g); chkptr(&$8004); puts("Duplicating Top of Stack\t"); aa,hi,lo=stkptr(); //Save Stack Pointer f=stkdup(); printf(f,"bytes=%d:"); setdst(*,hi,lo); g=(memcmp(@r, &r)==0) ? TRUE : FALSE; psorfl(f & g); chkptr(&$8009); puts("Pushing String onto Stack\t"); aa,hi,lo=stkptr(); //Save Stack Pointer f=stkstr(&s); printf(f,"bytes=%d:"); setdst(*,hi,lo); g=(strcmp(&s)==0) ? TRUE : FALSE; psorfl(f & g); chkptr(&$8016); puts("Copying String from Stack\t"); f=stktop(&t); setdst(&t); printf("\"%s\":"); g=(strcmp(&s)==0) ? TRUE : FALSE; psorfl(f & g); chkptr(&$8016); puts("Popping String off Stack\t"); f=stkpop(&t); setdst(&t); printf("\"%s\":"); g=(strcmp(&s)==0) ? TRUE : FALSE; psorfl(f & g); chkptr(&$8009); puts("Dropping Duplicate off Stack\t"); f=stkdrp(); printf(f,"bytes=%d:"); g=(f==4) ? TRUE : FALSE; psorfl(f & g); chkptr(&$8004); puts("Popping Array off Stack\t\t"); f=stkpop(&t); prtary(f); puts(": "); g=(memcmp(f,&r)==0) ? TRUE : FALSE; psorfl(f & g); chkptr(&$7FFF); puts("Popping off Empty Stack\t\t"); f=stkpop(&t); printf(f,"bytes=%d:"); if (f) fail(); else pass(); chkptr(&$7FFF); puts("Overflowing Stack\t\t"); f=stkpsh(255,&t); printf(f,"bytes=%d:"); if (f) fail(); else pass(); goto exit; void chkptr(aa,yy,xx) { puts("Checking Stack Pointer Address\t"); aa, hi, lo = stkptr(); setdst(""); cklohi(*,yy,xx); } void prtary(aa) { putc('{'); for (i=0;i