
Listing 2:


#       compiled using cc -O -S fib.c
_fib:
        link    a6,#-8           # set local frame pointer
        cmpl    #2,a6@(8)        # determine if n<2
        jgt     L20
        moveq   #1,d0            # return 1 in d0
        jra     LE18
L20:
        movl    a6@(8),d0        # copy in-coming parameter from stack
        subql   #2,d0
        movl    d0,sp@-          # stack out-going parameter n-2
        jbsr    _fib
        addqw   #4,sp
        movl    d0,a6@(-8)       # copy fib(n-2) result to memory
        movl    a6@(8),d0        # copy in-coming parameter from stack
        subql   #1,d0
        movl    d0,sp@-          # stack out-going parameter n-1
        jbsr    _fib
        addqw   #4,sp
        addl    a6@(-8),d0       # add fib(n-2) and fib(n-1)
        movl    d0,a6@(-4)       #  result in d0
LE18:
        unlk    a6
        rts


