LEX 'ATBINLX4' ID #5E MSG 0 POLL 0 ENTRY ATBIN$ CHAR #F ENTRY BTA$ CHAR #F KEY 'ATBIN$' TOKEN #B9 KEY 'BTA$' TOKEN #BA ENDTXT * 5E B9 F m0615B ATBIN$ * 5E BA F m0621B BTA$ **************************************** * ATBINLX4 corrects a bug that flawed the BTA$ keyword in * BINLEX6 and MMLEXV04. The flaw was two-fold: first, BTA$ * did not check available memory, which could result in * Memory Lost if you did not have memory to spare. Second, * BTA$ made inefficient use of the stack, which aggravated * the first problem.. * * Both problems were solved when I realized that BTA$ converts * one to eight bytes into a single byte. Since the resulting * string is alway smaller than the input string, both goals * could be achieved by storing the resulting string right back * into the space on the stack that was used by the input string. * * COPYRIGHT 1989 BY MICHAEL MARKOV - NOT FOR COMMERCIAL USE ******************************************************** NIBHEX 411 * ATBIN$ entry point ATBIN$ GOSBVL #0BD38 =POP1S CD0EX RSTK=C CD1EX D1=C D0=C GOSBVL #1A460 =D=AVMS D1=D1- 16 CD1EX C=C-A A C=C-A A C=C-A A C=C-A A C=C-A A C=C-A A C=C-A A ?D>C A GOYES m061E5 to GOVLNG #0944D =MEMERR D1=C RSTK=C C=A A C=C+C A C=C+C A C=C+C A CSL W CSL W LCHEX F DAT1=C W D1=D1+ 16 C=0 W C=A A CSRB D=C A m061B7 D=D-1 A GOC m061EC A=DAT0 B GOSUB m061FD GOSUB m061FD GOSUB m061FD GOSUB m061FD GOSUB m061FD GOSUB m061FD GOSUB m061FD GOSUB m061FD D0=D0+ 2 GONC m061B7 m061E5 GOVLNG #0944D =MEMERR m061EC C=RSTK D1=C C=RSTK D0=C GOVLNG #0F23C =EXPR m061FD LCHEX 30 '0' eInvalid TAB =pRUNft =t0 SB=0 ASRB ?SB=0 GOYES m0620F LCHEX 1 m0620F DAT1=C 2 D1=D1+ 2 RTN ******************************************************** * The above code for ATBIN$ is the same as that in both BINLEX6 * and MMLEXV04. It is included for completeness ********************************************************* NIBHEX 411 BTA$ A=0 W BTA$ entry point. Preclear string length register. GOSBVL #0BD31 =REVPOP reverse string, we right-justify the bits * ?A#0 A Not null$? this would allow faster execution if * GOYES NotNul input string is null, but this would surely be * D1=D1- 16 a mistake! * GOTO expr nothing to do if null$ * NotNul GOSBVL #1A460 =D=AVMEMS CD1EX C=C+A A top char of string R1=C save it for ADHEAD D1=C output pointer CD0EX save PC and set-up D0 as the input pointer R0=C ASRB convert string length to byte count Nbyte- P= 7 8 bits/byte, less 1 (exit on carry) Nbyte A=A-1 A if 0 input bytes left, then exit GOC BTA$ex D0=D0- 2 advance pointer to next input byte C=DAT0 XS get input byte least significant bit into XS CSRB to most significant bit of C[B] P=P-1 decrement counter GONC Nbyte not yet 8 bits, go get next bit D1=D1- 2 advance pointer to output byte DAT1=C B output it GONC Nbyte- B.E.T. BTA$ex ?P= 7 did we store the data? GOYES FULL C=0 M clear potential trash out of last output byte C=0 XS shift CSRB shift bits P=P-1 GONC shift until the bits are all in the right place D1=D1- 2 advance the output pointer DAT1=C B send the partial byte out FULL ST=1 0 we want to return from ADHEAD P= 0 C=R0 restore D0 D0=C GOSBVL #181B7 =ADHEAD GOSBVL #1B38E =REV$ expr GOVLNG #0F23C =EXPR done! END