Question 1 Write an ARM assembly language program which implements a loop to cal
ID: 3728188 • Letter: Q
Question
Question 1 Write an ARM assembly language program which implements a loop to calculate the integer division of two unsigned numbers stored in r2 and r1 (i.e., computes r2/r1), and store the result in rO. You can do this by counting successive subtractions of the divisor (r1) from the dividend (r2) until the difference is less than the divisor. Your code should not destroy the values of r1 or r2. Question2 Write ARM assembly language instructions to set the least significant byte of rO to zero if the least significant byte of rO is the same as the least significant byte of r1. Use registers r2 and r3 as scratch registers (to store intermediate values).Explanation / Answer
MOV R2,#128 ;divide R2
MOV R1,#4 ;by R1
MOV R0,#0 ;initialise counter
.subtract
SUBS R2,R2,R1 ;subtract R1 from
;R2 and store
;result back in
;R2 setting flags
ADD R0,R0,#1 ;add 1 to counter,
;NOT setting flags
BHI subtract ;branch to start of
;loop on condition
;Higher, i.e. R2 is
;still greater than
;R1. Answer now in R0
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.