0% found this document useful (0 votes)
98 views1 page

Q-2) Compare One-, Two-, and Three-Address Machines by Writing Programs To Compute For

The document compares one-, two-, and three-address machines by writing programs to compute the expression X = (A * F + B * C) / (B* D - E * F) for each. The one-address machine requires the most instructions, followed by the two-address then three-address machines, which requires the fewest instructions. However, the three-address machine has the fastest execution time, followed by the two-address then one-address machines.

Uploaded by

Faltu Account
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views1 page

Q-2) Compare One-, Two-, and Three-Address Machines by Writing Programs To Compute For

The document compares one-, two-, and three-address machines by writing programs to compute the expression X = (A * F + B * C) / (B* D - E * F) for each. The one-address machine requires the most instructions, followed by the two-address then three-address machines, which requires the fewest instructions. However, the three-address machine has the fastest execution time, followed by the two-address then one-address machines.

Uploaded by

Faltu Account
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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