Question

6 pts) Compare zero- and three-address machines by writing programs to compute X = (A-B * C) + (D + E) * F for each. Store your final result in variable X. For the 0-address machine, youll use POP X. You have the following commands: 0 Address PUSH M POP M ADD SUB MUL DIV 3 Address MOVE (XY) SUB (XEY Z) DIV (X-Y/Z) Add or remove rows as needed. 0 Address 3 Address

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:------------

Given,

Expression, X = (A - B * C) + ( D + E) * F

Postfix Notation of given Expression,

==> ( A - B C* ) + ( D E + ) * F

==> (A B C * - ) + ( D E + F * )

==> A B C * - D E + F * +

Here, TOS = Top of Stack

0 Address 3 Address
PUSH A (TOS <- A ) MUL R1, B,C ( R1 <- B * C )
PUSH B   (TOS <- B ) SUB R2, A, R1 (R2 <- A - R1)
PUSH C (TOS <- C ) ADD R3 ,D ,E (R3 <- D + E )
MUL (TOS <- B * C ) MUL R3,R3,F (R3 <- R3 * F )
SUB (TOS <- A - B * C ) ADD X, R2, R3 ( X <- R2 + R3 )
PUSH B (TOS <- D )
PUSH B (TOS <- E )
ADD    (TOS <- D + E )
PUSH F   (TOS <- F )
MUL (TOS <- (D + E ) * F )
ADD (TOS <- ( A - B * C ) + (D + E ) * F ) )
POP X ( X <- TOS )
Add a comment
Know the answer?
Add Answer to:
6 pts) Compare zero- and three-address machines by writing programs to compute X = (A-B *...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program the following advanced language formulas using the universal command statement expression method for the 0,...

    Program the following advanced language formulas using the universal command statement expression method for the 0, 1, 2, 3 address machine in Figure 1. However, use any register name you want to use. A = (A + B * C) / (D – B * E) 0 Address PUSH M POPM ADD SUB MUL DIV 1 Address LOADM STOREM ADDM SUBM MUL M 2 Address MOVE ( XY) ADD (X-X+Y) SUB (X--X-Y) MUL (X--XXY) DIV ( XXY) 3 Address MOVE...

  • Note: The question needs to be answered in "C Programming Languange ". And after the question fin...

    Note: The question needs to be answered in "C Programming Languange ". And after the question find 3 pages for needed informations. Spring CE4717 Language Processors Q1. Consider the following LEx program. return R1 return R2 return R3 return R4 return R5; return R6; IA-2a-z)[A-Za-z0-9]- -2 10-91+ 10-9a-EA-FI Ihi] [01] [01] 이삐 t Vtin) int main (void) int tcode; do f tcode -yylex()i printf ("token type td \"%s\"\n", tcode, yytext); ) while (tcode)i return 0; i. Explain the steps needed...

  • Group Project 1 The Micro-1 Processor Simulation <Micro-1 Computer> Here's the organization of a computer equipped...

    Group Project 1 The Micro-1 Processor Simulation <Micro-1 Computer> Here's the organization of a computer equipped with a Micro-1 processor Memory contains an array of integer cells: int cell[] = new int[CAP]; where CAP is the capacity of memory. Initially this is set to 256. Internally, the Micro-1 processor is equipped with eight 32-bit data/address registers and two 32 bit control registers: PC, the program counter, contains the address of the next instruction to execute. IR, the instruction register, contains...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT