Explore BrainMass
Share

### Explore BrainMass

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Compare zero-, one-, two-, and three-address machines by writing programs to compute
X = (A+B X C)/D - E X F)
For each of the four machines. The instructions available for use as follows:

PUSH M LOAD M MOVE (X<-- Y) MOVE (X <--Y)
SUB SUB M MUL (X<-- X x Y) MUL (X<-- Y x Z)
MUL MUL M DIV (X<-- X /Y) DIV (X<-- Y /Z)
DIV DIV M

Legend: <-- arrow
small x multiply

#### Solution Preview

X=(A+B*C)/D-E*F

MUL T,B,C //T=B*C
DIV T,T,D //T=(A+B*C)/D
MUL T1,E,F // T1=E*F
SUB X,T,T1 //X=T-T1=(A+B*C)/D-E*F

Here we have taken two temporary registers T,T1 and storing the result in these two temp registers and finally, we have stored the content of registers into X which is the result.
In 3 address machines, each instruction takes 4 memory access, one access to fetch opcode from memory, 2 for getting the 2 inputs operands and a final to write the result back in memory

Hence, machine generates a total no of 20 ...

#### Solution Summary

The following posting helps compare address machines.

\$2.19