1 / 14

Operand Addressing And Instruction Representation - PowerPoint PPT Presentation

Operand Addressing And Instruction Representation. Tutorial 3. Addressing Modes. Addressing Modes. One, Two, Three-Address Machines. Consider how the C expression A = B*C + D might be evaluated by each of the one, two, and three-address instruction types.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Tutorial 3

• Consider how the C expression A = B*C + D might be evaluated by each of the one, two, and three-address instruction types.
• • Assumptions: Addresses and data words are two bytes in size. Opcodes are 1 byte in size. Operands are moved to and from memory one word (two bytes) at a time.
• • Three-Address Instructions: In a three-address instruction, the expression A = B*C + D might be coded as:
• mult B, C, A
• add D, A, Awhich means multiply B by C and store the result at A Then, add D to A and store the result at address A.
• Two Address Instructions: In a two-address instruction, one of the operands is overwritten by the result. Here, the code for the expression A = B*C + D is:
• mult C, A
• One Address (Accumulator) Instructions: A one-address instruction employs a single arithmetic register in the CPU, known as the accumulator. The code for the expression A = B*C + D is now:
• mult C
• store A
• The load instruction loads B into the accumulator, mult multiplies C by the accumulator and stores the result in the accumulator, and add does the corresponding addition. The store instruction stores the accumulator in A.
• Evaluate the expression Z= (X*Y)+(W*Z)

• 3 Address operands (first operand is the destination)

Using the 3 address instructions the code to evaluate the expression for Z is written as:-

Mult R1, X, Y

Mult R2, W, u

• When using two address instructions, one address specifies a register the other operand can be a register or a memory location.

Mult R1, Y

Mult R2, U

Store Z, R1

• The Accumulator is assumed as a destination in One Address instruction

Mult Y

Store Temp

Mult U

Store Z

• Stack based Architectures use no operands for instructions such as Add, Sub, Mult or Divide.

Push X

Push Y

Mult

Push W

Push U

Mult

Pop Z

Show the programs to execute

Y= (A-B)/[C+(D*E)] on

SUB Y, A, B YA-B

MULT T, D, E T<- D*E

DIV Y, Y, T YY/T

MOV Y, A YA

SUB Y, B YY-B

MOV T, D TD

MULT T, E TT*E

DIV Y, T YY/D

MULT E ACACXE