Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

neon - REV16 ARMV8 assembly Instruction

So, guys. I am making a simple code just to test the REV16 instruction on armv8 assembly. This is my code

      .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

This is the C code that calls it

int main(void)
{
  long int fff = REV16(); //it calls the function in assembly, starts the entry point
  print(f"REV16 %lu 
",fff);

 return 0;
}
 

So, firstly I used mov x4,x2, but it was going to Neon_rev16_error:label and returning the expected result (43520) and that was a problem. If it is returning the expected result, why is it going to Neon_rev16_error:? Than I realized it was probably moving the memory address sabed on x4, not the value on that. For that reason I changed to ldr x4,[x2] but in this case, my application just freezes.

Do you guys have any idea of what I can do to make my code properly work? Thanks a lot in advance


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...