⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mc.doc

📁 c语言的小编译器,学习的好东东.
💻 DOC
📖 第 1 页 / 共 5 页
字号:
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
                                    MICRO-C
    
                             A compact 'C' compiler
                               for small systems.
    
                                Technical Manual
    
    
    
    
    
                                  Release 2.0
    
                               Revised 10-Aug-90
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
                       Copyright 1988,1990 Dave Dunfield
                              All rights reserved
    MICRO-C                                                          Page: 1


    1. INTRODUCTION
    
          MICRO-C is a compact, portable compiler for a subset  of  the  'C'
       language which is suitable for implementation on small 8  or  16  bit
       computer systems. It may be used as a resident or cross compiler, and
       is capable of generating ROMable code. It is  distributed  in  source
       form, and thus provides a learning tool for those wishing to  examine
       the internals of a working compiler.
    
          The main goal in the development of MICRO-C, has been to provide a
       reasonably powerful language  which  will  be  portable  with  little
       difficulty to many  target  systems.  The  'C'  language  was  chosen
       because  it  was  designed  to  be  portable,  and   provides   ample
       programming power. MICRO-C provides  an  alternative  to  interpreted
       BASIC or assembly language  programming  which  are  often  the  only
       languages available on small 8 bit systems.
    
          With today's focus on larger computers and workstations,  software
       support for small  systems  and  micro-controller  sized  devices  is
       getting hard to find. MICRO-C helps fill that gap, because all  files
       necessary to port and maintain  the  compiler  are  included  on  the
       distribution disk, allowing it to be  moved  to  ANY  system  without
       dependance on a software vendor.
    
          Sample code generators  and  runtime  librarys  are  included  for
       several popular microprocessors.
    
          Also included with the compiler is the 'C' and 'ASM'  source  code
       for a complete library of system functions, as well  several  example
       programs.
    
          The MICRO-C "package" (software and documentation) is copyrighted,
       and may  not  be  re-distributed  in  any  form  without  my  written
       permission. If you have received the  "DEMO"  archive,  and  wish  to
       obtain the entire MICRO-C package complete with source code, fill out
       and send the order form contained in the "READ.ME" file,  along  with
       the required payment to:
    
                           Dave Dunfield
                           56 Burnetts Grove Circle,
                           Nepean, Ont. (Canada)
                           K2J 1N6
    
          If you choose not to order the complete MICRO-C package, you  MUST
       discontinue using MICRO-C within thirty days.
    
          MICRO-C is provided on an "as is" basis, with no warranty  of  any
       kind. In no event shall the author be liable for any damages  arising
       from its use or distribution.
    MICRO-C                                                          Page: 2


       1.1 Code Portability
    
             With few exceptions, this compiler follows the  syntax  of  the
          "standard" UNIX compiler (within  its  subset  of  the  language).
          Programs written in MICRO-C should compile with few changes  under
          other "standard" compilers.
    
          1.1.1 Unsupported Features:
    
                MICRO-C does not currently support the following features of
             standard 'C':
    
                    Long, Double, Float and Enumerated data types,
                    Structures, Unions, Typedef and Bit fields.
    
          1.1.2 Additional Features
    
                MICRO-C provides a few additional  features  which  are  not
             always included in "standard" 'C' compilers:
    
                    Unsigned character variables, Nested comments, 16 bit
                    character constants, Inline assembly code capability.
    
       1.2 Compiler Portability
    
             MICRO-C is written in standard 'C', and is capable of compiling
          itself. This allows any system  with  a  'C'  compiler  (including
          MICRO-C) to be used to port MICRO-C to another processor.
    
             The  parser  makes  very  few  assumptions  about  the   target
          processor  or  operating  system  architecture,  allowing  a  code
          generator  to  be  written  for  virtually   any   processor   and
          environment.
    
             With the exception of required I/O routines (described  later),
          the MICRO-C compiler uses no library functions, and relies  on  no
          system services.
    
             Assuming that the code generator is fairly efficent,  and  that
          the I/O routines and code generator are not unreasonably large,  a
          full MICRO-C compiler may be implemented on systems with as little
          as 32K of free ram and a single floppy disk.
    MICRO-C                                                          Page: 3


       1.3 The MCC command
    
             When  created  using  the  'io'  routines   supplied   on   the
          distribution disk, the format of the MICRO-C Compiler command line
          is:
    
                    MCC [input_file] [output_file] [options]
    
             [input_file] is the name of  the  source  file  containing  'C'
          statements to read. If no filenames are given, MCC will read  from
          standard input.
    
             [output_file] is the name of the file to  write  the  generated
          assembly  language  code  to.  If  less  than  two  filenames  are
          specified, MCC will write to standard output.
    
          1.3.1 Command Line Options
    
                -q      - Instructs MCC to be quiet, and not display the
                          startup message when it is executed.
    MICRO-C                                                          Page: 4


    2. THE MICRO-C PROGRAMMING LANGUAGE
    
          The following pages contain a brief summary of  the  features  and
       constructs implemented in MICRO-C.
    
          This document does not  attempt  to  teach  'C'  programming,  and
       assumes that the reader is familiar with the language.
    
       2.1 Constants
    
             The following forms of constants are supported by the compiler:
    
                <num>       - Decimal number        (0 - 65535)
                0<num>      - Octal number          (0 - 0177777)
                0x<num>     - Hexidecimal number    (0x0 - 0xffff)
                '<char>'    - Character             (1 or 2 chars)
                "<string>"  - Address of literal string.
    
             The following "special" characters may be used within character
          constants or strings:
    
                \n          - Newline (line-feed)   (0x0a)
                \r          - Carriage Return       (0x0d)
                \t          - Tab                   (0x09)
                \f          - Formfeed              (0x0c)
                \b          - Backspace             (0x08)
                \<num>      - Octal value <num>     (Max. three digits)
                \x<num>     - Hex value <num>       (Max. two digits)
                \<char>     - Protect character <char> from input scanner.
    
       2.2 Symbols
    
             Symbol names  may  include  the  characters  'a'-'z',  'A'-'Z',
          '0'-'9', and '_'. The characters '0'-'9' may not be  used  as  the
          first character in the  symbol  name.  Symbol  names  may  be  any
          length, however, only the first 15 characters are significant.
    
             The "char" modifier may be used to declare a symbol as an 8 bit
          wide value, otherwise it is assumed to be 16 bits.
    
                              eg: char input_char;
    
             The "int" modifier may be used to declare a symbol as a 16  bit
          wide value. This is assumed if neither "int" or "char" is given.
    
                                  eg: int abc;
    
             The "unsigned" modifier may be used to declare a symbol  as  an
          unsigned positive only value. Note that unlike some 'C' compilers,
          this modifier may be applied to a character (8 bit) variable.
    
                            eg: unsigned char count;
    MICRO-C                                                          Page: 5


             The "extern" modifier causes the compiler to be  aware  of  the
          existance and  type  of  a  global  symbol,  but  not  generate  a
          definition for that symbol. This allows the module being  compiled
          to reference a symbol which is defined  in  another  module.  This
          modifier may not be used with local symbols.
    
                            eg: extern char getc();
    
             A  symbol  declared  as  external  may  be  re-declared  as   a
          non-external at a later  point  in  the  code,  in  which  case  a
          definition for it will be generated. This allows  "extern"  to  be
          used to inform the compiler of a function or variable type so that
          it can be referenced  properly  before  that  symbol  is  actually
          defined.
    
             The "static" modifier causes global variables to  be  available
          only in the file where they are defined.  Variables  or  functions
          declared  as  "static"  will  not  be   accessable   as   "extern"
          declarations in other object files, nor will they cause  conflicts
          with duplicate names in those files.
    
                         eg: static int variable_name;
    
             The "register" modifier indicates to the  code  generator  that
          this is a high priority variable, and should be kept where  it  is
          easy to get at. Since  its  interpretation  depends  on  the  code
          generator, it is often  ignored  in  simple  implementations.  See
          "Functions" for a  special  use  of  "register"  when  defining  a
          function.
    
                          eg: register unsigned count;
    
             Symbols declared with a preceeding '*' are assumed to be 16 bit
          pointers to the declared type.
    
                             eg: int *pointer_name;
    
             Symbol names declared followed by square brackets  are  assumed
          to be arrays with a number of dimensions equal to  the  number  of
          '[]' pairs that follow. The size of each dimension  is  identified
          by a constant value  contained  within  the  corresponding  square
          brackets.
    
                          eg: char array_name[5][10];
    
          2.2.1 More Symbol Examples
    
                char a;                 /* 8 bit signed */
                unsigned char b;        /* 8 bit unsigned */
                int c;                  /* 16 bit signed */
                unsigned int d;         /* 16 bit unsigned */
                unsigned e;             /* also 16 bit unsigned */
                extern char f();        /* external function returning char */
    MICRO-C                                                          Page: 6


          2.2.2 Global Symbols
    
                Symbols  declared  outside  of  a  function  definition  are

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -