Armv8 Assembly cmp 在运行时冻结

问题描述

我已经在这里发布了类似的代码,但现在我的问题有所不同。 出于某种原因,如果我尝试将 x3 与 x4 进行比较,应用程序在运行时会冻结,但如果我将 x3 与 x2 进行比较,它就可以正常工作并返回 x4 上的内容 (43520/1010101000000000)

我无法理解正在发生的事情,比较 x2 和 x4 应该没有太大区别。一定有一些我遗漏的东西(可能很简单)。 也许我在处理寄存器内存时做错了什么? 那是什么,在应用 and x4,x2,x5 指令并保存在 x4 上之后,使它与 x2 不同?据我所知,唯一的区别应该是高位,如果有的话。

   ASM_FUNC(REV16)
    
      ldr    x1,=oneHundredSeventy//Loads the memory address of "oneHundredSeventy" 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
      mov    x5,#4294967295       //filter 0b0000000000000000000000000000000011111111111111111111111111111111
        
      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
    
      and    x4,x5             //Eliminates the upper bits on the x2 register
     
      cmp    x3,x4                //Compares the value of x4 and x3  
      b.ne   Neon_rev16_error     //if different,go to test_error
      b      Neon_rev16_end       //if equal,go to test_end
        
    Neon_rev16_error:
      mov    x0,x4                //Loads the value on x4 to the return register (x0)
      ret
    
Neon_rev16_end:
  mov    x0,#0                //Loads the value #6 to the regurn register (x0

这是调用它的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;
}
 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱: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...