默认的情况下,这些寄存器只是叫做r0,r1,...,r14等,而APCS 对其起了不同的别名。
使用汇编器预处理器的功能,你可以定义 R0 等名字,但在你修改其他人写的代码的时候,最好还是学习使用 APCS 名字。
一般编程过程中,最好按照其约定,使用对应的名字,这样使得程序可读性更好。
关于不同寄存器所对应的名字,见下表:
表 3.2. ARM寄存器的别名
寄存器名字 | ||
---|---|---|
Reg# | APCS | 意义 |
R0 | a1 | 工作寄存器 |
R1 | a2 | " |
R2 | a3 | " |
R3 | a4 | " |
R4 | v1 | 必须保护 |
R5 | v2 | " |
R6 | v3 | " |
R7 | v4 | " |
R8 | v5 | " |
R9 | v6 | " |
R10 | sl | 栈限制 |
R11 | fp | 桢指针 |
R12 | ip | 内部过程调用寄存器 |
R13 | sp | 栈指针 |
R14 | lr | 连接寄存器 |
R15 | pc | 程序计数器 |
更加详细一点,见下:
The following register names are predeclared:
- r0-r15 and R0-R15
- a1-a4 (argument, result, or scratch registers, synonyms for r0 to r3)
- v1-v8 (variable registers, r4 to r11)
- sb and SB (static base, r9)
- ip and IP (intra-procedure-call scratch register, r12)
- sp and SP (stack pointer, r13)
- lr and LR (link register, r14)
- pc and PC (program counter, r15).
Predeclared extension register names
The following extension register names are predeclared:
- d0-d31 and D0-D31(VFP double-precision registers)
- s0-s31 and S0-S31(VFP single-precision registers)
The following coprocessor names and coprocessor register names are predeclared:
- p0-p15 (coprocessors 0-15)
- c0-c15 (coprocessor registers 0-15).