BITS

Developer(s): Michael DiRienzo
Date: 1990
Type: Program
Platform(s): TS 2068

BITS prints a reference chart of every byte value from 0 to 255: the decimal number, the hexadecimal number and the eight bits, each drawn as a filled box for a 1 or an empty box for a 0. Two columns of 21 values fill each screen; then C copies the screen to a TS2040 printer, Q quits and ENTER shows the next page. Michael J. DiRienzo wrote it for designing user-defined graphics and reading machine code.

It ran in the Mike’s Notebook column of July 1990. DiRienzo notes that he added line 115 and changed line 120 to make the patterns print 65% faster.

Program Analysis

  • Lines 300–340 POKE UDG A (a filled box) and UDG B (an empty box) from DATA.
  • Lines 40–210 loop over two screen columns and 21 rows; h$ holds the hexadecimal digits.
  • Lines 110–160 test each bit from 7 down to 0: line 115 builds the power of two by repeated doubling and lines 120–130 extract the bit with INT.
  • Lines 220–280 handle the copy, quit and continue keys.

Notable Techniques

  • UDGs stand in for bits, so the chart shows each pattern as it would look in a character.
  • The bit is found arithmetically, as x-INT (x/2)*2 of INT (n/2^b), without any machine code.

Potential Issues

  • The COPY option is for the TS2040; other printers need line 240 changed, as the column says.

Typed in from the Mike’s Notebook column on RMG Enterprises’ monthly RMG UPDATES disk for July 1990, where the program exists only as a listing in the column’s text. The two PRINT statements in lines 140 and 150 use UDG A and UDG B, as the column instructs. It was tokenized for tape and tested in ZEsarUX.

Related Articles

Knowing the bit patterns of a specific byte can also help to better understand machine code among the many other uses.
I like to work with computer graphics on the TS2068 and Ifrequently need to look up bit patterns for User Defined Graphics characters.

Related Content

Image Gallery

Source Code

   10 GO SUB 300
   20 POKE 23658,8: LET n=0
   30 LET h$="0123456789ABCDEF"
   40 FOR c=1 TO 2
   50 IF c=1 THEN LET c1=0: LET c2=4: LET c3=7
   60 IF c=2 THEN LET c1=17: LET c2=21: LET c3=24
   70 PRINT AT 0,c1;"Dec";TAB c2;"Hex";TAB c3+1;"Binary"
   80 FOR z=1 TO 21
   90 LET s=INT (n/16)
  100 PRINT AT z,c1;n;TAB c2;h$(1+s);h$(1+n-16*s);TAB c3;
  110 FOR b=7 TO 0 STEP -1
  115 LET l=1: FOR w=1 TO b: LET l=l*2: NEXT w
  120 LET x=INT (n/l)
  130 LET t=x-INT (x/2)*2
  140 IF t=1 THEN PRINT "a";
  150 IF t=0 THEN PRINT "b";
  160 NEXT b
  170 PRINT 
  180 LET n=n+1
  190 IF n=256 THEN GO TO 220
  200 NEXT z
  210 NEXT c
  220 PRINT #1;AT 1,0;"(C)opy,(Q)uit,ENTER to Continue"
  230 LET q=CODE INKEY$
  240 IF q=67 THEN COPY : LPRINT : IF n<256 THEN CLS : GO TO 40
  250 IF q=81 THEN STOP 
  260 IF q=13 AND n=256 THEN STOP 
  270 IF q=13 THEN CLS : GO TO 40
  280 GO TO 230
  300 FOR n=USR "A" TO USR "A"+15
  310 READ a: POKE n,a
  320 NEXT n
  330 RETURN 
  340 DATA 0,0,126,126,126,126,126,0,0,0,126,66,66,66,126,0

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.