Question: Subroutine: x _ mod _ N input: R 5 unsigned 1 6 - bit integer x - - returned unchanged R 6 unsigned 1 6
Subroutine: xmodN
input: R unsigned bit integer x returned unchanged
R unsigned bit nonzero integer N returned unchanged
output: R unsigned bit integer y may be modified
y is the remainder when x is divided by N
Modifies R all other core registers in RR unchanged
xmodN:
mov.w RR
repeat:
cmpw RR ;set status bits for xN
jn enddiv ;if xN we are done
;otherwise
sub.w RR ;x xN
jmp repeat land repeat from top
enddiv:
ret
Sometimes it works correctly eg it can correctly compute and at
other times it does not. Can you find the error and fix the subroutine?
a What line needs to be fixed? Enter the line number.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
