For this assignment assume you are given the following assem

For this assignment, assume you are given the following assembly language instructions (you may not need to use all of them: RISC (Load-Store): L, ST, ADD, SUB, MULT, DIV, AND, OR, NOT, BC, and COMP. Stack: PUSH, POP, ADD, SUB, MULT, DIV, AND, OR, NOT. Using the above operations Write the Assembler code for a RISC Load-Store machine (3 operands) that will implement the following assignment: f= (a + b) * (c/d); Write the Assembler code for a Stack machine that will implement the same assignment. Write the code for a RISC Load-Store machine Assembler that will implement the following: if (a > b) {a = b;} else {b = a;}

Solution

Solution:

Q1 a)

L R1, a Value of a loaded into R1

L R2,b value of b loaded into R2

ADD R3, R1,R2 values inside R1 and R2 is added and result stored into R3

L R1,c Value of c losded into R1

L R2, d Value of d loaded into R2

DIV R4, R1, R2   values inside R1 and R2 is divided and result stored into R4

MULT R3,R3,R4 values inside R3 and R4 is divided and result stored into R3

ST f, R3 value of R3 stored into f

Q1 b)

PUSH a Value of a push into stack

PUSH b Value of b push into stack

ADD a and b are added and result is push into stack

PUSH d   Value of d push into stack

PUSH c    Value of c push into stack

DIV c and d are divided and result is push into stack

POP f final result stored into f

Q2.

L R1, a

L R2, b

COMP R1, R2

BGT R2, ELSE

ST R1, R2

j EXIT

ELSE: ST R2, R1

EXIT:

 For this assignment, assume you are given the following assembly language instructions (you may not need to use all of them: RISC (Load-Store): L, ST, ADD, SUB

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site