嘿,我对 RISC-V 还算陌生。
我的练习题之一是:
将 0x0000000000000123 的值右移 4 位。预期结果为 0x3000000000000012,即所有十六进制数字向右移动一位,而最右边的一位移动到前面*
到目前为止,我了解了一些关于逻辑运算的知识:andi, or, and xori
。在我之前的练习中我学到了add, addi, sub, slli, srli, srai
.
我从以下开始:
addi x6, 0x, 0x123
然而,我被困在这里了。我的教科书并没有真正正确地描述事物,所以非常感谢任何帮助!
这就是我最终所做的:
addi x30, x0, 0x123
andi x29, x30, 0x00f //masking all, but the right most hexadecimal digit
slli x6, x29, 60 //shifting this digit all the way to the left (rotating)
srli x7, x30, 4 //shifting the original value 4 bits right
add x5, x6, x7 //adding the two regs
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)