0

I am new to linux GDB, and I have a questions on Aarch64 assembly:

On my assembler dump, there are the following lines:

0x0000005555555788 <+36>: str w0, [sp, #24]

0x000000555555578c <+40>: ldr w1, [sp, #24]

I know what LDR and STR means, and that w0, w1 represents registers,

But I would like to know the [sp, #24] part. What does sp and #24 mean?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Cyh1368
  • 239
  • 3
  • 10
  • 2
    It's an addressing mode involving SP, the stack pointer. Read the vendor-supplied manual or any tutorial for the basics, e.g. this one on arm.com: https://developer.arm.com/documentation/102374/0101/Loads-and-stores---addressing covers AArch64 addressing-modes. See also [ARM AArch64 stack management](https://stackoverflow.com/q/31346886) and [understanding aarch64 assembly function call, how is stack operated](https://stackoverflow.com/q/66098678), although neither of those are duplicates. – Peter Cordes Jun 04 '21 at 05:31
  • @PeterCordes The ARM documentation helped a lot. Thanks! – Cyh1368 Jun 04 '21 at 06:10

1 Answers1

1

str w0, [sp, #24] means "store w0 at the address sp+24".

ldr w1, [sp, #24] means "load w1 from the address sp+24".

These are both using the "base plus offset" syntax explained in section C1.3.3 of the Architecture Reference Manual.

apt1002
  • 969
  • 6
  • 15