home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_11 / 9n11068b < prev    next >
Text File  |  1991-08-29  |  912b  |  31 lines

  1.  
  2. Listing 2:
  3.  
  4.  
  5. #       compiled using cc -O -S fib.c
  6. _fib:
  7.         link    a6,#-8           # set local frame pointer
  8.         cmpl    #2,a6@(8)        # determine if n<2
  9.         jgt     L20
  10.         moveq   #1,d0            # return 1 in d0
  11.         jra     LE18
  12. L20:
  13.         movl    a6@(8),d0        # copy in-coming parameter from stack
  14.         subql   #2,d0
  15.         movl    d0,sp@-          # stack out-going parameter n-2
  16.         jbsr    _fib
  17.         addqw   #4,sp
  18.         movl    d0,a6@(-8)       # copy fib(n-2) result to memory
  19.         movl    a6@(8),d0        # copy in-coming parameter from stack
  20.         subql   #1,d0
  21.         movl    d0,sp@-          # stack out-going parameter n-1
  22.         jbsr    _fib
  23.         addqw   #4,sp
  24.         addl    a6@(-8),d0       # add fib(n-2) and fib(n-1)
  25.         movl    d0,a6@(-4)       #  result in d0
  26. LE18:
  27.         unlk    a6
  28.         rts
  29.  
  30.  
  31.