Search code examples
assemblyarmstack-memoryaddressing-mode

difference between ldmia.w sp, {r1, r2} and ldmia.w sp!, {r1, r2}?


I am working in a binary analysis project and I came across two different variants of ldmia arm assembly instruction.

ldmia.w sp, {r1, r2}

ldmia.w sp!, {r1, r2}

I know ldmia.w sp!, {r1, r2} is a synonym to pop {r1,r2}. but what about ldmia.w sp, {r1, r2}? . Am I using the value stored in sp as a memory address to load from into r1 and r2 which doesn't make much sense to me or am I poping from the stack without updating the value of the sp which also doesn't make sense.


Solution

  • Refer to the ARM Architecture Reference Manual for the meaning of the various parts of the ARM assembly language. The ! sign denotes that the new address is written back to the register. I.e. ldmia.w sp!, {r1, r2} adds 8 to sp but ldmia.w sp, {r1, r2} leaves sp unchanged.