/**************************************************** * INTS - Test Integer Variables and Function Calls */ //Specify System Header using -H option #include #include #include #include #include #include #include #include char size; char s[128]; //Test String char cval,cnum,ctot; //Character Function Variables int ivar,ival; //Integer Variables int icmp,itot,ires; //Function Variables int less, more; //Test Values for imin() and imax() int yx, dd; //Function Arguments and Variables void cpival(icmp) { if (>ival <> >icmp or "); putwrd(icmp); failln(); goto exit; } } /* Test imin() and imax() */ void minmax() { newlin(); puts("LESS=$"); putwrd(less); puts(",MORE=$"); putwrd(more); newlin(); puts(" IMIN()=$"); setsrc(less); ival = imin(more); putwrd(ival); newlin(); cpival(less); puts(" IMAX()=$"); setsrc(less); ival = imax(more); putwrd(ival); newlin(); cpival(more); } /* Test cvibcd() and upbcdi() */ void intbcd(ival) { newlin(); puts("CVIBCD($"); putwrd(ival); puts(")=$"); cvibcd(ival); puthex(temp2); puthex(temp1); puthex(temp0); } /* Test itoa() and atoi() */ void itaati(ivar) { newlin(); puts("ITOA($"); putwrd(ivar); puts(")=\""); setdst(s); size = itoa(ivar); puts(s); putln("\""); puts("ATOI(\""); puts(s); puts("\")=$"); ival = atoi(s); putwrd(ival); newlin(); cpival(ivar); } /* Test iadd() and isub() */ //**needs iaddc() void addsub(ivar) { newlin(); putint(ival); putc('+'); putint(ivar); putc('='); setsrc(ival); ctot, itot = iadd(ivar); putint(itot); puts(" carry=$"); puthex(ctot); newlin(); putint(itot); putc('-'); putint(ivar); putc('='); setsrc(itot); ires = isub(ivar); putint(itot); puts(" carry=$"); puthex(ctot); newlin(); cpival(ires); } /* Test imult() and idiv() */ void mltdiv(ivar) { newlin(); putint(ival); putc('*'); putint(ivar); putc('='); setdst(ival); cval,itot = imult(ivar); putint(itot); if (cval) puts(" OVERFLOW!"); newlin(); putint(itot); putc('/'); putint(ivar); putc('='); setdst(itot); ires = idiv(ivar); putint(ires); newlin(); cpival(ires); ival>>; setsrc(ival); cval,itot = iadd(itot); if (cval) return; //Number to Large to Modulo putint(itot); putc('%'); putint(ivar); putc('='); setdst(itot); ires = imod(ivar); putint(ires); newlin(); cpival(ires); } void prshft() { puts(); putc('('); putdec(cval); puts(",%"); cnum = >ivar; putbin(cnum); putspc(); cnum = >; prshft("ISHFTR"); ctot, itot = ishftr(cval, ivar); pritot(); prctot(); newlin(); cpival(itot); } main: less = $009A; more = $00DE; minmax(); less = $789A; more = $78DE; minmax(); less = $7800; more = $BC00; minmax(); less = $789A; more = $BCDE; minmax(); less = $F18F; more = $F18F; minmax(); anykey(); itaati(&0); itaati(&234); itaati(&256); itaati(&456); itaati(&23456); itaati(&$FFFF); anykey(); ival = &23; addsub(&34); ival = &1234; addsub(&5678); ival = &23456; addsub(&34567); ival = &$7700; addsub(&$6600); ival = &$7FFF; addsub(&$8000); ival = &$FDEC; addsub(&$CDEF); anykey(); ival = &23; mltdiv(&34); ival = &123; mltdiv(&234); ival = &255; mltdiv(&257); anykey(); shftlr(0,&$AA55); shftlr(1,&$A55A); shftlr(2,&$F00F); shftlr(3,&$0FF0); shftlr(4,&$AA55); shftlr(7,&$A55A); anykey(); shftlr(8,&$AA55); shftlr(9,&$A55A); shftlr(11,&$0FF0); shftlr(12,&$AA55); shftlr(15,&$A55A); shftlr(16,&$F00F); goto exit;