Question

Problem 1: a) Write LEGv8 assembly language programs for the following C program fragments. Please make...

Problem 1:
a) Write LEGv8 assembly language programs for the following C program
  fragments. Please make sure to add any necessary comments.

    P[20] = P[10] + P[30] + 25;

b) Show the machine code that will be generated by the assembly code in
   Problem 1.a. You can write machine code as decimal numbers.

please help me solve this

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Let the reference of p be X22

LDUR X9,[X22,#80] //index 8 required offset of 80, temporary register X9 gets p[10]

LDUR X10,[X22,#240] //index 30 required offset of 240, temporary reg X10 gets p[30]

ADD X9,X10,X9 //X10+X9 stored in X9, X9 gets p[10]+p[30]

ADD X9,#25 //X9 gets p[10]+p[30]+25

STUR X9,[X22.#160] //stores p[10]+p[30]+25 in p[20] as index 20 requires offset of 160

Machine code

for ADD opcode is 10001011000, opcode size is 11 and instruction is R format

for LDUR opcode is 11111000010, opcode size is 11 and instruction is D format

Add a comment
Know the answer?
Add Answer to:
Problem 1: a) Write LEGv8 assembly language programs for the following C program fragments. Please make...
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