home *** CD-ROM | disk | FTP | other *** search
- Central Institute of Technology, Wellington, New Zealand Page 68000 C compiler
- Copyright 1984, 1985, 1986 Matthew Brandt.
- All commercial rights reserved.
-
- Modified for MSDOS and compatibility with the AS68 Assembler
- by Brian Brown, Central Institute of Technology, Heretaunga, New Zealand,
- Nov 1989
-
-
- This compiler is an optimizing C compiler for the Motorola 68000 processor. It
- has successfully compiled itself on UNIX system V running on a Motorola VME
- 10. Since this code was written for a machine with long integers it may
- exhibit some irregularity when dealing with long integers on the IBM-PC. The
- author makes no guarantees. This is not meant as a serious developement tool
- although it could, with little work, be made into one.
-
- This compiler is intended as an instructive tool for personal use. Any use for
- profit without the written consent of the author is prohibited. This compiler
- may be distributed freely for non-commercial use as long as this notice stays
- intact. Please forward any enhancements or questions to:
-
- Matthew Brandt
- Box 920337
- Norcross, Ga 30092
-
-
- LIMITATIONS
- - Although you may declare floating point types the code generator
- does not know how to deal with them. They should therefore be
- avoided.
- - The preprocessor does not support arguments to #define'd macros
- or any of #line #ifdef... etc. Only #include and #define are
- supported.
- - Function arguments declared as char may not work properly.
- Declare them as int.
- - The size of functions is slightly limited due to the fact that
- the entire function is parsed before any code is generated.
- - The output of the compiler is in the UNIX 68000 assembler format.
- Nov 1989: Modified to be AS68 Compatible!
- - There is no standard runtime library support.
-
- If you wish to make commercial use of all or part of this package please
- contact me at the above address or (404)662-0366. Any voluntary contribution
- from non-commercial users will be greatly appreciated but is by no means
- necessary. enjoy...
-
- Matt Brandt
-
- DATA TYPES
- The data types supported are,
- char
- char *
- char array[]
- char array[][]
- double
- enum
- float
- int
- int *
- int array[]
- int array[][]
- int (*funcptr)()
- long
- short
- struct
- union
- unsigned
-
-
-
- STORAGE CLASSES
- automatic
- extern
- register
- static
- typedef
-
- examples,
- auto int test;
- extern int sum;
- register int quick;
- static char *msg = "Hello and Welcome.";
-
- DO NOT USE CLASS static OR auto INSIDE A FUNCTION.
-
-
-
- UNARY INTEGER OPEARTIONS
- - minus
- * indirection
- & address of
- ++ increment
- -- decrement
- ~ 7E 1's complement
- ! not
-
-
- BINARY INTEGER OPERATIONS
- + addition
- - subtraction
- * multiplication
- / division
- | inclusive or
- ^ exclusive or
- & logical and
- == equal
- != not equal
- < less than
- <= lass than or equal
- > greater than
- >= greater than or equal
- << left shift
- >> right shift
-
-
-
- LOGICAL OPERATORS
- && logical and
- || logical or
-
-
-
- CONDITIONAL OPERATOR
- ? : ;
-
-
-
- ASSIGNMENT OPERATORS
- =
- +=
- -=
- /=
- *=
- %=
- <<=
- >>=
- |=
-
- COMPILER FAILS ON ^=
-
-
- PROGRAM CONTROL
- if( expression ) statement;
- if( expression ) statement; else statement
- while( expression ) statement;
- for( expr1; expr2; expr3 ) statement;
- switch( expression ) statement;
- case constant: expression;
- default: expression;
- break;
- continue:
- return
- return expression
- ; /*null statement*/
- {statement; statement; ... ; statement}
- goto label
- label:
- (*functionpointer)();
-
-
- PROBLEMS:
- do { } while(condition);
- while( constant ) { }
- for( expr, expr ; expr, expr ; expr, expr ) { }
- ^=
- auto int /*inside a function*/
-
-
-
-
- VARIABLE DECLARATIONS
- Global variables may be type static or auto. Local variables inside functions
- are not preceeded by a storage class.
-
- examples,
- extern int eint;
- long lint;
- register int rint;
- short sint;
- static char *msg = "Hello";
- static enum color hue = green;
- static int (*oldintptr)() = &swap;
- struct table mytable[10];
- union test { float f; char c; int i; } mytest;
- unsigned int uint;
-
-
- COMPILER RESERVED KEYWORDS
- define auto break
- else char case
- endif double continue
- ifdef enum default
- ifndef extern do
- include float else
- int for
- long goto
- typedef if
- register switch
- short return
- sizeof while
- static
- struct
- union
- unsigned
- void
-
-
-
- COMMAND LINE OPTIONS
- When the compiler is run, it reads one C source file and produces an assembly
- language output file. The format of the compiler command line is:
-
- cc68k [-options] input_file.c
-
- The only option is -e, which echoes the compiler list file to the console
- screen.
-
-
- The compiler generates two output files,
-
- input_file.ASM assembler code
- input_file.LST list file
-
-
-
- LIBRARY FILES
- The compiler incorporates its own routines to handle switch and long multiply
- routines. These are included at the end of the assembler and list files.
-
-
- SAMPLE COMPILATION
-
- cc68k test.c
-
- This line causes the compiler to compile the input file test.c and write the
- generated code to the output file test.asm. Any errors are displayed on the
- screen, and also appear in the list file.
-
- Control C will abort the compiler.
-
-
- Assembling
-
- as68 test lf ef
-
- This command causes the file test.asm to be assembled, generating a .ls file
- (list) and a .S19 file (motorola S record). The .S19 file is downloaded to a
- target system for operation.
-
-
-
- OPTIMIZATION
- The compiler uses both intermediate and peephole optimization, this generates
- very effecient code. The code output routines have been heavily modified to
- allow operation with the AS68 assembler.
-
- «MDBO»