home *** CD-ROM | disk | FTP | other *** search
-
- Programming Example
-
- Copyright (c) 1992-1993, SAS Institute, Inc, Cary, NC USA
- All Rights Reserved
-
- The sources avg.c and avg2.a are programming examples on how to setup
- and call
-
- -- assembler routines from C
- -- AmigaDos routines from C
- -- library routines from assembler routines
- -- AmigaDos routines from assembler routines.
-
- In addition, there is an example of how to create an assembler routine that
- can be called with parameters passed on the stack as well as in registers.
- This feature allows you to have one routine that can be used whether you
- compile with 'parms=stack' or 'parms=register'. Also, you can create
- C language routines with this same dual nature by using the 'parms=both'
- option. This is in fact how the SAS/C link libraries are built.
-
- To build the program, compile and link the sources with the following
- command:
-
- sc avg.c avg2.a link
-
- to produce an executable named 'avg'. This program will accept numeric
- command line arguments and return for you the average of the numeric
- values. The program uses two assembler routines (avg() and prnts())
- to compute and print the average. avg() is the routine that is built
- to handle both stack and register parameters. prnts() is calls the
- AmigaDos Write() routine to write to the console. If no arguments are
- given, the program returns a usage message.
-
- Ex: 1> avg 1 2 3
- average = 2
-
- As with all our examples, feel free to experiment with different compilation
- options and startups. The sources themselves contain some hints about
- different things that you can try.
-
-