Popular Computing--MICRO-MANIA (Hobby Electronics mag., Apr. 1982)

Home




by Jonathan Scott

What's really lurking beneath the keyboard of a PET, TRS-80 or ZX81? What can you do with it?


ALL HOME COMPUTERS are based on the microprocessor integrated circuit. In fact this is physically a rather small part of that thing which comes in the box marked 'home computer'. It is a plain integrated circuit with 40 to 64 pins, and looks just like a lot of other ordinary integrated circuits. You could buy a common one for much less than £10, or for a classy one you might pay £100 or so. (1982 prices in UK; for USD, multiply by 1.5)

Most of the cost of the complete unit is the 'support' equipment--the PCB, memory, keyboards and so on. But more of that later.

How should we briefly characterize this device, upon which books have been written in abundance? Well, for anyone who has a good knowledge of computers two single descriptions are enough, so we'll start there and work back. These are called the 'chip architecture', and the 'instruction set'. Let us draw an analogy to make it clear. We will discuss a microprocessor, and consider a man sitting at a desk as the model.

The architecture of a microprocessor (or CPU, for Central Processing Unit) is usually presented in the form of a small map showing the locations of significant 'places' in the chip. It corresponds to the places in or on the desk where something may reside. In the CPU there will be several spots where a number can be held, just like the memory on a pocket calculator. Our man at the desk has, for example, the top of the desk, which we will suppose can hold only one number of the size the computer deals with at a time. There might be several drawers which can also hold one number apiece.

If you want to hang on to a bigger number than will fit in one drawer, you must break it up and put it in several drawers.

One popular CPU is the 6502; it has six locations. Some of these have fixed jobs. To keep a record of where the CPU is up to in its program --this corresponds to two drawers in the desk which hold the page number in a book the man is reading. The book is telling him what to do --it corresponds to the program.

Another location is called the 'accumulator' and is the place where the result of a calculation usually goes --this is like the top of the desk. In your pocket calculator it is what you see in the display --the result. A third location is known as 'stack pointer' and also holds a specific piece of information --the place where there is some free memory for holding any numbers you need to keep for a while. It is like a drawer in the desk in which a piece of paper is kept; written on the paper is where to find some blank pages in a pad kept elsewhere lie outside the CPU).

Temporarily Registered

The other two registers in the 6502 are general purpose registers, typically used for temporary jobs, counting or indexing.

The latter need not concern us yet but gives its name to these locations, called 'index registers'. These are like two spare but handy drawers in the desk. If all this has left you confused, there we'll recap using figures. We have chosen the 6502 as it is relatively simple (not a complex architecture) and yet has most of the fundamental bits we need to discuss.

It is used in Apple, PET and Acorn computers, among others.

The common CPUs on the market to day, like the 6502, 8080 and Z80, are 'eight bit' units. This means that each number is eight bits wide, or is an eight digit binary number. Such numbers span a decimal range of 0-255, of course. Bigger numbers, or fractional ones, must be kept in several locations at once; this need not be a worry yet, as it falls naturally into place later.

So now we know that CPUs have places in them like pocket calculator memories. What can they do with the numbers in these locations? The 'instruction set' is a list of all the possible commands. In a pocket calculator there are a fixed number of keys which either input a number, execute a function such as 'x', or get a result I = ). Our man at the desk can do a variety of things, such as "put the number on the next page of the book of instructions into the X-index register", or "go to such-and-such a place if the accumulator is zero". In the 6502 there are about 150 different things which it can do in any one 'move' or instruction. A program understandable by the CPU is composed entirely of these.

The next most fundamental bit in the box is memory. This comes in two kinds --memory that you can put numbers in to yourself, rubbing out and replacing the numbers as you will, and memory which contains fixed numbers, which can neither be changed by you nor rubbed out, even by turning off the power. The former is called RAM, (short for Random Access Memory); the latter is ROM, for Read Only Memory. In the computers you buy in the shops, a lot of useful pro grams which you need frequently are perpetually available within the computer memory because they are in ROM. The size of the ROM (typically 4-16K for BASIC) reflects how comprehensive and convenient are the programs that you buy with the unit. For instance, '4K-BASIC' is relatively small, and consequently a coarse and limited version of BASIC. 8K would be more reasonable.

Expensive commercial units might offer 16K or more of language interpreter --quite big, and sporting many clever and useful work-saving pieces of program.

The types of 'program' and their merits and uses will be covered in the 'Languages Within Languages' section.

RAM is where the computer holds numbers and where the programs you type in are kept. Thus, the more of it you have, the bigger a program you can put in (in any given language) and/or the more numbers you can store at any time.

Machines with only 1-4K of RAM must be regarded as small, and will be adequate only if you are programming simple jobs in a very compact form. 16K is typical, and does most 'household' jobs.

Machines with 64K or more are now available, but only a tough business job or a large commercial game will demand this.


Peripheral Matters

As well as the CPU and memory, a complete computer will need some way of getting things from you --a keyboard; a way of getting things to you --a screen or printer; and a way of recording your program permanently so you can turn the machine off and not waste all your work --mass storage, usually a disk drive or audio tape facility. The keyboard can be like an electric typewriter, which is nice but adds to the cost, or it can be one of various sorts of economy measures ranging from one with only a few keys to one with those 'solid state' touch sensitive keys, with no moving parts. All will do the job, though if you are at all serious you will find that a full typewriter-style keyboard is the only one which does not eventually get on your nerves.

The cheapest output, and the one used by many manufacturers, is a signal which will put words and numbers on the screen of a home TV set. This is neat and clear. Some computers just put out RF which you tune into with an unused slot in your TV tuner. This is quick, though not so good as the ones that put out video signals which can be fed directly to the video amplifier stages, bypassing the tuner. Video monitors, as they are called, give a clearer picture, although they must be specially purchased --a measure to consider if you are serious.

Some units (eg, PET) include a video monitor, so you get one with the purchase price.

Finally, the mass storage. This just means a way of permanently recording your programs in a fashion which allows you to load them back into the computer whenever you want. Most computers allow programs to be put onto an ordinary cassette recorder. This is adequate at first, and it's cheap; but it is also slow, and you have to keep track of where on the tapes you have put various programs. Also, there is the occasional failure and you lose a recording --very painful. Once you are addicted and com mitted, a disc drive is really necessary. It is fast, reliable and keeps its own catalogue of what you have stored away. By the 40th program, this looks like a godsend!

-------------------


PROGRAM COUNTER

DOUBLE LENGTH NUMBER WHICH ACTS LIKE A BOOKMARK. KEEPING YOUR PLACE IN A PROGRAM ACCUMULATOR

THE MOST USED GENERAL LOCATION HOLDS A NUMBER WHICH MAY BE INSPECTED, MODIFIED OR MOVED ELSE WHERE AS COMMANDED BY THE PROGRAM STACKPOINTER

HOLDS A NUMBER WHICH SHO WS WHERE WE CAN 'STACK' UP NUMBERS WE NEED TO HOLD ON TO ELSE WHERE IN THE MACHINE FROM THE CPU X REGISTER Y REGISTER TWO INDEX REGISTERS. CALLED "X' AND '`'"

HANDY GENERAL PURPOSE REGISTERS WHICH WE CAN USE FOR ANYTHING WE WANT --USUALLY COUNTING OR POINTING TO THINGS TOO BIG TO HOLD IN THE uP

Elements of the 6502 CPU.

--------------------

Languages Within Languages

We have now discussed all the factors which reflect the comprehensiveness and the cost of home computers, and we have abstractly discussed CPU architecture and said that they have a fixed range of instructions which they can execute.

Now we will discuss what various 'levels of instructions' are available. These can all be called languages.

The set of instructions which are native to a particular processor --say the 6502 --are said to comprise its 'machine language'. These are fixed and unchangeable with any given CPU. The most fundamental program to a processor is called its 'monitor', and this is a program written in and designed to deal with machine language. Consider what happens when power is first applied to a computer. It must have some starting place, some logical first move. In the Z80, the machine sets the program counter to 0 --which is to say that our man at the desk opens his book of instructions at the first page and puts the book mark there. In the 6502 the 'reset location', as this place is called, is near the very end of the range, rather like the index of the book. When power is first turned on, or when you push the 'reset' button because some catastrophe has scrambled up what you were doing, the bookmark gets back to this place --always the same place for a given brand of CPU.

Living around this place is usually the 'monitor' program. In computer jargon we say that "the monitor takes control", by which we mean that the processor is doing what the monitor program is telling it to do. What does the monitor do? Well, first it prepares the computer for use by getting the keyboard and screen ready for action and generally checking that all is well. Our man at the desk might suddenly wake up, and he will first put his bookmark in the appropriate place, as he does each time he comes to the desk.

That page tells him to adjust his chair, close all the filing cabinet drawers, turn on a light if it is dark, and so on. This will all be listed in the book --his 'program'. Once this has been done, the man will probably sit waiting for some work to come his way. The computer will, when it has finished setting up the job, wait for you to give it something to do by hitting a key or set of keys. The monitor has a few commands which allow you to effectively look at any memory locations you may wish to inspect and to change them, to enter a number representing one of the 0 instructions in the instruction set of the CPU. It allows you to execute a group of these instructions and also to look, at any time, at the registers in the processor. It may also give you some commands helpful in finding errors in such a program --an act called 'debugging'. (mistakes in a program, of any type, are called 'bugs'.) Whatever commands a monitor understands will be outlined in some paperwork accompanying the unit, and need only be read up when you want to use the monitor. It is sufficient, at this time, to say that the monitor is a crude mechanism which is very close to the actual machine language of the processor.

You need a knowledge of the architecture and the instruction set to use it, and even then it is a slow and tedious process to write and enter programs in machine code.

However, suppose we had a dictionary --a dictionary which would allow us to look up nice familiar English words like 'multiply', and get the machine code instructions to do this.

And suppose this dictionary lived in the machine already, so that you could type in a phrase like "if E/C = MC then beep" and know that if E/C does equal MC the machine will beep. Such a dictionary is often built in, and it is called a 'BASIC interpreter', or just 'BASIC'. Interpreters come in other languages, too, though BASIC is more common today. Some machines have monitors that know if BASIC is in the machine and when they have finished getting the machine in order they hand control over to the BASIC program at once. Others require you to hit some specific key --mentioned in the sheet of instructions that go with the monitor --to cause BASIC to be executed.

BASIC English

With BASIC in control, you can type in a lot of these words, recognized by BASIC, and then have them executed --or 'interpreted', as the jargon goes.

There are words to make calculations, words to make decisions, words to collect bits of information from the user via the keyboard, and words to make things happen on the screen. These new words may be regarded as a new 'instruction set', just like the one we mentioned before, except that they are more English-like, and they are also substantially similar from one machine to another. These are the two major advantages --BASIC is easier to think out, and does not demand a knowledge of the CPU inside the machine. The price is speed --BASIC is very slow compared to machine language --but the reward is speed of writing and the ability to put the program into your neighbor's machine (although it has perhaps a different CPU in it), because the words of BASIC are standardized. The 'dictionary' inside the machine does the translation for you.

There are better languages than BASIC, each with advantages, which will come soon to home computers.

Pascal is even more 'English-like' in its appearance, for instance, and FORTH is much faster to execute --you can take your pick on some machines.

This "language within a language" is just one more level of flexibility. In fact there is, within the IC itself where you cannot see or change it, another language called 'microcode' and a dictionary to translate this into the particular machine languages of your CPU. The microcode carries out the range of machine language instructions using an even cruder set of instructions which are actually hardware implemented (with, yes, transistors!). One more point about the languages.

We have called them 'interpreters'. An interpreter will take a lot of words in BASIC, say, which are your program, and execute them (in machine code) as it goes. This is slow because it does the 'dictionary-looking-up' as it goes. There is another type of 'dictionary program' which spends some time translating all the words before it even commences the actual running of the program. This pro cess is called 'compilation', and such programs are called 'compilers'. The ad vantage is that the actual program runs faster than before, but the penalty is that you have to spend some time compiling beforehand, and if you make a change in the original ('source', in the jargon) you have to re-compile the whole thing. In general, the enthusiast's home machine is not geared up for this, and you are better off with an interpreter and a little machine level programming if need be.

What Can You Do With It?

This is of course the 200-plus question. As you take it out of the box, there are really only two valuable uses for a home computer in its basic form: teaching yourself about computers and playing games. Now the skill of writing computer programs has two good points; first it will help you get into the computer industry or make it easier for you to talk to people in it already, and second it is an excellent mental exercise like chess or Mastermind. If these are not of interest to you, perhaps it is time to think again. Playing games is really self explanatory --if you pour lots of 10p pieces into video games, then you have an idea what this function is worth to you.

But there must be other areas where the home computer can be useful in the home. There are other uses, but they fall into two categories --ones that only pay off when you do things on a grander scale than you can at home, and jobs which require some specific 'peripheral' connected to your machine (which costs extra, of course). Now the keeping of mailing lists or stock inventories is one well-known task. Quite honestly, these require expensive printers and only begin to be labor-saving with more than 50 people and two mass-mailings a year.

You, the private householder, are very unlikely even to save effort, let alone cost.

The keeping of cross-reference recipes is another potential job, but you have to be a fantastic cook, not to mention a religious bookkeeper and typist to get all the data into the machine and benefit from its being there. The closest you will ever get to that as a useful pastime is if someone markets a disk with them all on it, for about £10.

Next come the programs which re quire some additional peripheral, such as modems, joysticks, plotters, heat sensors, position sensors, movement sensors, switched mains sockets, or a custom peripheral, such as a Morse code translator ... In future issues, we'll be developing a whole range of simple, but interesting, gadgets you can hang off the end of your computer. We will conclude this article with a few ideas that will give you a hint of what you can get up to with your home computer.


The Morse Maniac

One of the most ingenious purposes to which a computer has been put is the operation of a morse radio station in an amateur DX contest. In these contests, you score points for simply exchanging call signs, often going through a simple ritual of introduction. All the communication is by morse, and what is said is simple, fixed, and repetitive. Once the contact has been made you need only record time, call-sign, etc, and maybe post off an acknowledgement later.

This can be done easily with a computer--it searches regularly through the bands, finds a station, sends the appropriate message (in morse), receives and decodes the morse response, records it all on a printer or a disk, and says goodbye. This it does as fast as possible, night and day, taking not the slightest break. When the contest is over it can print out all the acknowledgements. All that is required is a small box capable of keying the transmitter (allowing the computer to send), and capable of telling the computer when carrier and modulation is being received --a minor electronic feat. This job is specifically for the ardent ham, of course, but then most computer jobs are specific to some pastime.

The Clever Watchdog

Burglar alarms, particularly the quickly installed area types such as radar units, are prone to false alarms because the unit cannot tell the difference between the odd disturbance of a rattling window, or power surge on the supply, from a man walking across a room. However, a computer can analyze the doppler response and eliminate freak or definitely non-human responses. If you hook an analogue-to-digital converter between the radar and the computer (only a few E's worth of bits and pieces), the latter will perform quite sophisticated event filtering, giving alarm only when intrusion is fairly definite. It even simplifies the electronics in the radar module, very considerably reducing its cost! This function ties up your machine, of course, but only when you are out, so it might pay off if you live in a risky area. In addition it can turn lights and appliances off and on, making the house look inhabited --with the right peripherals, needless to say. If you devise an excellent program to do this, you might even end up selling it to one of the computer houses who buy such things and make them available to others, or to a magazine like this one.

The Formula One Computer

The author of this article has interfaced a common home computer to a slot car track. This required the computer to have control of the current into the car and a set of position reporting sensors dotted around the track. It makes for very interesting programming, working out how to enable the computer to adjust its driving habits to adapt to a car or layout and achieve close to the best possible performance. In the same vein, a computer can make a very realistic and varied model railway organizer, giving interesting hands-off movement and shunting, though this requires quite a lot of interfacing hardware.

The Computer Mail Order

At least one chain of electronic component and hi-fi stores in far-off Australia sell a small peripheral for their line of home computers which allows your computer to do your mail ordering direct to their computer. You prepare your order; a program that comes with the peripheral does this on your screen. Next you phone up the store's computer.

Then you hand the phone over to your computer, tell it to go, and in a couple of hours their computer has dispatched the goods and charged your account or credit card. Very neat indeed, and there are no middlemen to lose or confuse your order. This is going to become more common, thought not quickly.

The Word-processing Wizard

Word-processing may once have been the domain of commercial computers, but it has now really taken off at the domestic level. All you need is a printer with a pleasant typeface. Programs are becoming available which will correct your spelling of up to 10,000 common words, and then set out anything from a party invitation to a business letter.

While you might not be able to justify the expense of a home computer, or the printer, just for this purpose, it is worth having the program if you already have the equipment. There is some value to be gained from a precise and correct job application, for example. In addition, if you are in it for the programming experience, it may be worthwhile writing your own program for the job, or a copy of one you have seen used but want to improve.


Conclusion

Well, there are some ideas to start your imagination rolling. If you have a little constructional experience, so much the better, as you may be able to fashion your own interfaces so you can more cheaply hook up the computer to your train or your home appliances. Here at HE it is our intention to publish programs and constructional articles to assist those with home computers. If you are thinking about it, we hope this article has given you some idea of what's possible, and how involved you must get to reap the benefits. For those such as your children, who are growing up in a very computer-involved world, the experience will be invaluable, and for you it may become a very productive hobby, especially if you get involved in the hard ware side as well as programming.

-----------------

-----------------


(adapted from: Hobby Electronics magazine, Apr. 1982)

Also see:

Inside Color TV

DIY Project--Digital Capacitance Meter

 


Top of Page

PREV. |   | NEXT |   More HE articles | HOME