汇编 6800 循环?测试字中的特定位
试图帮助朋友与朋友一起解决一些汇编代码,但我遇到了一个小问题。
我正在尝试弄清楚如何循环 8 位二进制字并检查特定位的值。我需要检查第 1、3、5 和 1 位。 7 看看它们是否为 1。
即
int count = 1;
int bitAdd = 0;
foreach (var bit in word) {
if ((count = 1 && bit = 1) || (count = 3 && bit = 1) || (count = 5 && bit = 1) || (count = 7 && bit = 1)) {
bitAdd += 1;
}
count += 1;
}
非常感谢帮助。
//编辑 抱歉,pusdo 代码有点含糊。试图让它更简洁一些。
Trying to help a friend out with a friend out with some assembly code, but I've run into a small problem.
I'm trying to work out how I would loop through a 8 bit binary word and check the value of specific bits. I need to check bits 1, 3, 5 & 7 to see if they are 1.
i.e.
int count = 1;
int bitAdd = 0;
foreach (var bit in word) {
if ((count = 1 && bit = 1) || (count = 3 && bit = 1) || (count = 5 && bit = 1) || (count = 7 && bit = 1)) {
bitAdd += 1;
}
count += 1;
}
Help is much appreciated.
//Edit
Sorry, pusdo code was a bit ambiguous. Tried to make it a little more succinct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 BTST 指令在这里对您有用。
http://68k.hax.com/BTST
例如:
将检查值中是否为第 5 位在 d0 中设置。
(这适用于 68000,我不太确定 6800,谷歌搜索告诉我 BITA 或 BITB 指令可能有用:http://www.textfiles.com/programming/CARDS/6800 )
I think the BTST instruction will be of use to you here.
http://68k.hax.com/BTST
For example:
Will check if bit 5 in the value in d0 is set.
(This will work for the 68000, I'm not too sure about the 6800, googling tells me that BITA or BITB instructions might be of use: http://www.textfiles.com/programming/CARDS/6800 )