Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在汇编 Sparc 中使用按位运算检查地址是否为 8 的倍数?
那么在C中你需要做这样的事情:
is_multiple_of_8 = (addr & (8 - 1)) == 0;
因此,只需将其转换为 asm,手动或让编译器帮助您(例如gcc -S)。它实际上应该最多只有 2 或 3 条指令:您只需要将地址与 7 相加,然后测试为零。
gcc -S