
Many students of computer math become confused when it comes to concepts involving computer math. A computer can be thought of as a hotel with a certain number of floors and a certain number of rooms per floor. If the computer uses an 8 bit microprocessor, such as the Timex machines (Zilog Z-80 chip) do, there would be 64 floors with 1024 rooms per floor.
Now, if you have a 16K TS-1000, the floors from 1 to 16 are occupied by the machinery that make the computer work, such as the BASIC language and routines that control the CRT (or TV), the recorder input & output, the keyboard. etc.
These floors of rooms or memory areas are called ROM which stands for Read Only Memory. What is in these rooms are numbers between 0 and 255. They cannot be altered by entry from the keyboard or recorder.
The floors between 17 and 32 are the RAM or Random Access Memory rooms and also can hold numbers between 0 and 255. The difference is that the user can control which numbers go into these rooms.
Since this is a 16K machine, the floors between 33 and 64 are locked out and unattainable to the user. It is like they are there but there are no rooms to put the numbers in since they haven’t been built yet.
To help visualize how the computer stores these numbers in memory, picture in each of the rooms, a device that has 8 light bulbs on it. These bulbs represent the 8 bits in a byte. Each bulb can be in one of two states – either it is lit or it is not lit. If all the bulbs were lit, the number being held in that room would be 255. If none of them were lit, it would be 0. The following numeric values would be assigned to the bulbs from left to right:
BULB # LIT - NOT LIT 1 128 0 2 64 0 3 32 0 4 16 0 5 8 0 6 4 0 7 2 0 8 1 0
You will notice that the numbers when the bulbs are lit, represent powers of the number 2 but what you might not have known is that ANY NUMBER FROM 0 TO 255 CAN BE REPRESENTED BY THE SUM OF A COMBINATION OF THESE NUMBERS!
Computers use numbers from 0 to 255 to represent letters (both upper & lower case on some) numbers, logical operators, etc. On the TS-1000, the letter “A” is represented by the number 38. On the 2068 it is 65. The 2068 uses ASCII code which is the accepted code set for almost all computers. The command “PRINT CHR$ (65)” will result with “A” on almost all computers.
If a certain memory location of the TS-1000 held the information for the letter “A” and we PEEKed that location, we would find the number 38. The computer, however, looks at the eight bits in that location and sees the eight digit number 00100110. If we pictured this as the series of 8 light bulbs, and we were reading from right to left with the right-most bulb being #0 and the left-most bulb being #7, bulbs number 1,2 and 5 would be lit and the rest would be off.
If we were to add (2 ** 1) plus (2 ** 2) plus (2 ** 5) we would get (2 + 4 + 32) or 38.
The following program puts this all into perspective. It starts off asking you for a number from 0 to 255 and then converts in into binary. Before you enter the number, you will see numbers in the grid representing the powers of 2 from 0 to 7. After the program calculates the binary equivalent, it will display it and blot out the power numbers not used. If the numbers left are added together, the sum will equal the inputted number.
The way this program works is by scanning the inputted number 8 times and comparing it to see if it is larger or equal to one of the powers of 2 starting with the largest one (128). If it is larger or equal to this power number, it subtracts the power number from the input number and puts a “1” in the appropriate binary number position. If the input number is smaller than the power number, it just puts a “0” in the appropriate binary number position.
This program will also work on the TS-2068. Remove the FAST & SLOW commands – Ed.