Question
Please help me answer both of those questions thank you in advance

Problem 3- Consider the following assembly code: Problem 4 Given the following code, assume x1 holds the value Ox00101000. Wh
0 0
Add a comment Improve this question Transcribed image text
Answer #1

3)

Answer: Loop executes twice and is based on the value ofx2, if the value ofx2 is <0 the loop terminates. The value ofx2 at th

4)

Description:
MAIN:
bge x0,x1,NOTSET (branch to NOTSET if x0>=x1)
addi x2,x0,1 (add immediate value to x2 register i.e. x2=x0+1)
NOTSET: addi x2,x0,0 (add immediate value to x2 register i.e. x2=x0+0)
bne x2,x0,ELSE (branch to ELSE if x2≠x0)
beq x0,x0,DONE (branch to DONE if x0=x0)
ELSE: addi x2,x2,2 (add immediate value to x2 register i.e. x2=x2+2)
DONE:
What will be the value of x2 register after the execution of following code:
Assume x1=0x00101000
Case 1: if x0<x1
Suppose x0=0x0000 0000
MAIN:
bge x0,x1,NOTSET (Condition x0 >= x1 is not True)
addi x2,x0,1 (x2=x0+1 i.e. x2=0x00000001)
NOTSET: addi x2,x0,0
bne x2,x0,ELSE (go to ELSE if x2≠x0)
beq x0,x0,DONE (go to DONE if x0=x0)
ELSE: addi x2,x2,2 (x2=x2+2 i.e. x2=0x0000 0011)
DONE:
Output: if x0<x1 Then x2=x0+3
x2=0x0000 0011
Case 2: if x0>=x1
Suppose x0=0x00101001
MAIN:
bge x0,x1,NOTSET (Condition True x0>=x1, go to NOTSET)
addi x2,x0,1
NOTSET: addi x2,x0,0 (x2=x0+0 i.e. x2=x0)
bne x2,x0,ELSE (go to ELSE if x2≠x0)
beq x0,x0,DONE (go to DONE if x0=x0)
ELSE: addi x2,x2,2
DONE:
Output: if x0>=x1 Then x2=x0
x2=0x00101001

Add a comment
Know the answer?
Add Answer to:
Please help me answer both of those questions thank you in advance Problem 3- Consider the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT