Typical Instruction Format
Many computers have instructions in two main parts:
(a) function code (b) operand (or address)
The function code is a binary code for the actual instruction.
The operand is either:
1 A data item for the instruction to operate on; or
2 The address of a location containing a data item.
Example
For a particular microcomputer each function code takes up eight bits.
The code for LOAD ACCUMULATOR FROM MEMORY is 1010 1001. The address of each location takes 16 bits.
So the instruction 1010 1001 0001111 1111 1111 means:
LOAD ACCUMULATOR with the contents of location 0001111 1111 11111
Note: The instruction would probably be displayed in hexadecimal as A9 IFFF.
Worked question
A computer has six-bit function codes for its instructions. Included in the instruction set are the following:
Function code |
Meaning |
001000 |
Store contents of accumulator in the given location |
001101 |
Load the accumulator with the number given |
101100 |
Add the number given to the accumulator |
Explain the meanings of the following instructions:
1- 101100 000011
2- 001000
1- 101100 is the code for ‘add the number given to the accumulator’. 000011 is the binary for 3.
The instruction means ‘add the number 3 to the accumulator’.
2- 001000 is the code for ‘store contents of the accumulator in location’. The instruction means ‘store the contents of the accumulator in location 110011’.
THE NUMBER OF POSSIBLE FUNCTION CODES AND ADDRESSES
There is a limit to the number of different function codes a computer can have. This is decided by the number of bits used to store the code. The number of codes possible is the number of different values which can be stored in the available hits.
e.g. For eight-bit codes the number of different codes = 28
=256
There is also a limit to the number of addresses in the same way. The number of possible addresses is the number of different values which can be stored in the number of bits available.
e.g. For 16-bit addresses, the number of locations = 216
=65 536
Note: In fact most 8-bit microcomputers have 16-bit addresses. This means they are limited to 65536 (i.e. 64K) addresses for all storage. This includes the user’s RAM area, the screen memory and all the ROMs.
Worked question
For a given computer, the instructions occupy 16 bits each. Of this the function code is six bits and the rest of the instruction is an address. How many different instructions could the computer have and how many locations can be addressed?
The number of different instruction codes using six bits =26
=64
The number of different addresses which can be formed using the remaining ten bits =210
= 1024