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

PARALLEL SoFTWARE TECHNOLOGIES LABORA PS Part 3: Given the following formula: X

ID: 3607607 • Letter: P

Question

PARALLEL SoFTWARE TECHNOLOGIES LABORA PS Part 3: Given the following formula: X - A/B C/D E Provide the machine code to implement this formula using a. Three address format with a maximum one operand being a memory address for ALU operations b. Two address format with no operand being a memory address (except for Load and Store operations of course) c. One address format d. Which of the two solutions (part 3a and 3b) requires fewer registers for this code sequence? Which version requires the fewest number of instructions? UNIVERSITYof HOUSTON PSTL List of instructions required for part 3 Tab

Explanation / Answer

a.

load                 $r0, A

load                 $r1, C

div                   $r2, $r0, B

div                  $r3, $r1, D

add                  $r0, $r2,$r3

sub                   $r0,$r0, E

store                 X, $r0

b.

load                 $r0, A

load                 $r1, B

load                 $r2, C

load                 $r3, D

div                   $r0, $r1

div                  $r2, $r3

add                  $r0, $r2

load                 $r1, E

sub                   $r0, $r1

store                 X, $r0

c.

All data manipulations in the accumulator.

load                 A                     acc <- A

div                   B                     acc <- A+B

store                T                      T <- acc

load                 C                     acc <- C

div                   D                     acc <- C/D

add                  T                      acc <- C/D +T (C/D + A/B)

sub                   E                      acc <- A/B + C/D - E

store                X                     X <- acc

d. Number of instructions required in the below order:

three address(7) < one address(8) < two address(10)

Here if “sub” instruction is not allowed then it can be achieved by first calculating negative of E(NEG instruction) then adding negation to A/B + C/D using ADD.