78.9k views
5 votes
.Write the code to implement the following expressions on 3, 2,1, and 0 address

machines. A= B + C x D

User Danfelabs
by
9.0k points

1 Answer

7 votes

Answer:

Code to implement the expression-A= B + C x D

0 Address

The 0 address instruction consist 1 components in the format.

Only opcode

PUSH C

PUSH CD

MUL

PUSH B

ADD

POP A

1 Address

The 1 address instruction consist 2 components in the format.

One is opcode,other is addresses of source.

LDA D

MUL C

ADD B

STA A

2 Address

The 2 address instruction consist 3 components in the format.

One is opcode,other two are addresses of destination and source.

LOAD A, D

MUL A, C

ADD A, B

STORE A, A

3 address

The 3 address instruction consist 4 components in the format.

One is opcode, two are addresses of source and one is destination .

MUL A, D,C

ADD A, B,A

User Mhopeng
by
8.4k points