Instruction Format and Types of Address Instructions PDF

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 &nbsp;&nbsp;&nbsp;&nbsp; R1 ← M[A]+M[B] - ADD R2, C, D &nbsp;&nbsp;&nbsp;&nbsp; R2 ← M[C]+M[D] - MUL X, R1, R2 &nbsp;&nbsp;&nbsp;&nbsp; M[X] ← R1*R2 # Evaluate X=(A+B)*(C+D) - MOV R1, A &nbsp;&nbsp;&nbsp;&nbsp; R1 ← M[A] - ADD R1, B &nbsp;&nbsp;&nbsp;&nbsp; R1 ← R1+M[B] - MOV R2, C &nbsp;&nbsp;&nbsp;&nbsp; R2 ← M[C] - ADD R2, D &nbsp;&nbsp;&nbsp;&nbsp; R2 ← R2+M[D] - MUL R1,R2 &nbsp;&nbsp;&nbsp;&nbsp; R1 ← R1*R2 - MOV X,R1 &nbsp;&nbsp;&nbsp;&nbsp; M[X] ← R1 # Evaluate X=(A+B)*(C+D) - LOAD A &nbsp;&nbsp;&nbsp;&nbsp; AC ← M[A] - ADD B &nbsp;&nbsp;&nbsp;&nbsp; AC ← AC+M[B] - STORE T &nbsp;&nbsp;&nbsp;&nbsp; M[T] ← AC - LOAD C &nbsp;&nbsp;&nbsp;&nbsp; AC ← M[C] - ADD D &nbsp;&nbsp;&nbsp;&nbsp; AC ← AC+M[D] - MUL T &nbsp;&nbsp;&nbsp;&nbsp; AC ← AC*M[T] - STORE X &nbsp;&nbsp;&nbsp;&nbsp; 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 |

Use Quizgecko on...
Browser
Browser