简体   繁体   中英

Store instruction in NEON armv8 assembly

I am learning how to program in armv8 assembly using neon. This code compiles, but it freezes at running time.

The first part is where the variables are created (array1), the second part (Main) is where the code starts, like the entrypoint.

.data
array1: .word 30,70

ASM_FUNC(TEST)
.text

Main:
  mov x0,#11

  ldr x2,=array1  
  
  LD1 {V0.2D}, [x2] 

  ST1  {V0.2D}, [x0], #16
  

  ret

This is the C code that calls it

int TEST();

int main(void)
{
  printf("========== ASM Started ==========\n");
  long int ff = TEST();
  printf("=========== ASM has finished successfully ===========\n");
  return 0;
}

You see... it prints the "ASM Started" but never gets to "Asm has finished". When I coment the ST1 {V0.2D}, [x0], #16 it works just fine, but of course, the code is not doing what I need it to do. So, my question is: What did I do wrong in this line of code? Did I allocate my vector in the wrong way? Did I use the wrong offset?

This code compiles the lower the level of language that you work with, the less relevant that statement is. When you program in machine code, the assembler translates your symbolic code into a binary form of the same; it is not a compiler, and any error checking that it provides is for its sake not yours!

Your assembly source can be contracted into:

  mov x0,#11
  ST1  {V0.2D}, [x0], #16

which as others mention in comments, is attempting to store at address 11 (0xb), which is both unaligned, and likely unmapped because addresses close to zero are likely unmapped to help you find your bugs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM