最近在学习arm体系架构,先简单了解一下APCS。
什么是APCS?http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf
具体的概念随后理解下,先提供一个汇编和反汇编的方法,以供实验。之后会详细写APCS的东西。
获取arm gnu工具链之后,我们写一个简单的c代码。
int func0(int x)
{
return x++;
}
void main()
{
int x = 9;
x = func0(x);
}
然后执行: arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb hello.c -nostartfiles -o hello.o
这时会生成hello.o,我们再反汇编一下:
arm-none-eabi-objdump -S hello.o > hello.s
hello.s:
hello.o: file format elf32-littlearm
Disassembly of section .text:
00008000 <func0>:
8000: b480 push {r7}
8002: b083 sub sp, #12
8004: af00 add r7, sp, #0
8006: