Function-Level Inline Assembly

The compiler accepts function definitions that are composed entirely of assembly statements. Function-level assembly code uses this syntax:

asm function-definition

A function that uses function-level assembly must end with a blr instruction.

Listing 1. Example Assembly Language Function
asm void mystrcpy(char *tostr, char *fromstr)

{
    addi  tostr,tostr,-1
    addi  fromstr,fromstr,-1
@1  lbzu  r5,1(fromstr)
    cmpwi r5,0
    stbu  r5,1(tostr)
    bne   @1
  blr
}