3- please convert the following. show all work
a) convert this into one-address machine instruction (load,store,add,sub,mult): E = (A*C) + (B*D)
b) convert this into two-address machine instruction: A= C+B*D*E+A.
c) convert this expression using zero-address machine: a=b-c*d.
(a)Expression:- E= (A*C)+(B*D)
AC is accumulator
M[ ] is memory Location
M[T] is Temporary Location
LOAD | A | AC=M[A] |
ADD | B | AC=AC+M[B] |
STORE | T | M[T]=AC |
LOAD | C | AC=M[C] |
ADD | D | AC=AC+M[D] |
MUL | T | AC=AC*M[T] |
STORE | X | M[X]=AC |
(b) Two Address Instruction contains opcode,destination address,source address,mode
A=C+B*D*E+A
R1,R2 are the registers
M[ ] is the memory Location
MOV R1,B R1=M[B]
MOV R2,D R2=M[B]
MUL R1,R2 R1=R1*R2
MOV R2,E R2=M[E]
MUL R1,R2 R1=R1*R2
ADD R1,C R1=R1+C
ADD R1,A R1=R1+A
MOV X,R1 M[X]=R1
(c)
Expression: a=b-c*d Postfixed : a = BC-D* TOP means top of stack M[X] is any memory location
PUSH B TOP=B
PUSH C TOP=C
SUB TOP=B-C
PUSH D TOP=D
MUL TOP=B-C*D
POP X M[X]=TOP
Get Answers For Free
Most questions answered within 1 hours.