Neon instruction in ARM fails


Gabriel Carvalho de Faria
 

Greetings!
 

We are trying to implement an .efi application that validates some ARM architecture instructions.

 
For this application, an assembly code was created, with the help of AsmMacroIoLibV8, present in edk2. The implementation can be seen below.

#include <AsmMacroIoLibV8.h>
 
.data
 
OneHundredSeventy: .word 0b0000000010101010
 
Filter32bit: .word 4294967295
 
.bss
 
EmptyVar: .space 64
 
.text
 
ASM_FUNC(SQXTNInstruction)
 
  ldr       x1,=OneHundredSeventy
  ldr       x2,=EmptyVar
  mov    x3,#2147483647
  mov    x5,Filter32bit       // The error happens here
 
  LD1        {V0.16B},[x1]
  SQXTN   V1.2S, V0.2D
  MOV      x2,V1.D[0]
 
  and     x4,x2,x5
 
  cmp    x3,x4
  b.ne    Error
  b         End
 
Error:
  mov x0,x4
  ret
End:
  mov x0,#0
  ret
 
When using the value defined for Filter32bit, as it is in the code, the return of this instruction is 1 (error). However, when directly loading the hardcoded value into register x5, the return is 0 (success).
 

This behavior happened on a machine with a Snapdragon(TM) 8cx @ 2.84 GHz - QUALCOMM processor.

 
We would like to know if there is any bug in the implementation or if there is an explanation for this behavior.

Best regards!
Gabriel.