如何解决REV16 ARMV8 汇编指令
所以,伙计们。我正在编写一个简单的代码来测试 armv8 程序集上的 REV16 指令。 这是我的代码
.data //Indicates that this section initiates the variables
oneHundredSeven: .word 170
.bss
empty_variable: .space 64
.text //Indicates the code section starts here
ASM_FUNC(REV16) //this is the entrypoint
ldr x1,=oneHundredSeven //Loads the memory address of "oneHundredSeven" variable into the x1 register
ldr x2,=empty_variable //Loads the memory address of "empty_variable" variable into the x2 register
mov x3,#43520 //Moves the expected result to x3
LD1 {V0.16B},[x1] //Loads the value from the memory address saved on x1 to the V0 neon register
REV16 V1.16B,V0.16B //Reverts the bits on the V0 neon register and saves on the V1 neon register
//This instruction splits the 128-bit V1 register into eight 16-bit containers
//divided into two sub containers of 8-bits
MOV x2,V1.D[0] //Set x2 to the value of the first double word in V0
cmp x2,x3 //Compares the value of x2 and x3
b.ne Neon_rev16_error //if different,go to test_erro
b Neon_rev16_end //if equal,go to test_end
Neon_rev16_error:
mov x0,x2 //Loads the value on x2 to the return register (x0)
ret
Neon_rev16_end:
mov x0,#0 //Loads the value #6 to the regurn register (x0)
ret
这是调用它的C代码
int main(void)
{
long int fff = REV16(); //it calls the function in assembly,starts the entry point
print(f"REV16 %lu \n",fff);
return 0;
}
所以,首先我使用了 mov x4,x2
,但它会Neon_rev16_error:
标记并返回预期结果 (43520),这是一个问题。如果它返回了预期的结果,为什么它会变成 Neon_rev16_error:
?比我意识到它可能正在移动 x4 上的内存地址,而不是它的值。出于这个原因,我改为 ldr x4,[x2]
,但在这种情况下,我的应用程序只是冻结。
你们知道我可以做些什么来使我的代码正常工作吗? 提前非常感谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。