Question #218626

Write a program to evaluate the arithmetic statement 𝑥 = −𝑏 + (𝑏 ∗ 𝑏 − 4 ∗ 𝑎 ∗ 𝑐)/ 𝐶 + 𝐻 i. Using a general register computer with 3 address constructions ii. Using a stack organized computer with zero address operation instructions. 


1
Expert's answer
2021-07-19T00:35:24-0400

i)

MUL R1, b, b R1\gets M[b]*M[b]

MUL R2, 4, a R2\gets M[4]*M[a]

MUL R2, R2, c R2\gets R2*c

SUB R1, R1, R2 R1\gets R1-R2

SUB R1, R1, b R1\gets R1-M[b]

ADD R3, C, H R3\gets M[C]+M[H]

DIV X, R1, R3 X\gets R1/R3


ii)

PUSH 4 TOS\gets 4

PUSH a TOS\gets a

PUSH c TOS\gets c

MUL TOS\gets(4*a)

MUL TOS\gets(4*a*c)

PUSH b TOS\gets b

MUL TOS\gets (b*b)

SUB TOS\gets ((b*b)-(4*a*c))

SUB TOS\gets(((b*b)-(4*a*c))-b)

PUSH TOS\gets C

PUSH TOS\gets H

ADD TOS\gets(C+H)

DIV TOS\gets (((b*b)-(4*a*c))-b)/(C+H)

POP X M[X]\gets TOS


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS