## Teaching Your 'Puter The 3 R's

First a question:-

*What is the largest number you can count to on your fingers?*

Hint - the answer is a lot more than 10!

Hopefully as you read this article you will understand why, but just in case I'll put the answer at the bottom.

Computers are stupid. Let's be honest about this a computer is just a lump of electronic junk which can just about do what you tell it to do. And even then you have to describe every little step on the way. Just think about making a phone call. To get your 'puter to do it you must first tell it where to find the telephone directory book, then how to look up the number, then where the telephone is, then to lift the hand set, then what sound to listen for [to make sure the phone is connected] then how to press the buttons, and so. And even then the silly computer will fail since it cannot read the telephone book!

OK I know that in practice all you do is press a button to get the computer to dial a number, but that is because someone has already trained the computer to do it. But how did they train the computer?

Well, the simple answer is to say the programmed it. But that does not really explain how the computer understands the programming. To understand that we need to look at how the 'brain' of the computer works. The brain, of course is the CPU, or Central Processing Unit.

The CPU is a simple electronic circuit comprising some very simple components eg transistors. It just seems complex because there are one heck of a lot of these components in a CPU. Now don't worry, I'm not going into these components, at least not in this column. All you need to know is that they are simple and basically have two states - on and off, more commonly represented as 0 and 1.

The advantage of only having 0 or 1 is that it is simple. The trouble is that if all you can have is on or off you do not have a computer but a light bulb. Lets face it you would have difficulty in getting a computer do anything if all you could tell it was two things. The way round this is to group the numbers, which incidentally are called bits. Early machines use 8 bits, later ones used 16 and current ones use 32. The very latest CPU's use 64.

Now with 8 bits [which is called a byte] we have a total of 256 different combinations, starting with 00 00 00 00 and going through to 11 11 11 11. This means that we can give the computer 256 different instructions. It also means that we can store any number from zero to 255. Now we can start teaching the computer.

So the CPU, and all the other chips, the motherboard etc, in fact all the hardware, all use 8 bits at a time. At least the early microcomputers did. The trouble is that while 8 bits is fine at the hardware level and gives a lot of instructions it's just not quite enough. After all, there are 26 letters, 52 if you allow both upper and lower case, add in some standard symbols and all of a sudden 256 different instructions sound quite small. And what about numbers? There are an infinite number of them. The answer to have the meaning of the value dependent on its situation. So, for example the value 01 00 00 00 could be 64, or the letter A, or an instruction to write a value somewhere depending upon the context. This can be done by having the instruction which says, for example, following value is a letter, or copy the following value to the location given by the value following that. This gives us a lot more possible instructions.

There is another small problem, how do you represent numbers above 255? Or, for that matter numbers like 12.345 or 6½?

Well larger numbers are easy just use two or more locations. Fractions and more complex and involve splitting the byte into two, one part being the number before the decimal point and the other the bit after.

So to teach a computer all you need is to know what the 255 values
between 00 00 00 00 and 11 11 11 11 mean. By the way if you haven't
noticed what we are talking about here is binary numbers. Of course
computers being computers it has to get a bit more complicated than
that. Although the computers talk binary it is actually easier to use
hexadecimal, or hex for short. Binary is base 2, ie there are two
possible values, Decimal, which we humans use, is base 10, hexadecimal
is base 16 ie it has 16 numbers 0-9 plus A, B, C, D, E and F. I'm not
going into hex in this column [e-mail me if you want me to do a column
on it] all you need to know for now is that it is just numbers.

[See the
Decimal - Binary - Hex - Character
Table for conversions.

Of course trying to remember what all those numbers mean in any particular situation is rather difficult and trying to type it all in without making a mistake is even more difficult. So someone invented Assembler, which is better, but still pretty difficult. Then someone else invented 'High Level Languages' such as Basic, Pascal, C and so on which were much easier to use. And now we have macro languages which are even easier.

Perhaps one day we will be able to tell the stupid computer to phone Aunty Ethel, the numbers in the book.