For the average computer owner, canned programs or home-brew programs in BASIC will do the jobs we had in mind when we bought the computer. At one time or another, however, all of us will have a need to know something of the inner workings of our purchase. This may be the result of a need to do things that BASIC can’t do – such as control I/O ports to an alarm system for example – or it may be a need to remove some of the sense of uncontrollable magic from the machine. While replaceing this feeling of mystery, we will gain an appreciation of at least four interlocking levels of complexity in the machine. Starting from the smallest, they are:
1. The actual hardware: wires and semi-conductor switches.
2. The machine code that controls these switches.
3. The BASIC (or other high level language) that lets you easily invoke the machine code, and…
4. The real world problems that are addressed by your programs.
THE REAL WORLD
Now let’s work backwards through those levels. The real world offers an infinite number of situations that need some sort of calculation. If you need assistance, you go to an expert, who asks you questions, then provides an answer. Some canned programs operate at this level – they ask you questions, you respond, and they provide you with the results.
HIGH LEVEL LANGUAGES
Over the last 10,000 years, we have developed symbolic tools to assist us. These include the alphabet and language, and the number system and algebra. The real world tools can be adapted to the computer. The result is a programming language. It uses (in the case of BASIC) English words to describe its functions, and algebraic notation to express the mathematical operations. [Neither the English, nor the algebraic notation conform to the original, “real world” standard. They have been modified to accomodate the remaining two levels of complexity.] At this level, numbers are represented as you would expect – “10” means ten, while some of the symbols are new – such as * for times. Generally, this is a self-sufficient level – you needn’t look any farther when using or programming the machine. Some programs can be so complex as to approach a language themselves in flexibility and power – DBII, or even VU-CALC are examples.
MACHINE CODE
The third level, machine code, is the level that actually controls the central processor. In the Timex there is an extremely complex program of 8192 steps that is responsible for the operation of the computer, as well as the interpretation of any BASIC program that might be present. These are two very different jobs, and in other computers they are performed by two different programs.
The first job is that of an operating system. This portion coordinates the various elements of hardware, allowing for display, printouts, loading, and saving of data. The second portion is the BASIC interpreter and editor. This is the “brain” that you are fighting as you try to avoid the dreaded inverse “S”. This interpreter can be replaced: for example, the egregious BASIC that comes with the Commodore can be replaced with a much more efficient version (though it’s still not as compact as Sinclair BASIC).
At this level, numbers are represented in whatever way is most convenient for the program. In its reports to the display file numbers are expressed as decimal numbers, but for its own use, there are four different methods of expression – each used when most appropriate. It is possible to write your own programs in machine code. It requires extensive knowledge of these deeper levels of the computer, but also offers enormous freedom and speed. You can make the computer execute machine code by using “USR nnn”, where nnn is the starting address of the code.
HARDWARE
Numbers as Voltage
In this deepest level all information is in the form of electrical potential. A +5 volt signal might represent a “one”, while a ground level might represent a “zero”. This might seem very limiting; it is. Single lines carry information around the computer, controlling the timing and operation of its “hidden” accessories. But there isn’t any way to have an individual line for each possible number. Rather, there are two groups of lines, known as busses, that carry numbers. These busses are organized as sets of eight lines. The first bus is the data bus; it consists one set of eight. [The second bus is the address bus – we will get to it in a moment.] There are 256 different possible patterns of voltage in these eight lines, ranging from “00000000”, “00000001”, “00000010”, “00000011”,… to “11111111”. This group of eight is called a byte. To express a number larger than 255, you need a second byte. With two bytes, you have 256*256 possible numbers, or 65536. This is where the magic 64K number comes from. (each K=2*2*2*2*2*2*2*2, or 1024)
The “Real” Computer
Now that we have a way to express numbers electrically, we need to have some device that will perform operations with these numbers, such as addition. This is the job of the Central Processing Unit. Originally, this was a device the size of a refrigerator. In a micro, it’s on a chip, called a microprocessor. It is able to take a series of numbers from the memory (the machine code) and use them as instructions, controlling the actions of the rest of the computer, as well as performing simple arithmetic and logical steps.
The CPU has a very few locations to hold numbers, ready to be used. These locations are called registers. Each register, and the controlling logic that goes with it, are composed of networks of transistors. In the Z80, data is handled in one byte units. Other chips use two bytes (16 bits) or four bytes (32 bits) for data.
For each byte of machine code that must be executed, the CPU must perform a number of discrete steps. These steps are held as microcode, which is yet a deeper layer of operation. Since it is common to all Z80 CPU chips and cannot be changed, we can ignore it.
Storage
A computer must store many more numbers than could possibly be held in registers, however. To store these numbers, the computer has additional chips. These form a series of banks of eight switches. Each bank can hold one number, between 0 and 255. Each bank has a unique address. (You can look at each bank from BASIC. Try the first bank, with address zero. “PRINT PEEK 0” should give 211.) These banks are called up through the second bus, the address bus. Since our computer needs more than 256 spaces to store numbers, the address bus is two bytes wide, allowing 64K different addresses. (Not all these addresses must be used.)
Methods of Storage
ROMs
There are three ways of physically building these banks. They can be jumpers, capacitors, or transistor networks. Banks of jumpers are called ROMs. Numbers are stored as a pattern of connections – intact lines will allow the voltage to build up to +5V, while open circuits leave the line at 0V. These patterns can only be created in in a factory – as far as you are concerned, they are Read Only Memory. This is ideal for a program that always must accompany the machine, and that is why the Timex comes with its operating system in ROM. These can never be erased.
EPROMs
Capacitors can be loaded with numbers at will, by applying the correct voltage. Once loaded, they will retain their values for at least ten years, unless they’ve been erased. Memory chips with capacitors are called EPROMs (Eraseable, Programmable Read Only Memory). These chips are often used in small production devices, such as interface boards. These can only be erased with great difficulty, and then, all information on the chip will be lost.
RAMs
Both devices above are somewhat like engraving in granite. It would be nice to have something more like a blackboard that would retain the information until it was specifically erased. The answer is the RAM. This is composed of transistor networks that will stay in an “on” state until specifically turned “off”. This is the device that holds your BASIC programs and other information that can be changed at will. Unfortunately, these chips must constantly have a supply of +5V to keep the transistors happy. A very short interruption causes all the banks to return to zero.
This completes our tour of the levels of the Computer. Each level is adapted to dealing with both the level above, and the level below. In your relations with the computer, you can decide what level is most appropriate, from the most general canned program, to the most detailed hardware level. Fortunately, the computer is an amazingly forgiving device. Except for the hardware level, you can’t hurt the machine with an incorrect command. Your program may crash, but the computer will patiently wait for you to try again.
Mark Fisher