+ 3

ARM assembly and C

i see in assembly file that generated by c++ compiler for ARM architecture: .save {r11, lr} push {r11, lr}//why r11? .setfp r11, sp mov r11, sp// I don't know why again?!! bl _Z4funcv// func() movw r0, #0//return 0 pop {r11,pc} //assign lr to pc and r11 to r11 then moves sp by +8 usually we use branch to LR and exchange to return subroutine . but in some functions it pushes LR (link register) and R11 to stack and and at the end of function pops them and assign LR to PC(program counter) to return program to return address and assign r11 to r11 again Why it tries to save the r11 value? and why it save lr in the stack then reassign it to pc? Is it possible for lr to lose its value when program call another function? i think "BL func" save pc to lr and that's because program pushes lr to stack. (to save its return addres) is my assumption correct? other questions are: what is movw ? i didn't find any flag as"w" in references. and i see in assembly words which begins with dot. what are those?

12th Sep 2021, 3:57 PM
Mehran
Mehran - avatar
2 Antworten
+ 1
Martin Taylor thanks. but you didn't answer completely. some questions remained unanswered
12th Sep 2021, 6:03 PM
Mehran
Mehran - avatar