Here is a fragment of a C program that will execute on the S machine: Assume that integers are…

Here is a fragment of a C program that will execute on the S machine:

Assume that integers are stored as 4-byte long words. The S-machine instructions to perform the assignment statement above are

For simplicity, we have written the slla instruction so they refer to the variables by their symbolic names rather than by offset. For the purposes of this problem, we define a stack transaction as any push of a (4-byte) long word onto the stack or any pop of a long word from the stack. An

instruction in the S machine may perform one or more stack transactions during its execution. The sadd4 instruction, for example, performs three stack transactions. Draw up a table like the one started below. Fill in this table by following these instructions for each S-machine instruction in the above program fragment.

1. Check the “Push onto stack” column if the instruction pushes either a datum or an address onto the stack.

2. Check the “Pop from stack” column if the instruction removes either a datum or an address from the stack.

3. Indicate whether the entry pushed or popped is a value (datum) or an address by checking either the “Value” or the “Address” column. 4. If the instruction performs several stack transactions, indicate each on a separate line in the table. List the stack transactions in the order in which (Hint: No instruction makes more than three stack transactions.) they occur.

Assume that the width of the path between the processor and main memory is 1 long word. Each stack transaction transfers a long word to or from the stack. How many accesses to main memory are performed by the stack transactions in your answer?