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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...