asm-test-nofralloc.c [plain text]
#include <stdio.h>
extern void abort();
asm int FibonacciAsm(register int n)
{
nofralloc
mflr r0
stw r31, -4(sp)
stw r30, -8(sp)
stw r29, -12(sp)
stw r0, 8(sp)
stwu sp, -80(sp)
cmpwi cr7, n, 1
ble cr7,LDone
mr r31, n
subi r3, r31, 1
bl FibonacciAsm
mr r30, r3
subi r3, r31, 2
bl FibonacciAsm
mr r29, r3
add r3, r29, r30
LDone:
addi sp, sp, 80
lwz r0, 8(sp)
lwz r29, -12(sp)
lwz r30, -8(sp)
lwz r31, -4(sp)
mtlr r0
blr
}
int main(int argc, char* argv[])
{
int x;
x = FibonacciAsm(12);
if (x != 144)
abort();
return 0;
}