1 year ago
#374973
El Beto
Multiplication subroutine in IAR is returning random values
Currently I've created a rather hardcoded way of multiplying a value by 10. While testing said subroutine, I've noticed that if I call the subroutine more than one time, the value that'll be returned is not the one I anticipated if I step over the call, however if I step into the call it works as intended.
For example:
digit1: 5
fiveThousand:
call #multiply10
call #multiply10
call #multiply10
mov.b digit1,R10
multiply10:
mov.b digit1,R12
mov.b digit1,R13
add R13,R12
add R13,R12
add R13,R12
add R13,R12
add R13,R12
add R13,R12
add R13,R12
add R13,R12
add R13,R12
mov.b R12,digit1
mov.b #0,R13
mov.b #0,R12
ret
Then the value returned to R10 will be 160, not 5,000 as expected.
assembly
msp430
iar
0 Answers
Your Answer