Professional Documents
Culture Documents
The bits of the instruction are divided into groups called fields. The commonly used
fields found in instruction formats are:
1. Operation Code (or, simply Op-code): This field states the operation to be
performed. This field defines various processor operations, such as add, subtract,
complement, etc.
2. Address: An address field designates a memory address or a processor register
or an operand value.
3. Mode: This field specifies the method to get the operand or effective address of
operand. In some computers’ instruction set, the op-code itself explicitly specifies
the addressing mode used in the instruction.
Prof. (Dr.) T. K. Ghosh
Instruction Formats
• For example, in the instruction:
ADD R1, R0;
ADD is the op-code to indicate the addition
operation and R1, R0 are the address fields for
operands.
• In certain situations, other special fields are
sometimes used. For example, a field that gives
the number of shifts in a shift-type micro-
operation or, a label field is used to process
unconditional branch instruction.
Prof. (Dr.) T. K. Ghosh
Instruction Formats
• The number of address fields is the primary concern of an
instruction format.
• The memory or processor registers stores the operand values
on which operation codes specified by computer instructions
are executed.
• Memory addresses are used to specify operands stored in
memory.
• A register address specifies an operand stored in processor
register. A register address is a binary number of k bits that
defines one of 2k registers in the CPU.
• Thus a CPU with 32 processor registers R0 to R31 has a
register address field of 5 bits. For example, processor register
R7 is specified by the binary number 00111.
• The internal organization of processor registers determines
the number of address fields in the instruction.
Prof. (Dr.) T. K. Ghosh
CPU organization
• The design of an instruction set for a
computer depends on the way in which the
CPU is organized.
• Generally, there are three different CPU
organizations with certain specific
instructions:
➢Single accumulator organization.
➢General register organization.
➢Stack organization.
2n – 1
PUSH POP
SP 98
23
43 Stack SP 43
- 21 - 21 Stack
56 56
(a) After PUSH of data (98) at top of stack (b) After POP of data (23) from top of stack
Decode
instruction
Yes Bran
ch ?
No
Fetch operands
Execute
instruction
Yes
Interrupt Interru
handling pt?
No
Store the result
Update PC
Op-code R1 (register)
Instruction
Operand
Memory address
Address of operand
operand
Memory
The branch location is computed by adding the offset value 20 with the current
value of the PC. This instruction (JR 20) requires 2 bytes: one for the op-code
(JR) and another for its offset value 20.
Prof. (Dr.) T. K. Ghosh
Addressing Modes
9. Relative Address Mode or PC-relative Address Mode:
2022
PC
Op-code Instructionaddress
Operand address = address + content of XR.
This mode is useful in accessing operand array. The address part of the instruction gives the
starting address of an operand array in memory. The index register is a special CPU register
that contains an index value for the operand. The index value for operand is the distance
between the starting address and the address of the operand. Any operand in the array can be
accessed with the same instruction provided that the index register contains the correct index
value.
For example, an operand array starts at memory address 1000 and assume that the index
register XR contains the value 0002. Now consider load instruction
LDA 1000
The effective address of the operand is calculated as:
Effective address = 1000 + content ofProf.
XR(Dr.) T. K. Ghosh
= 1002.
Addressing Modes
11. Base Register Address Mode: This mode is used for relocation of the
programs in the memory. Relocation is a technique of moving program or data
segments from one part of memory to another part of memory. Relocation is an
important feature of multiprogramming systems. In this mode the content of the
base register (BR) is added to the address part of the instruction to obtain the
effective address.
Instruction
Op-code offset
2500 2700
2520 2800
2250
2700
3400
4502