Question: Suppose the target assembly language for a compiler has Exercise 5 five instructions for integers: push address add sub mul pop address In these instructions,
Suppose the target assembly language for a compiler has Exercise 5 five instructions for integers: push address add sub mul pop address In these instructions, an address is the name of a static variable (whose a dress will be filled in by the loader). The machine maintains a stack of in which can grow to any size. The push instruction pushes the integer from the en memory address to the top of the stack. The add instruction adds the t on the stack to the next-from-the-top integer, pops both off, and pushes the onto the stack. The sub instruction subtracts the top integer on the stack fro next-from-the-top integer, pops both off, and pushes the result onto the stack Th mul instruction multiplies the top integer on the stack by the next-from-th teger, pops both off, and pushes the result onto the stack. The pop instr an integer off the stack and stores it at the given memory address. So, for the compiler might translate the assignment result : offset+ (width into this: actual ad egers rom the g op integer m the e-top in uction pops example, n) push offset push width push n mul add pop result Using this assembly language, give translations of the assignment statements in Exercise 4. Use as few instructions as possible
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
