1: /	example of UNIX fortran
   2: /	calling interface to machine code
   3: /	this example is a function that
   4: /	returns the single precision
   5: /	sum of all of its single precision arguments.
   6: /	for example:
   7: /		f = sum(1.,2.,3.)
   8: /	sets f to 6.
   9: 
  10: .globl  sum.                            / defination of entry
  11: .globl  retrn                           / reference of return
  12: 
  13: sum.:                                   / entry point
  14:         value                           / location of return value
  15:         .+2                             / pointer to execution code
  16:         setf                            / no d/f i/l modes guaranteed
  17:         mov     *2(sp),r0               / arg count
  18:         mov     r3,r1                   / r3 points to arg list
  19:         tst     (r1)+                   / zeroth arg is old r3
  20: 
  21:         clrf    fr0                     / start of actual function
  22: 1:
  23:         addf    *(r1)+,fr0              / add in each argument
  24:         sob     r0,1b                   / for each argument
  25: 
  26:         movf    fr0,value               / make returned value available
  27:         jmp     retrn                   / actual return
  28: 
  29: .bss
  30: value:  .=.+4                           / space for return value
  31: 
  32: / synopsis:
  33: /	1. save registers r3, sp
  34: /	2. arg list (pointers to values)
  35: /	   begins at 2(r3)
  36: /	3. entry name is name of function
  37: /	   followed by "."
  38: /	4. first word after entry point is
  39: /	   location of return value. this is
  40: /	   true for both functions and subroutines
  41: /	5. second word after entry point is
  42: /	   pointer to pdp-11 code body
  43: /	6. return is expedited by a jump to
  44: /	   the globl routine "retrn"

Defined functions

sum. declared in line 10; defined in line 13; used 1 times
  • in line 10

Defined variables

value defined in line 30; used 2 times
Last modified: 1975-07-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 450
Valid CSS Valid XHTML 1.0 Strict