Inline assembler: register clobber
Hi, first of all: sorry for my bad english.
I have a arm1136 based SOC, and I'm playing with the inline assembler.
Please, look at the following code:
void function() {
asm volatile("mov r8, r0\n"
: : : "r8");
}
Due to ARM calling convention r8 must be saved before the asm statment and after it must be restored, right?
As expected, if I "objdump" this, r8 is saved/restored:
00000000 <function>:
0: e92d4100 push {r8, lr}
4: e1a08000 mov r8, r0
8: e8bd8100 pop {r8, pc}
But if I compile this code in thumb mode (-mthumb), r8 doesn't get saved/restored:
00000000 <function>:
0: 4680 mov r8, r0
2: 4770 bx lr
I can't undestand this, r8 should be saved/restored in thumb mode too, where am I wrong?
This is the output of "arm-none-eabi-gcc -v":
Using built-in specs.
COLLECT_
COLLECT_
Target: arm-none-eabi
Configured with: ../gcc-
Thread model: single
gcc version 4.8.3 20140820 (release) (4.8.3-9+11)
I'm in debian testing (jessie)
Thanks in advance for your help.
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Thomas Preud'homme
- Solved:
- Last query:
- Last reply: