4 Representing data and instructions inside a computer
I have just indicated that a processor is made up of millions of electronic components manufactured as one very complex circuit. The majority of these components act as switches that can exist in one of only two states, either on or off. The states of certain switches tell the processor what instructions to carry out. Also when a processor is running a program it is altering the state of other switches, switching them on and off many, many times a second.
To represent more easily what is happening to the states of these switches, the ‘off state is often referred to as 0, and the ‘on’ state as 1.
Imagine eight switches in the following states:
The states of these switches can be written down concisely as the 8-digit code 10001110, where the digit on the extreme left represents the state of the leftmost switch and so on through to the digit on the extreme right representing the state of the rightmost switch.
If, for example, the state of these switches at any time represented an instruction for a processor to execute, then 10001110 would cause one particular instruction to be executed and 10100001 another. (These instructions can also be represented in shorthand, so a list of instructions doesn't have to be tediously written down as many 1s and 0s.)
The code 10001110 is made up of 8 digits. In computing terminology, because each digit can only take one of two values (either 1 or 0), each digit is referred to as a ‘binary digit’. This is almost always abbreviated to bit. Therefore I can say 10001110 is an 8-bit code. As the code is in binary it is termed a binary code, so 10001110 is an 8-bit binary code.
Three switches in the following states would represent the 3-bit binary code 100:
Activity 4 (Exploratory)
Write down as many 2-bit binary codes as you can think of.
There are four possible 2-bit binary codes: 00, 01, 10 and 11.
This representation using 1s and 0s is very convenient. It makes it possible to write down what conditions exist inside the processor without having to deal with the complexities of the voltages and currents that exist to make the switches enter their on and off states. (If you could peer inside a processor you would not see 1s and 0s written down!)
Using binary codes is a very easy way to describe the state of the switches inside the processor, and allows people to represent what the electronic circuits that make up the processor are doing without having to understand how such circuits operate.