IAR 中的乘法子例程返回随机值
目前,我已经创建了一种相当硬编码的方式,将值乘以10。虽然测试表示子例程,但我注意到,如果我将subroutine称为多次以上,那么返回的值不是我所期望的。我越过呼叫,但是,如果我将其按预期运行,则该调用的工作原理。
例如:
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
然后,返回到R10的值将为160,而不是预期的5,000。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论