You are on page 1of 1

Q-2) Compare one-, two-, and three-address machines by writing programs to compute for

each of the three machines. X = (A * F + B * C) / (B* D - E * F). The instructions available for
use are as follows:

Ans.

3 Address 2 Address 1 Address


MUL R0, E, F MOVE R0, E LOAD E
MUL R1, B, D MUL R0, F MUL F
SUB R2, R1, R0 MOVE R1, B STORE R0
MUL R0, B, C MUL R1, D LOAD B
MUL R1, A, F SUB R1, R0 MUL D
ADD R3, R1, R0 MOVE R0, B SUB R0
DIV X, R3, R2 MUL R0, C STORE R0
MOVE R2, A LOAD B
MUL R2, F MUL C
ADD R2, R0 STORE R1
DIV R2, R1 LOAD A
MOVE X, R2 MUL F
ADD R1
DIV R0
STORE X

Comment: More lines of codes are required to execute the program in the 1 – address machine
than in the 2 – address machine. Similarly, more lines of codes are required to execute the
program in the 2 – address machine than in the 3 – address machine. However, the execution
time of the 3 – address machine is the fastest and then the 2 – address machine and then the
1 – address machine.

You might also like