Write a short program segment that doubles the longword-sized content in registe
ID: 3881062 • Letter: W
Question
Write a short program segment that doubles the longword-sized content in register D4 if the content in register D4 is positive. After the program segment, please also copy the content of register D4 to memory location with address 0x3000. You can use the IF THEN structure discussed in Lecture 6. (6 points) Hint: for conditional branch, BPL or BMI may not work in this problem, since "PL" means "non-negative" (N=0) while “MI" means "negative" (N-1). So you can use a comparison instruction first and then use a conditional branch discussed in Lecture 6. To double content in register D4, you can make a copy of register D4 in another data register, and add the content of that register to register D4.Explanation / Answer
CMP.L #0, D4 //compare d4 to 0
BLE SKIP //go to skip if <= 0
MOVE.L D4, D3 //copy d4 to d3
ADD.L D3, D4 //add d3 to d4
skip: // label skip
MOVE.L 0x3000, D3 //copy 0x3000 to D3
MOVE.L D4, (D3) //copy d4 into memory 0x3000
Hope this helps. Do Upvote! :)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.