Question: Consider the assignment x = y*x + x*z + y. Give a register-machine instruction stream to compute this assignment. Use the load, store, add, mul

Consider the assignment x = y*x + x*z + y. Give a register-machine instruction stream to compute this assignment. Use the load, store, add, mul instructions and the following format.

Example: Consider the assignment statement x = y + (z*y)*z.

As an example of machine language (VM, HM), we use a register machine typical of today's conventional computers. The above stack machine instruction stream would be translated, with some optimization performed, into the following instructions using three registers R1, R2, R3:

load y, R1 // load value of memory cell of y into R1 load z, R2 // load value of memory cell of z into R2 mul R2, R1, R3 // R3  R2 * R1 = z*y mul R3, R2, R2 // R2  R3 * R2 = (z*y)*z add R1, R2, R1 // R1  R1 + R2 = y + (z*y)*z store R1, x // store value of R1 in the memory cell of x

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!