Question

In LC3, Multiply whatever is in R0 by 6, and store it in R1 For ex,...

In LC3, Multiply whatever is in R0 by 6, and store it in R1

For ex, if R0 has 5, R1 will contain 30

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

Below is the LC3 code to do this

AND R1, R1, 0 //R1 will store value 0 now

AND R2, R2, 0 //R2 will store value 0 now

ADD R2, R2, 6 //R2 will store value 6 now

ADD R3, PC, 2 //Store value of PC+2 into R3 which is the value of next instruction with label START

START :- ADD R1, R1, R0 //R1 = R1+R0

ADD R2, R2, -1 //This will reduce the count of R2 by 1

BRz END //Branch to label END if R2 becomes 0

JMP R3 //Jump at label START which is stored in R3, if R2 is not zero

END :- RET //Return instruction

In the above instruction R2 initially holds value 6 and acts as counter. We repeatedly add R0 with R1.

Please comment for any clarification.

Add a comment
Know the answer?
Add Answer to:
In LC3, Multiply whatever is in R0 by 6, and store it in R1 For ex,...
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