14-Addressing Modes-30-01-2023
14-Addressing Modes-30-01-2023
L T PC
3 0 0 3
Dr. M. Bhuvaneswari
Assistant Professor Senior Gr.2
School of Computer Science and Engineering
Vellore Institute of Technology, Vellore
[email protected]
Instruction and its format
• A computer performs a task based on the instruction provided.
• Instruction is a statement by which the operation of CPU is
determined.
• An instruction comprises of two parts: Opcode, and Operand.
• Eg.:
• ADD R3,R4 – R3=R3+R4
• ADD LOCA,R1 – LOCA=[LOCA]+R1
• ADD R1,#10 – R1=R1+10
• MOV R1,R2 – R1←R2
• Opcode specifies the operation to be performed.
• Various categories of instruction – data transfer, arithmetic and logic,
2
control, I/O
Instruction and its format
• Operands - input for the operation.
• Specifies the source(s) and destination of the operation.
• Source operand - Immediate data, register name or a memory
location.
• Destination operand - register name or a memory location.
• Number of operands varies from instruction to instruction.
• Three-Address Instructions
• ADD R1, R2, R3 R1 ← [R2] + [R3]
• Two-Address Instructions
• ADD R1, R2 R1 ← [R1] + [R2]
3
Instruction and its format
• Number of operands varies from instruction to instruction.
• One-Address Instructions
• ADD M AC ← [AC] + M[AR]
• Zero-Address Instructions
• ADD TOS ← [TOS[ + [TOS – 1]
• Instruction format example
4
An Instruction Example
• Let say we have an ISA with 32 bit instruction only.
• Decoding process is easy – Fixed size instruction.
OPCODE Destination Register Source Register Memory location
32 bits
4 bits 5 bits 5 bits 18 bits
32 bits
4 bits 5 bits 5 bits 18 bits
7
Instruction Set
• The collection of different instructions that the CPU can execute is
referred to as the CPU’s instruction set.
• Instruction Set is categorized into types based on
• Operation performed
• number of operand addresses
• and addressing modes.
8
Instruction Set Category
• Based on Operation
• Data movement instructions: Move data from a memory location
or register to another memory location or register without changing
its form.
• Memory : LOAD, STORE, MOV
• I/O Instructions: IN, OUT
9
Instruction Set Category
• Data processing instructions : Arithmetic and logic (ALU)
instructions. Changes the form of ne or more operands to produce a
result stored in another location
• Arithmetic : ADD, SUB, MUL,...
• logic Instructions: AND, OR,...
10
Instruction Set Category
• Control Instructions : Any instruction that alters the normal flow of
control from executing the next instruction in sequence.
• Conditional : JNZ, JZ, JNP, ...,
• Un Conditional: Jump
11
Instruction Set
• The collection of different instructions that the CPU can execute is
referred to as the CPU’s instruction set.
• Instruction Set is categorized into types based on
• Operation performed
• number of operand addresses
• and addressing modes.
12