2.1.1,
3.
Push {LR, r4} creates context
4.
POP {LR,R4} restores context
BX lr returns from function
r0, as we can see with line 0x08000348, which is ADDS r0,r0#1, and then our conditional cmp r0, # 0x0a
MULS r2,r0,r2:
The line before loaded the value 2000 (0x07D0) into r2 to be multiplied by.
the paramater passed in is stored as r0
If list[i]==key then it immediately sends you to address 0x08000318, which is a BX command that sets the PC to the value of LR, and restores context, otherwise, if not found, we load in 0xFFFFFFFF into r0 and run the BX line anyway, which means that r0 is the variable that stores the return value no matter what
r1 stores key
three lines:
ADDS r0,r0,#1CMP r0, #0x0ABCC 0x08000306
So we add 1 to r0 (i), then we compare r0 to the value 10 (0A), and if it is less than 10, then we jump back to the address 0x08000306
main 0x0900033d 34
list_init 0x08000305 48
list_find 0x080002e5 26
list 0x20000000 40
offset 0x08000368 40
list has moved to the old position of data that held offset offset is now in an address much closer to main etc.. which means main, list_init, list_find have all had the address positions moved in some way
before const
Code - 122
inc,data 14
RO - 0
RW - 40
ZI - 40
debug = 3489
main.o
after const.
code - 122
data -14
RO -40
RW-0
ZI-40
debug 3493
main.o
RO, read only now is logically 40, and RW is no longer 40 as it is now const. debug also appears to have changed for some reason