Suppose you want to clear register R0 only when R18 is greater than R21, or set
ID: 3810006 • Letter: S
Question
Suppose you want to clear register R0 only when R18 is greater than R21, or set all the bits in R0 otherwise. After this, the program doubles the value in R0. Assuming all values are unsigned, complete the following program using AVR assembly language instructions. Do not include any unnecessary spaces in your program and do not modify any registers except noted above. Note that the ":" is not part of the label name and should not be included when specifying a branch target.
IF: (fill in the blank)
(fill in the blank)
LABEL2:SER R0
JMP END_IF
LABEL1:CLR R0
END_IF:ADD R0,R0
Explanation / Answer
Answer
At LEVEL2 all the bits in R0 is getting set, that means, R18 is less than R21 when compared in the previous step.
So, the blank space must have a comparision statement on R18 and R21 and does accordingly to the comparision.
Therefore,
IF: CMP R18, R21
JG LABEL1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.