home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / examples / avg / READ.ME < prev    next >
Encoding:
Text File  |  1996-12-24  |  1.6 KB  |  42 lines

  1.  
  2.     Programming Example
  3.  
  4.     Copyright (c) 1992-1993, SAS Institute, Inc, Cary, NC USA
  5.     All Rights Reserved
  6.  
  7.       The sources avg.c and avg2.a are programming examples on how to setup 
  8.    and call
  9.    
  10.       -- assembler routines from C
  11.       -- AmigaDos routines from C
  12.       -- library routines from assembler routines
  13.       -- AmigaDos routines from assembler routines.
  14.      
  15.    In addition, there is an example of how to create an assembler routine that
  16.    can be called with parameters passed on the stack as well as in registers.
  17.    This feature allows you to have one routine that can be used whether you
  18.    compile with 'parms=stack' or 'parms=register'.   Also, you can create
  19.    C language routines with this same dual nature by using the 'parms=both'
  20.    option.  This is in fact how the SAS/C link libraries are built.
  21.  
  22.    To build the program, compile and link the sources with the following
  23.    command:
  24.    
  25.       sc avg.c avg2.a link
  26.  
  27.    to produce an executable named 'avg'.  This program will accept numeric
  28.    command line arguments and return for you the average of the numeric
  29.    values.  The program uses two assembler routines (avg() and prnts())
  30.    to compute and print the average.   avg() is the routine that is built
  31.    to handle both stack and register parameters.  prnts() is calls the
  32.    AmigaDos Write() routine to write to the console.  If no arguments are
  33.    given, the program returns a usage message.
  34.    
  35.    Ex: 1> avg 1 2 3
  36.        average = 2
  37.        
  38.    As with all our examples, feel free to experiment with different compilation
  39.    options and startups.  The sources themselves contain some hints about
  40.    different things that you can try.
  41.    
  42.