Write a program to evaluate the arithmetic statement :
x=a-b+c*(d*e-f)/g+h*k
a) using a general register computer with two address instructions.
Answers
Answer:
X=A-B+C*(D*E-F)/G+H*k a. ONE ADDRESS INSTRUCTIONS: LOAD A AC<-M[A] SUB B AC<-AC-M[B] STORE T M[T]<-AC LOAD D AC<-M[D] MUL E AC<-AC*M[E] SUB F AC<-AC-M[F] MUL C AC<-AC*M[C] ADD T AC<-AC+M[T] STORE T M[T]<-AC LOAD H AC<-M[H] MUL K AC<-AC*M[K] ADD G AC<-AC+M[G] STORE T1 M[T1]<-AC LOAD T AC<-M[T] DIV T1 AC<-AC/M[T1] STORE X M[X]<-AC b.ZERO ADDRESS INSTRUCTIONS: RPN:AB-CDE*F-*GHK*+/ PUSH A TOS<-A PUSH B TOS<-B SUB...
please follow me and mark me as a brain list...
Answer:
Here is a program in assembly language that evaluates the arithmetic statement "x = a - b + c * (d * e - f) / g + h * k" using a general register computer with two address instructions:
load a, R1
load b, R2
sub R1, R2, R3
load c, R4
load d, R5
load e, R6
mul R5, R6, R7
load f, R8
sub R7, R8, R9
load g, R10
div R9, R10, R11
mul R4, R11, R12
add R3, R12, R13
load h, R14
load k, R15
mul R14, R15, R16
add R13, R16, R17
store R17, x
Explanation:
This program uses the following two-address instructions:
load: loads a value from memory into a register
store: stores a value from a register into memory
add: adds the contents of two registers and stores the result in a third register
sub: subtracts the contents of two registers and stores the result in a third register
mul: multiplies the contents of two registers and stores the result in a third register
div: divides the contents of two registers and stores the result in a third register
Note: This program assumes that the values of a, b, c, d, e, f, g, h and k are already stored in memory and the memory address for x is available to store the result. Also, the program uses R1 to R17 as registers.
More question and answers
https://brainly.in/question/32965351
https://brainly.in/question/30353909
#SPJ3