Question: Compare zero-, one-, two-, and three-address machines by writing programs to compute X = (A + B / C D) + (E * F) for

Compare zero-, one-, two-, and three-address machines by writing programs to compute X = (A + B / C D) + (E * F) for each of the four. Store your final result in variable X. The instructions available for use in each machine are as follows.

0 Address

1 Address

2 Address

3 Address

PUSH M

LOAD M

MOVE (XY)

MOVE (XY)

POP M

STORE M

ADD (XX + Y)

ADD (XY + Z)

ADD

ADD M

SUB (XX - Y)

SUB (XY - Z)

SUB

SUB M

MUL (XX * Y)

MUL (XY * Z)

MUL

MUL M

DIV (XX/Y)

DIV (XY/Z)

DIV

DIV M

Example: Here is the example from the book, and its solution.

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

0 Address

1 Address

2 Address

3 Address

PUSH A

LOAD E

MOV R0, E

MUL R0, E, F

PUSH B

MUL F

MUL RO, F

SUB R0, D, R0

PUSH C

STORE T

MOV R1, D

MUL R1, B, C

MUL

LOAD D

SUB R1, R0

ADD R1, A, R1

ADD

SUB T

MOV R0, B

DIV X, R0, R1

PUSH D

STORE T

MOV R0, C

PUSH E

LOAD B

ADD R0, A

PUSH F

MUL C

DIV R0, R1

MUL

ADD A

MOV X, R0

SUB

DIV T

DIV

STO X

POP X

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!