Question: Question 4 - Fix the subroutine ( 2 + 6 pts ) You are given following subroutine and contract ` ` ` 1 0 0
Question Fix the subroutine pts
You are given following subroutine and contract
;
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 R R
repeat:
cmpw R R ; set status bits for xN
jn enddiv ; if xN we are done
sub.w R R ; x xN
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.
b What should the correct line be Enter the instruction and operands. Watch out for autocorrect when entering your line.
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
