Please explain thoroughly. I will thumbs up 5. 1 point)is a load/store RISC ISA
ID: 3702787 • Letter: P
Question
Please explain thoroughly. I will thumbs up
5. 1 point)is a load/store RISC ISA that has 32 general purpose registers. 6. (20 points) Write the code to implement the expression A((B/F)(Cx D)) x E on 3, 2-,1-, and 0-address machines. Do not rearrange the expression. In accordance with programming language practice, computing the expression should not change the values of its operands. When using a 0-address machine, the order used is SOS op TOS, where SOS is second on stack and TOS is top of stack.Explanation / Answer
Answer:--
5). 1-address instruction set is a load/store RISC ISA that has 32 general purpose registers.
6).
3-Address Instruction:---
DIV R1, B, F R1 <-- M[B] / M[F]
MUL R2, C, D R2 <-- M[C] * M[D]
ADD R1, R1,R2 R1 <-- R1 + R2
MUL A, R1, E M[A] <-- R1 * R2
2 - Address Insructions:----
MOV R1, B R1 <-- M[B]
DIV R1, F R1 <-- R1 / M[F]
MOV R2, C R2 <-- M[C]
MUL R2, D R2 <-- R2 * M[D]
ADD R1, R2 R1 <-- R1 + R2
MOV R2, E R2 <-- M[E]
MUL R1,R2 R1 <-- R1 * R2
MOV A, R1 M[A] <---R1
1- Address Insructions:----
LOAD B AC <-- M[D] AC=Accumulator
DIV F AC <-- AC / M[F]
STORE X M[X] <---AC
LOAD C AC <-- M[C]
MUL D AC <-- AC * M[D]
ADD X AC <-- AC + M[X]
MUL E AC <-- AC * M[E]
STORE A M[A] <-- AC
0- Address Insructions:----To write these instruction firstly, we need to change the given expression in to Postfix Notation (Reverse Polish Notation) because Stack use 0- Address Insructions . Push ( Insert value into Top of Stack (TOS) and Pop (Remove value from Top of Stack) operations are used .
Given Expression , X = ((B/F) + (C*D)) * E
Postfix ----->
=> ((B/F) + (C*D)) * E
=> (( BF/) + (C*D)) * E
=> (( BF/) + ( CD* ) )* E
=> ( BF/ CD* + ) * E
=> BF/ CD * + E *
PUSH B TOS <-- B
DIV TOS <-- (B / F)
PUSH C TOS <-- C
PUSH D TOS <-- D
MUL TOS <-- (C * D)
ADD TOS <--(B / F) + (C * D)
PUSH E TOS <--- E
MUL TOS <-- ((B / F) + (C * D)) * E
POP A M[A] <-- TOS