|Informative Information for the Uninformed
Unlike the IA32 platform, PowerPC does not have a call or jmp instruction. Execution flow is controlled by one of the many branch instructions. A branch can redirect execution to a relative address, absolute address, or the value stored in either the link or count registers. Conditional branches are performed based on one of four bit fields in the condition register. The count register can also be used as a condition for branching and some instructions will automatically decrement the count register. A branch instruction can automatically set the link register to be the address following the branch, which is a very simple way to get the absolute address of any relative location in memory.
;; ;; Demonstrate GetPC() through a branch and link instruction ;; main: xor. r5, r5, r5 ; xor r5 with r5, storing the value in r5 ; the condition register is updated by the . modifier ppcGetPC: bnel ppcGetPC ; branch if condition is not-equal, which will be false ; the address of ppcGetPC+4 is now in the link register mflr r5 ; move the link register to r5, which points back here