Instruction Format and Types of Address Instructions PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document provides an overview of various instruction formats, including three-address, two-address, one-address, and zero-address instructions. It shows examples of evaluating expressions using these instruction types, thus detailing various methods of calculating a complex expression including registers and memory.
Full Transcript
# What is Instruction Format? - An instruction is normally made up of a combination of an operation code and some way of specifying an operand, most commonly by its location or address in memory. | Mode | Opcode | Operand/Address | |---|---|---| | | | | <br> <br> <sub> Fig. 9-3 Instruction For...
# What is Instruction Format? - An instruction is normally made up of a combination of an operation code and some way of specifying an operand, most commonly by its location or address in memory. | Mode | Opcode | Operand/Address | |---|---|---| | | | | <br> <br> <sub> Fig. 9-3 Instruction Format with Mode Field</sub> <br> <br> # Types of Address Instructions ## Three Address instructions - Memory addresses for the two operands and one destination need to be specified. - It is also called **General register organization**. - Instruction: ADD R1, R2, R3 - Microoperation: R1 ← R2 + R3 ## Two Address Instructions - Two address registers or two memory locations are specified. - Assumes that the destination address is the same as that of the first operand. - Instruction: ADD R1, R2 - Microoperation: R1 ← R1 + R2 ## One Address Instructions - One address can be a register name or memory address. - **SINGLE ACCUMULATOR ORGANIZATION** - It uses AC register for all data manipulation. - Instruction: ADD X - Microoperation: AC ← AC + M[X] ## Zero Address Instruction - Stack is used. Arithmetic operation pops two operands from the stack and pushes the result. - Also called **stack organization**. # EVALUATE X=(A+B)*(C+D) - ADD R1, A, B R1 ← M[A]+M[B] - ADD R2, C, D R2 ← M[C]+M[D] - MUL X, R1, R2 M[X] ← R1*R2 # Evaluate X=(A+B)*(C+D) - MOV R1, A R1 ← M[A] - ADD R1, B R1 ← R1+M[B] - MOV R2, C R2 ← M[C] - ADD R2, D R2 ← R2+M[D] - MUL R1,R2 R1 ← R1*R2 - MOV X,R1 M[X] ← R1 # Evaluate X=(A+B)*(C+D) - LOAD A AC ← M[A] - ADD B AC ← AC+M[B] - STORE T M[T] ← AC - LOAD C AC ← M[C] - ADD D AC ← AC+M[D] - MUL T AC ← AC*M[T] - STORE X M[X] ← AC # Zero Address Instruction - Evaluate X = (A+B)*(C+D) | **Instruction** | **Description** | **Output** | |---|---|---| | PUSH A | TOS ← A | Push A | | PUSH B | TOS ← B | Push B | | ADD | TOS ← (A+B) | ADD | | PUSH C | TOS ← C | Push C | | PUSH D | TOS ← D | Push D | | ADD | TOS ← (C+D) | ADD| | MUL | TOS ← (C+D)*(A+B) | Mult | | POP X | M[X] ← TOS | Store |