home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 338_01 / cc68k.doc < prev    next >
Text File  |  1990-09-25  |  7KB  |  257 lines

  1. Central Institute of Technology, Wellington, New Zealand                                                    Page 68000 C compiler
  2. Copyright 1984, 1985, 1986 Matthew Brandt.
  3. All commercial rights reserved.
  4.  
  5. Modified for MSDOS and compatibility with the AS68 Assembler
  6. by Brian Brown, Central Institute of Technology, Heretaunga, New Zealand,
  7. Nov 1989
  8.  
  9.  
  10. This compiler is an optimizing C compiler for the Motorola 68000 processor. It
  11. has successfully compiled itself on UNIX system V running on a Motorola VME
  12. 10. Since this code was written for a machine with long integers it may
  13. exhibit some irregularity when dealing with long integers on the IBM-PC. The
  14. author makes no guarantees. This is not meant as a serious developement tool
  15. although it could, with little work, be made into one.
  16.  
  17. This compiler is intended as an instructive tool for personal use. Any use for
  18. profit without the written consent of the author is prohibited. This compiler
  19. may be distributed freely for non-commercial use as long as this notice stays
  20. intact. Please forward any enhancements or questions to:
  21.  
  22.       Matthew Brandt
  23.       Box 920337
  24.       Norcross, Ga 30092
  25.  
  26.  
  27. LIMITATIONS
  28.    - Although you may declare floating point types the code generator
  29.      does not know how to deal with them. They should therefore be
  30.      avoided.
  31.    - The preprocessor does not support arguments to #define'd macros
  32.      or any of #line #ifdef... etc. Only #include and #define are
  33.      supported.
  34.    - Function arguments declared as char may not work properly.
  35.      Declare them as int.
  36.    - The size of functions is slightly limited due to the fact that
  37.      the entire function is parsed before any code is generated.
  38.    - The output of the compiler is in the UNIX 68000 assembler format.
  39.      Nov 1989: Modified to be AS68 Compatible!
  40.    - There is no standard runtime library support.
  41.  
  42. If you wish to make commercial use of all or part of this package please
  43. contact me at the above address or (404)662-0366. Any voluntary contribution
  44. from non-commercial users will be greatly appreciated but is by no means
  45. necessary. enjoy...
  46.  
  47. Matt Brandt
  48.  
  49. DATA TYPES
  50. The data types supported are,
  51.         char
  52.         char *
  53.         char array[]
  54.         char array[][]
  55.         double
  56.         enum
  57.         float
  58.         int
  59.         int *
  60.         int array[]
  61.         int array[][]
  62.         int (*funcptr)()
  63.         long
  64.         short
  65.         struct
  66.         union
  67.         unsigned
  68.  
  69.  
  70.  
  71. STORAGE CLASSES
  72.         automatic
  73.         extern
  74.         register
  75.         static
  76.         typedef
  77.  
  78.         examples,
  79.                 auto int test;
  80.                 extern int sum;
  81.                 register int quick;
  82.                 static char *msg = "Hello and Welcome.";
  83.  
  84.         DO NOT USE CLASS static OR auto INSIDE A FUNCTION.
  85.  
  86.  
  87.  
  88. UNARY INTEGER OPEARTIONS
  89.         -       minus
  90.         *       indirection
  91.         &       address of
  92.         ++      increment
  93.         --      decrement
  94. ~        7E     1's complement
  95.         !       not
  96.  
  97.  
  98. BINARY INTEGER OPERATIONS
  99.         +       addition
  100.         -       subtraction
  101.         *       multiplication
  102.         /       division
  103.         |       inclusive or
  104.         ^       exclusive or
  105.         &       logical and
  106.         ==      equal
  107.         !=      not equal
  108.         <       less than
  109.         <=      lass than or equal
  110.         >       greater than
  111.         >=      greater than or equal
  112.         <<      left shift
  113.         >>      right shift
  114.  
  115.  
  116.  
  117. LOGICAL OPERATORS
  118.         &&      logical and
  119.         ||      logical or
  120.  
  121.  
  122.  
  123. CONDITIONAL OPERATOR
  124.         ? : ;
  125.  
  126.  
  127.  
  128. ASSIGNMENT OPERATORS
  129.          =
  130.         +=
  131.         -=
  132.         /=
  133.         *=
  134.         %=
  135.         <<=
  136.         >>=
  137.         |=
  138.  
  139.         COMPILER FAILS ON ^=
  140.  
  141.  
  142. PROGRAM CONTROL
  143.         if( expression ) statement;
  144.         if( expression ) statement; else statement
  145.         while( expression ) statement;
  146.         for( expr1; expr2; expr3 ) statement;
  147.         switch( expression ) statement;
  148.         case constant: expression;
  149.         default: expression;
  150.         break;
  151.         continue:
  152.         return
  153.         return expression
  154.         ;       /*null statement*/
  155.         {statement; statement; ... ; statement}
  156.         goto label
  157.         label:
  158.         (*functionpointer)();
  159.  
  160.  
  161. PROBLEMS:
  162.         do { } while(condition);
  163.         while( constant ) {   }
  164.         for( expr, expr ; expr, expr ; expr, expr ) {  }
  165.         ^=
  166.         auto int                /*inside a function*/
  167.  
  168.  
  169.  
  170.  
  171. VARIABLE DECLARATIONS
  172. Global variables may be type static or auto. Local variables inside functions
  173. are not preceeded by a storage class.
  174.  
  175.         examples,
  176.                 extern int   eint;
  177.                 long         lint;
  178.                 register int rint;
  179.                 short        sint;
  180.                 static char *msg = "Hello";
  181.                 static enum color hue = green;
  182.                 static int (*oldintptr)() = &swap;
  183.                 struct table mytable[10];
  184.                 union test { float f; char c; int i; } mytest;
  185.                 unsigned int uint;
  186.  
  187.  
  188. COMPILER RESERVED KEYWORDS
  189.         define          auto            break
  190.         else            char            case
  191.         endif           double          continue
  192.         ifdef           enum            default
  193.         ifndef          extern          do
  194.         include         float           else
  195.                         int             for
  196.                         long            goto
  197.                         typedef         if
  198.                         register        switch
  199.                         short           return
  200.                         sizeof          while
  201.                         static
  202.                         struct
  203.                         union
  204.                         unsigned
  205.                         void
  206.  
  207.  
  208.  
  209. COMMAND LINE OPTIONS
  210. When the compiler is run, it reads one C source file and produces an assembly
  211. language output file. The format of the compiler command line is:
  212.  
  213.                 cc68k  [-options]  input_file.c
  214.  
  215. The only option is -e, which echoes the compiler list file to the console
  216. screen.
  217.  
  218.  
  219. The compiler generates two output files,
  220.  
  221.                 input_file.ASM  assembler code
  222.                 input_file.LST  list file
  223.  
  224.  
  225.  
  226. LIBRARY FILES
  227. The compiler incorporates its own routines to handle switch and long multiply
  228. routines. These are included at the end of the assembler and list files.
  229.  
  230.  
  231. SAMPLE COMPILATION
  232.  
  233.                 cc68k test.c
  234.  
  235. This line causes the compiler to compile the input file test.c and write the
  236. generated code to the output file test.asm. Any errors are displayed on the
  237. screen, and also appear in the list file.
  238.  
  239. Control C will abort the compiler.
  240.  
  241.  
  242. Assembling
  243.  
  244.                 as68 test lf ef
  245.  
  246. This command causes the file test.asm to be assembled, generating a .ls file
  247. (list) and a .S19 file (motorola S record). The .S19 file is downloaded to a
  248. target system for operation.
  249.  
  250.  
  251.  
  252. OPTIMIZATION
  253. The compiler uses both intermediate and peephole optimization, this generates
  254. very effecient code. The code output routines have been heavily modified to
  255. allow operation with the AS68 assembler.
  256.  
  257. «MDBO»