Search code examples
assemblyarmthumb

Assembly code meaning in memory disassembly view


What is the meaning of the following assembly instructions set:

flashEraseSector:
00005f24:   push    {r7, lr}
00005f26:   sub     sp, #24
00005f28:   add     r7, sp, #0
00005f2a:   str     r0, [r7, #4]
 17                   temp1 = (locat << 8);
00005f2c:   ldr     r3, [r7, #4]
00005f2e:   lsls    r3, r3, #8
00005f30:   str     r3, [r7, #20]
 18                   temp1 = temp1 >> 24;
00005f32:   ldr     r3, [r7, #20]
00005f34:   asrs    r3, r3, #24
00005f36:   str     r3, [r7, #20]
 19                   temp2 = (locat << 16);
00005f38:   ldr     r3, [r7, #4]
00005f3a:   lsls    r3, r3, #16
00005f3c:   str     r3, [r7, #16]
 20                   temp2 = temp2 >> 24;
00005f3e:   ldr     r3, [r7, #16]
00005f40:   asrs    r3, r3, #24
00005f42:   str     r3, [r7, #16]
 21                   temp3 = (locat << 24);

Here is my c code which has been compiled and

        temp1 = (locat << 8);
        temp1 = temp1 >> 24;
        temp2 = (locat << 16);
        temp2 = temp2 >> 24;
        temp3 = (locat << 24);
        temp3 = temp3 >> 24;

It would be great if someone explains what is happening here. Why are these storing 20,20,16,16? They have to store -4,4,12,20 right?

00005f30:   str     r3, [r7, #20]
00005f36:   str     r3, [r7, #20]
00005f3c:   str     r3, [r7, #16]
00005f42:   str     r3, [r7, #16]

Thanks in advance.


Solution

  • 0x00000800 is the address of the function flashLocat. Next, the first column represents the address in the memory where the instruction is, the second column represents the instrucion and the third the arguments. Anything after ";" represents a comment.