如何在摩托罗拉 M6800 中对数字进行取模
我如何在摩托罗拉 M6800 的汇编中取数字的 mod,例如 a%9。请告诉我应该使用哪些助记符。
How can I take mod of a number for instance a%9 in assembly in Motorola M6800.Please tell me which mnemonics should I use.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最后,如果没记错的话,6800没有除法指令(6809中添加的IIRC),所以你必须自己实现除法(或者,如果你不关心速度,只需减去重复除数,直到结果小于除数,这就是余数)。
要计算余数(不除除)实际上在二进制中非常容易:
例如,让我们计算 127 除以 9 后的余数。我们首先将 9 左移:
左移直到得到:
重复移位和相减:
因为 1 小于 9 ,我们得到余数: 1. 如果你想检查一下,9x14=126。
At last if memory serves, the 6800 doesn't have a division instruction (IIRC that was added in the 6809), so you'll have to implement division on your own (or, if you don't care about speed, just subtract the divisor repeatedly until the result is less than the divisor, and that's your remainder).
To just figure the remainder (without the division) is actually pretty easy in binary:
For example, let's figure the remainder after dividing 127 by 9. We start by shifting 9 left:
shift left until you get:
Repeatedly shift and subtract:
Since 1 is smaller than 9, we have our remainder: 1. In case you want to check that, 9x14=126.
使用简单的 68k
using easy 68k