Next: , Up: Registers


4.1 Register Clobbering

The B and X registers are assumed to be clobbered by any function calls, since return values and argument values may be placed there. Temporary values are never held in these registers across a function call; they will be moved to the stack or soft registers instead.

The Y and U registers are assumed to be preserved across a function call. Thus, if a function wants to use those registers, it will save/restore them. GCC does this in the prologue/epilogue for each function when it is necessary. The only exception is when a function has been tagged as naked, then this will not be performed.

If you are embedding assembly language inside C functions, or calling between C and assembly language functions, you should understand this behavior carefully. You cannot assume that a value in register D or X has the same value after making a function call. If you depend on the value of the CC or DP registers, you must deal with that explicitly, as GCC does not track them at all.