Unity University
College of Engineering, Technology and
Computational Sciences
Department of Computer Science
Course Title : Computer Organization and architecture
Topic: Computer Instruction formats, Core CPU-Registers & Computer Instruction types
Objectives
After studying this unit, you will be able to:
• Define instruction codes and operands
• Discuss computer registers
• Explain computer instructions
1. Introduction
A computer program refers to a sequence of instructions, which are stored in the memory of a
computer. These instructions are a group of bits that enable the computer to perform a specific
operation. They are read by the Central Processing Unit (CPU) and are placed in Instruction
Register (IR). The circuitry control then converts these instructions into a sequence of micro
operations that are required for their implementation.
1.1 Instruction Codes and Operands
A computer instruction is a binary code that specifies the micro-operations in a sequence for a
computer. They(instructions) are stored in the memory along with the data. Every computer has
its own unique set of instructions. They can be divided into three parts ( (refer fig. X, below):
1. Operation codes (Opcodes) , 2. Address (or operand) and 3. addressing mode
Fig. X: Instruction format
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 1
Unity University
Opcodes specifies the operation for a particular instruction. An address specifies the registers or
the locations that can be used for that operation.
Operands are specific parts of computer instruction that depict what data is to be operated on.
For a basic computer, 12 bits of memory is required to specify the address as the memory contains
4096 words.
The 15th bit of the instruction specifies the addressing mode (where direct addressing corresponds
to 0, indirect addressing corresponds to 1). Since the instruction format consists of 12 bits of
address and 1 bit for the addressing mode, 3 bits are left for Opcodes.
Addressing Modes
Instructions generally refer to the address of a specific memory location. These are called memory
reference instructions. The way in which a target address or effective address is identified within
the instruction is called addressing mode.
The address field for an instruction can be represented in two different ways. They are:
1. Direct Addressing: It uses the address of the operand.
2. Indirect Addressing: It uses the address as pointer to operand.
The address of the operand or the target address is known as the effective address.
Effective Address (EA) – It refers to the address that can be implemented as a target address for
a branch type instruction or the address that can be used directly to access an operand for a
computation type instruction, without developing any changes.
Opcodes
An opcode is a set of bits that defines the basic operations such as add, subtract, multiply,
complement, and shift. The total number of operations supported by the computer decides the
number of bits required for the opcode. The minimum bits available to the opcode must be n for
2n operations. These operations are performed on data that is stored in processor registers or in
memory.
Notes
Processors have registers to hold instructions, addresses, and data. Program Counter (PC) is the
register used to store the memory address of the instruction that is to be executed next. A PC
requires 12 bits to hold the memory address.
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 2
Unity University
Commonly, computers come with a single processor register assigned to them named,
Accumulator (AC). Operations are performed with the content in AC and the memory operand.
In case an operation in the instruction code does not require the operand from memory, the
remaining bits can be utilized for other purposes.
Example: Operations in the instruction code include clear AC, increment AC, complement AC, and
so on. These operations do not need the second part of the instruction code.
Did u know? Address bits are also used as operands in some cases.
Address
Address is defined as the location where a particular instruction is found in the memory.
Sometimes the address bits of an instruction code are used as operand and not as an address. In
such cases, the instruction has an immediate operand. If the second part has an address, the
instruction is known to have a direct address. Another possibility is, the second part having the
address of the operand. This is known as indirect address. In the instruction code, one bit is used
to indicate if direct or indirect address is implemented.
Figure Y: depicts a diagram showing direct (figure (a)) and indirect address(figure (b))
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 3
Unity University
Example:
Referring to figure Y, Consider Figure a,
Here, Addressing mode bit is 0, which indicates direct addressing.
Operand (or opcode) is ADD.
Address is 300. This indicates the address of the operand. The instruction is stored in the 22nd
memory location. The control jumps to the 300th location to access the operand.
Consider Figure b,
Here, Addressing mode is 1, which indicates indirect addressing. Operand is ADD.
Address is 200. This indicates the address of the operand. The control goes to the address 200 to
get the address of the operand. Here, the address is 1200. The operand found in this address
location is added to the data in accumulator.
Here the address of the operand is known as the effective address. In the first figure the effective
address is 300 and in the second figure it is 1200. The memory word that contains the address of
the operand in the indirect address is used as a pointer to an array of data. The pointer is located
in the processor register.
1.2 Computer Registers
Computer registers are high speed memory storing units. They are a part of the computer
processor. They can hold any kind of data, such as a bit sequence or an individual data.
Instructions specify registers as part of them in most cases. A register must be 32 bits in length for
a 32 bit instruction computer. Registers can be numbered depending on the processor design and
language rules.
The instructions in a computer are stored in memory locations and executed one after another at
a time. It is the function of control unit to retrieve the instruction from the memory and execute
it. The control does the same for all the instructions in the memory in a serial order. A counter is
required to keep a track of the next instruction to be executed and calculate its address. In addition
to counter, a register is also required to store the instruction code after it is read by the control
from memory. Processor registers are needed for data manipulation. The figure Z (below) displays
the registers with their memories. The memory addresses are stored in a different register. These
requirements clearly state the need of registers in a computer. In figure Z different basic registers
are shown with their memory capacity.
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 4
Unity University
Figure Z: Basic registers with their memory capacity
The explanation for each of the registers specified in figure Z is as follows:
1. The data register holds the operand read from the memory.
2. The accumulator is a general purpose register used for processing.
3. The instruction register holds the read memory.
4. The temporary data used while processing is stored in the temporary register.
5. The address register holds the address of the instruction that is to be executed next from the
memory.
6. The Program Counter (PC) controls the sequence of instructions to be read. In case a branch
instruction is encountered, the sequential execution does not happen. A branch execution calls
for a transfer to an instruction that is not in sequence with the instructions in the PC. The
address of this non-consecutive instruction is passed on to the PC to replace the existing
instruction address. To read an instruction, the memory cycle is initiated again with the PC
content taken as address for memory. Next, the PC is incremented by one and the previous
order continues.
7. The input register (INPR) and output register (OUTPR) are the registers used for the I/O
operations. The INPR receives an 8 bit character from the input device, same with the OUTPR.
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 5
Unity University
Note: Table 1.1 lists the registers and their functions.
1.3 Computer Instructions
A computer has programs stored in its RAM in the form of 1s and 0s that are interpreted by CPU
as instructions. One word of RAM contains one instruction in the machine language. These
instructions are loaded to the CPU one at a time, where it gets decoded and executed.
A basic computer has three instruction code formats, namely:
1. the memory reference instruction,
2. the register reference instruction, and
3. the input-output instruction format.
1.3.1 Memory Reference Instruction
Usually programmers write codes in assembly language which has a very close reference
with machine language. These instruction formats are known as memory reference
instructions. The memory reference instruction has a specific format. It consists of three
parts as shown below.
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 6
Unity University
The different memory reference instructions are tabulated in table T.
Table T: Memory Reference Instructions
In figure W(depicted below), the opcode varies from 000 to 110. The first bit is the indirection bit.
The memory reference instruction is performed on the contents of the address in bits 0-11 of the
instruction word, if the indirect bit is 0.
Figure W: Memory Reference Instruction Format for Direct Addressing
In figure W, the indirection bit is given as 0 and the opcode as 000 indicating LDA. The address,
given in binary as 000000000111 is equivalent to decimal 7. This states that the Register A will be
loaded with contents of word 7 from memory. In case the indirect bit is changed to 1, the word 7
in memory would contain the address of the word that is to be loaded by Register A and not direct
content. Figure W illustrates the memory reference instruction format for direct addressing. The
15th bit here is 0.
In figure M, the indirection bit is given as 1 and the opcode as 000 indicating LDA. The address,
given in binary as 000000000111 is equivalent to decimal 7. This states that the register A will be
loaded with contents of word 7 from memory. As the indirect bit is 1, the memory contains the
address of word that is to be loaded by register A and not direct content. Figure M illustrates the
memory reference instruction format for indirect addressing. The 15th bit here is 1.
Figure M: Memory reference instruction format for indirect addressing.
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 7
Unity University
1.3.2 Register Reference Instruction
The register reference instructions use 16 bits to specify any operation. All these instructions take
1 clock cycle during execution. Figure F depicts its format.
Figure F: Register Reference Instruction Format
In figure F, the four leftmost bits are always 0111 which is the binary equivalent of hexadecimal
7. The opcodes and the registers that can be implemented are listed in table F(depicted below).
Table F: Register and their Description
Table G depicts opcodes and their description.
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 8
Unity University
Other than the leftmost 4 bits, the next nine bits hold the operand and registers, and the last three
are don’t cares. Consider an instruction as shown in figure H( as seen below).
Figure H: Instruction
In figure H (depicted above), 0111 indicates that the instruction is register reference. When the
processor loads and executes the instruction, it moves the contents of Register A to Register B. A
programmer would actually write this instruction in the coding format as:
MOV A, B
This is called assembly language and is translated into machine language by an assembler. The
machine language format of this instruction is stored in a disk. The operating system then loads it
from the disk to memory and causes the CPU to execute it.
1.3.3 Input/Output Instructions
The I/O instructions are similar to the register reference instructions. They also use a 16-bit format
to specify an operation. The difference is that the leftmost bits here are always 1111, which is the
binary equivalent of hexadecimal F.
Types of Instructions (types of operations (opcodes)
The number of different opcodes varies widely from machine to machine. However, the same
general types of operations are found on all machines. A useful and typical categorization is the
following:
■ Data transfer
■ Arithmetic
■ Logical
■ Conversion
■ I/O
■ System control
■ Transfer of control
Table K lists common instruction types in each category. This section provides a brief survey of
these various types of operations, together with a brief discussion of the actions taken by the
processor to execute a particular type of operation.
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 9
Unity University
Table K lists some of the basic computer instructions available.
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 10
Unity University
Table K lists some of the basic computer instructions available(Continued).
1.4 Summary
The binary codes that specify the micro operations in a sequence are called computer
instructions. An instruction code format consists of addressing mode, operation codes, and
address.
For a basic computer, 12-bits of memory is required to specify the address since the
memory contains 4096 words.
Computer registers are used to store the data. They are high speed storage areas within the
processor. Before every processing, the data must be represented in the registers.
A basic computer consists of eight registers, a memory unit, and a control unit. These units
need to communicate often. Bus provides the medium through which communication can
take place.
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 11
Unity University
Computer instructions are programs written in the form of 0’s and 1’s as interpreted by
the CPU. The instruction codes are divided into three categories, memory reference
instructions, register reference instructions, and Input/Output instructions.
1.5 Self Assessment
Part I: State whether the following statements are true or false:
(a) Opcodes specifies the operation for a particular instruction. T
(b) Effective address cannot be implemented as a target address for a branch type instruction. T
(c) Previously buses were used for connecting devices but now wires are used for the same. F
Part II: Descriptive (solve them by using the E-Text-book, and prepare to explain in class)
1. What are the typical elements of a computer instructions?
2. What type of locations can hold source and destination operands?
3. Discuss the different computer registers and their importance.
4. Computer buses help in the transmission of data between the components connected to it.
Discuss.
5. Instruction cycles are concerned with the fetch and execute cycle. Justify.
6. Consider a hypothetical microprocessor generating a 16-bit address (for example, assume that
the program counter and the address registers are 16-bit wide) and having a 16-bit data bus.
a) What is the maximum memory address space that the processor can access directly if it is
connected to a “16-bit memory”?
b) What is the maximum memory address space that the processor can access directly if it is
connected to a “8-bit memory”?
7. What type of operands are typical in computer instruction sets?
Answer: Computer instructions operate on data. the most important general categories of data
are:
a) Addresses
b) Numbers (integers or fixed point, floating point, decimal, etc.)
c) Characters (text or character strings)
d) Logical data
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 12
Unity University
8. List down the general types of “Instruction set operations “ (or different opcodes) that are
found on all computers.
Answer:
a) Data transfer operation (memory or register, )
b) Arithmetic operation n (add, subtract, multiply, divide, absolute, increment decrement)
c) Logical operation (NOT, AND,OR,XOR, logical shifts, arithmetic shifts )
d) Conversion operation (change the format of data ex. Decimal to binary)
e) Input/output operation
f) Transfer of control operation( Brach instruction, skip instruction)
9. What is the difference between assembly language and machine language?
_________________The End! _______________
Source: Feleke M. HaileMariam (Dr.-Eng.) Page 13