Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

After the price of RAM dropped dramatically and the price of SRAM registers incr

ID: 3665917 • Letter: A

Question

After the price of RAM dropped dramatically and the price of SRAM registers increased dramatically our accounting department has decided that, in order to save costs, we can store the $PC register in the register file, and use the ALU itself to add 4 to the ALU after each instruction. They say this could be accomplised by re-compiling our code to inject an increment instruction to PC after every instruction The code would therefore look like this: Woult this idea work? Why or why not? Be specific. You may draw diagrams if it is useful.

Explanation / Answer

Here as per code provided, understand that:

add   $t0,$t1,$t2   # $t0 = $t1 + $t2; add as signed (2's complement) integers
addi $pc $pc 4   # $pc = $pc + 4; "add immediate" (no sub immediate)
lw   $t3 16($s0)   # load word at RAM address ($s0+16) into register $t3.
"16" gives offset from address in register $t3
addi    $pc $pc 4   # $pc = $pc + 4; "add immediate" (no sub immediate)
sw   $t4 12($s0)   # stores content of register $t4 into RAM at address ($s0+12)
addi   $pc #pc 4   # $pc = $pc + 4; "add immediate" (no sub immediate)

As we store $pc register in the register file and ALU itself adds 4 to itself after each instruction,

understand that this may work fine. We can save the cost too this way.