Download E500ABIUG: PowerPC e500 Application Binary Interface User's Guide
Transcript
Freescale Semiconductor, Inc. Coding Examples For example, assume a stack frame as described in Figure 2-25, with the back chain word at address 0x400, and where the CR does not need to be saved. To save only 32-bit values, r11 should contain 0x400 on entry to the 32-bit register save routine. To save only 64-bit values, r11 should contain 0x400 - 0x90 = 0x370. Figure 2-32 shows an example of saving some 32-bit and some 64-bit values. Figure 2-32 shows the standard stack frame. Address Freescale Semiconductor, Inc... r11 points here for 32-bit call --> SP ---> r11 points to 0x388 for 64-bit call --> 0x400 0x3FC 0x3F8 ... 0x3E8 0x3E4 0x3E0 0x3DC 0x3D8 ... 0x3AC 0x3A8 0x3A4 Description Back chain r31 word r30 word ... r26 word r25 double word r24 double word ... r18 double word Local variable space Parameter save area,if any LR save area, if any Back chain ... ... 0x388 Figure 2-32. Standard Stack Frame To save r26–r31 as 32-bit values, as shown in the stack frame in Figure 2-32, and r18–r25 as 64-bit values, r11 should contain 0x400 (address of the back chain word) on entry to the appropriate 32-bit save routine (_save32gpr_26), and then be adjusted to contain 1000 - 8*25 + 104 = 904 (0x3e8 - 8 * 25 + 0x68 = 0x388) in preparation for the call to the 64-bit save routine (_save64gpr_ctr_18). r25 will be stored at 0x388+0x58 = byte 0x3e0, which is the double word directly preceding the 32-bit save area. Note that the r11 pointer for the 64-bit call does not necessarily point to any particularly meaningful location directly; it points to an address such that the fixed offsets make the register saves and restores line up appropriately. (In fact, r11 points to where r14 would be stored if it needed saving.) 2.7.3.3 Details about the Functions Each function described in this section is a family of 18 functions with identical behavior except for the number and kind of register affected. The function names below use the notation [32/64] to designate the use of a 32 for the 32-bit general register functions and a 64 for the 64-bit general register functions. The suffix ‘_m’ designates the portion of the name that would be replaced by the first register to be saved. That is, to save registers 18 through 31, one should call _save32gpr_18. Figure 2-33 shows an example implementation. Chapter 2. Low-Level System Information For More Information On This Product, Go to: www.freescale.com