Download E500ABIUG: PowerPC e500 Application Binary Interface User's Guide
Transcript
Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Coding Examples C code Assembly code extern int src; extern int dst; extern int *ptr; .extern src .extern dst .extern ptr dst = src; addis lwz addis stw r6,r0,src@ha r0,src@1(r6) r7,r0,dst@ha r0,dst@1(r7) ptr = &dst; addis addi addis stw r6,r0,dst@ha r0,r6,dst@1 r7,r0,ptr@ha r0,ptr@1(r7) *ptr = src; addis lwz addis lwz stw r6,r0,src@ha r0,src@1(r6) r7,r0,ptr@ha r7,ptr@1(r7) r0,0(r7) Figure 2-36. Absolute Load and Store NOTE In the examples that follow, the assembly syntax symbol@got refers to the offset in the global offset table at which the value of symbol (that is, the address of the variable whose name is symbol) is stored, assuming that the offset is no larger than 16 bits. The syntax symbol@got@ha, symbol@got@h, and symbol@got@l refer to the high-adjusted, high, and low parts of that offset, when the offset may be greater than 16 bits. Figure 2-37 shows small model position-independent load and store operations. C code Assembly code extern int src; extern int dst; extern int *ptr; .extern src .extern dst .extern ptr .text # Assumes GOT pointer in r31 dst = src; lwz lwz lwz stw r6,src@got(r31) r7,dst@got(r31) r0,0(r6) r0,0(r7) ptr = &dst; lwz lwz stw r0,dst@got(r31) r7,ptr@got(r31) r0,0(r7) *ptr = src; lwz lwz lwz lwz stw r6,src@got(r31) r7,ptr@got(r31) r0,0(r6) r7,0(r7) r0,0(r7) Figure 2-37. Small Model Position-Independent Load and Store Figure 2-38 shows large model position-independent load and store operations. Chapter 2. Low-Level System Information For More Information On This Product, Go to: www.freescale.com