home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d141 / smallc.lha / SmallC / OPINST.DOC < prev    next >
Text File  |  1988-05-15  |  7KB  |  153 lines

  1.  
  2.                       COMPILING A SMALL-C SOURCE FILE
  3.  
  4.          The compiler is initiated by entering 'SMC' in response to the
  5.        Amiga-DOS CLI prompt n>.  The compiler greets you and asks three
  6.        questions.  The possible answers are contained in parenthesis
  7.        following each question.  The capitalized response in the default
  8.        taken if you press the return key.  The first question asked is:
  9.  
  10.                  Should I pause after an error (y,N)?
  11.  
  12.          A response of 'Y' to this question causes the compiler to pause
  13.        after displaying an error.  This will give you an opportunity to
  14.        continue the compilation or not.  Moreover, in the event of a lot
  15.        of screen activity during a compilation, this insures that you
  16.        won't miss an error message.  An 'N' response causes the compiler
  17.        to continue automatically after displaying an error.
  18.  
  19.          The second question asked is:
  20.  
  21.                  Do you want the Small-C text to appear (y,N)?
  22.  
  23.          A response of 'Y' to this question causes the compiler to write
  24.        the input source code into the output file(s) as comment
  25.        statements.  Each Small-C statement appears with a semicolon as
  26.        the first character (to make it a comment to ASM) followed by the
  27.        assembly language code generated by the compiler for that
  28.        statement.  This interleaving of source code and generated code is
  29.        very useful in learning how the compiler implements various Small-C
  30.        statements.  Choosing this option causes the output files to be
  31.        larger, however.  An 'N' response will cause the compiler to omit
  32.        writing the Small-C source to the output file.
  33.  
  34.          The third question asked is:
  35.  
  36.                  Compiling 'main()' (Y,n)?
  37.  
  38.          A response of 'Y' to this question causes the compiler to define
  39.        space for any global variables.  An 'N' response causes the compiler
  40.        to define global variables as externally defined references.
  41.  
  42.          The three previous questions are followed by requests for input
  43.        and output filenames.  There are no default extensions supplied
  44.        by the compiler.  Each input file generates a separate output
  45.        file.
  46.  
  47.          The next request by the compiler is:
  48.  
  49.                  Input filename?
  50.  
  51.          The Small-C source code is contained in the file you name in
  52.        response to this question.  There is no default extension supplied
  53.        by the compiler.
  54.  
  55.           A single function definition cannot be spread out across
  56.        multiple input files.  This is because the compiler assumes the
  57.        output file corresponding to each input file will be separately
  58.        assembled.  It writes extra assembly language statements into
  59.        each output file to support this.  A function spread across two
  60.        input files may not assemble correctly.  Also, due to the way the
  61.        compiler handles externals, it is possible that a function name
  62.        could be multiply defined and the compiler not detect it.  This
  63.        can happen if the separate definitions occur in different input
  64.        files.  In this circumstance, the error will be detected by your
  65.        linkage editor.
  66.  
  67.          The runtime library (SMCLIB.ASM) is not input to the compiler
  68.        as in other incarnations of Small-C.  Instead, it is input to
  69.        your linkage editor as just another object file.  Your linkage
  70.        editor will bind all of the object inputs together to produce
  71.        an executable file.
  72.  
  73.          If your response to the input filename request is the return
  74.        key or a space (as the first character), the compiler terminates
  75.        and returns control to the CLI.  This is the way the compiler is
  76.        normally ended.
  77.  
  78.          Following the input filename request is the question:
  79.  
  80.                  Output filename?
  81.  
  82.          The assembly language generated by the compiler for the
  83.        previous input file is written into the named file.  Normally
  84.        this file will have the extension .ASM (not supplied
  85.        automatically by the compiler) since it will be input to the
  86.        assembler.  If you press return, instead of providing a file name,
  87.        the compiler will direct its output to the display.  You might
  88.        try this initially to get a feel for the code the compiler
  89.        generates.
  90.  
  91.  
  92.  
  93.                          COMPILER ERROR REPORTING
  94.  
  95.          When the compiler detects an error in the Small-C program, it
  96.        displays a message on the screen.  An example would be:
  97.  
  98.        Line 20, main + 0: missing open paren
  99.        main)
  100.             ^
  101.  
  102.            The error occurred on the 20th line in the input file.  The
  103.        function being compiled was "main".  The error occurred 0 lines
  104.        into the function.  The error detected was a "missing open
  105.        paren".  The caret character (^) shows where the compiler was,
  106.        in the input line, when it detected the error.  The compiler
  107.        continues automatically if you responded 'N' to the first question
  108.        asked by the compiler (see example above).  If you responded 'Y' to
  109.        this question, you will see the following message displayed:
  110.  
  111.                            Continue (Y,n,g)  ?
  112.  
  113.          Pressing 'Y' (or just the return key) causes the compiler to
  114.        continue processing the source input.  If you respond with 'N',
  115.        the compiler displays the message:
  116.  
  117.                           Compilation aborted.
  118.  
  119.        and returns to the CLI.  If you answer 'G', the compiler continues
  120.        processing the source input, but will no longer pause after an
  121.        error.
  122.  
  123.          In this first version of the Small-C compiler, there is no way
  124.        to stop the compiler once it has started, except to re-boot your
  125.        Amiga.
  126.  
  127.  
  128.  
  129.                  ASSEMBLING AND LINKING THE COMPILER OUTPUT
  130.  
  131.          Once your Small-C program is compiled by the compiler without
  132.        errors, you are ready to see if your program will actually run.
  133.        To do so, you must first run the output of the compiler through
  134.        an assembler.  The following command, issued at the CLI prompt,
  135.        will accomplish this:
  136.  
  137.                     a68k filename.asm
  138.  
  139.          This command will work for the 68000 macro assembler written by
  140.        Charlie Gibbs.  Other assemblers for the Amiga may be satisfactory,
  141.        but his assembler is the only one that the author knows will
  142.        definitely work.
  143.  
  144.          The final step in creating an executable program is to run the
  145.        output of the assembler through a linkage editor.  The following
  146.        command, issued at the CLI prompt, will accomplish this:
  147.  
  148.                 blink filename.o smclib.o small.lib to filename
  149.  
  150.          This command will work for the linkage editor written by the
  151.        Software Distillery.  Other linkage editors may be satisfactory, but
  152.        BLINK is the only one that the author knows will definitely work.
  153.