Operand addressing and instruction representation
Download
1 / 14

Operand Addressing And Instruction Representation - PowerPoint PPT Presentation


  • 99 Views
  • Uploaded on

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.

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

PowerPoint Slideshow about ' Operand Addressing And Instruction Representation' - sana


An Image/Link below is provided (as is) to download presentation

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



One two three address machines
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.

  • • 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.


One two three address machines1
One, Two, Three-Address Machines

  • 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:

  • load B, A

  • mult C, A

  • add D, A


One two three address machines2
One, Two, Three-Address Machines

  • 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:

  • load B

  • mult C

  • add D

  • 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.


One two three address machines3
One, Two, Three-Address Machines

  • Evaluate the expression Z= (X*Y)+(W*Z)

    For 3address, 2 address, 1 address and 0 address instructions


Three address operands
Three Address Operands

  • 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

    Add Z, R2, R1


Two address instruction
Two address Instruction

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

    Load R1, X

    Mult R1, Y

    Load R2, W

    Mult R2, U

    Add R1, R2

    Store Z, R1


One address instruction
One Address Instruction

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

    Load X

    Mult Y

    Store Temp

    Load W

    Mult U

    Add Temp

    Store Z


Zero address instruction
Zero Address Instruction

  • 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

    Add

    Pop Z


One two three address machines4
One, Two, Three-Address Machines

Show the programs to execute

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

One address, two Address and Three Address operand Instructions

Three Address Instruction:

SUB Y, A, B YA-B

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

ADD T, T,C TT+C

DIV Y, Y, T YY/T


Two address instruction1
Two Address Instruction

MOV Y, A YA

SUB Y, B YY-B

MOV T, D TD

MULT T, E TT*E

ADD T, C TT+C

DIV Y, T YY/D


One address instruction1
One Address Instruction

LOAD D AC D

MULT E ACACXE

ADD C ACAC+C

STORE Y YAC

LOAD A AC A

SUB B ACAC-B

DIV Y AC AC/Y

STORE Y YAC


ad