4 ms·
It's history, mostly. The very first Arm design didn't do anything special with r13 and r14, so using them as sp and lr was purely convention (you could have an
by pm215 4y ago
It's history, mostly. The very first Arm design didn't do anything special with r13 and r14, so using them as sp and lr was purely convention (you could have an upward growing stack in r0 if you wanted). The years roll by, and it turns out that in fact everybody follows the conventions, so it makes sense with cleverer hardware to optimise for r13-is-sp, and it's a reasonable tradeoff with Thumb to enforce r13-is-sp in return for being able to make the instructions smaller and save code size. The technical constraints and situation of 1983 are not the same as those of 2003 or 2023.
- fanf2 4y agoThere was always one instruction that made r14 special: BL, branch with link. Both r13 and r14 are special for exception handling and SWI instructions, because they have extra versions in the register banks, specifically for the supervisor mode stack pointer and exception return address.
- pm215 4y agoOh yes, good points.