iPhone/ARM calling convention
on iPhone/ARM, which CPU registers are functions supposed to preserve, if any开发者_如何学C?
Old, but incorrect answer. Wikipedia is often inaccurate (sometimes downright incorrect), and this is an example of the former case. There is a generic calling convention (which is what Wikipedia documents), but OSes can deviate - both Android and iOS do (and likely Win 8 will, but we'll know that when the binaries start surfacing)
http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iPhoneOSABIReference/Introduction/Introduction.html provides the correct spec for iOS, so no sense in repeating here. Most notably, note the use of r7 and r12. Also note that ARMv6 and ARMv7 are different. By now, you want ARMv7 architectures (A4,5,6..)
Wikipedia's article on Calling Convention has a good summary of the conventions for ARM.
精彩评论