Chapter 25 - How the computer works

The illustration overleaf shows the inside of the ZX81 (but don't take it apart yourself because it can be a tricky business putting it together again).

    As you can see, everything has a three letter abbreviation (TLA).

    The pieces of plastic with lots of metal legs are the wondrous silicon chips, which have brought you not only digital watches, but also the Sinclair ZX81. Inside each piece of plastic is a piece of silicon about the size of the  cursor, joined by wires to the metal legs.

    The brains behind the operation is the processor chip, often called the CPU (Central Processor Unit). This particular one is a Z80 processor

(actually a Z80A, which goes faster).

    The processor controls the whole computer, does the arithmetic, considers what keys you've pressed, decides what to do as a result, & coordinates the television picture. However, for all its cleverness, it could not do all this on its own. Left to itself, it knows nothing about BASIC, floating point arithmetic, or televisions, & it has to get all its instructions from another chip, the ROM (Read Only Memory). The ROM is just a long list of instructions that make a complete computer program telling the processor what to do under all foreseeable circumstances. This program is written not in BASIC, but in what is called Z80 machine code, & takes the form of a long sequence of bytes. (Remember that a byte is just a number between 0 & 255.) Each byte has an address showing whereabouts in the ROM it is; the first one has address 0, the second has address 1, & so on up to 8191. That makes altogether 8192 = 8*1024 bytes, which is why this ZX81 BASIC is sometimes called an 8K BASIC. 1K is 1024, or 210.

    Although there are similar chips in many different machines, this particular sequence of instructions is unique to the ZX81 & was written specially for it by a small firm of Cambridge mathematicians.

    You can see what byte is at a given address using the function PEEK. For example, this program prints out the first 21 bytes in the ROM (& their addresses).

        10 PRINT "ADDRESS";TAB 8;"BYTE"

        20 FOR A = 0 TO 20

        30 PRINT A;TAB 8;PEEK A

        40 NEXT A

    The next chip to consider is the memory, or RAM (Random Access Memory) chip. This is where the processor stores the information that it wants to keep - your BASIC program, variables, the picture for the television, & various notes (the system variables) of what sort of state the computer is in.

    Like the ROM, the memory is arranged into bytes, each with an address: the addresses range from 16384 to 17407 (or possibly up to 32767 if you have a 16K RAM pack.) Again as with the ROM you can find the values of these bytes using PEEK, but the big difference from the ROM is that you can also change them. (The ROM, of course, is fixed & unalterable.)


       POKE 17300,57

    This makes the byte at address 17300 have the value 57. If you now type

       PRINT PEEK 17300

you get your number 57 back. (Try poking in other values, to prove that there's no cheating.)

    Note that the address has to be between 0 & 65535; & most of these will refer to bytes in ROM or nowhere at all, & so have no effect. The value must be between -255 & +255, & if it is negative it gets 256 added to it.

    The ability to poke gives you immense power over the computer if you know how to use it; however, the necessary knowledge is rather more than can be imparted in an introductory manual like this.

    The last big chip is the logic chip, or SCL (Sinclair Computer Logic) chip. Again, this was specially designed & made for the ZX81, & it connects the other chips together in rather a clever way to make them do more than they normally would.

    The modulator converts the computer's television output into a form suitable for the television, & the regulator converts the smoothed, but unregulated 9 volts of the power supply to a regulated 5 volts.



    Statements: POKE

    Functions: PEEK

Previous: Chapter 24    Next: Chapter 26