home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
100-199
/
ff141.lzh
/
SmallC
/
OPINST.DOC
< prev
next >
Wrap
Text File
|
1988-05-15
|
7KB
|
153 lines
COMPILING A SMALL-C SOURCE FILE
The compiler is initiated by entering 'SMC' in response to the
Amiga-DOS CLI prompt n>. The compiler greets you and asks three
questions. The possible answers are contained in parenthesis
following each question. The capitalized response in the default
taken if you press the return key. The first question asked is:
Should I pause after an error (y,N)?
A response of 'Y' to this question causes the compiler to pause
after displaying an error. This will give you an opportunity to
continue the compilation or not. Moreover, in the event of a lot
of screen activity during a compilation, this insures that you
won't miss an error message. An 'N' response causes the compiler
to continue automatically after displaying an error.
The second question asked is:
Do you want the Small-C text to appear (y,N)?
A response of 'Y' to this question causes the compiler to write
the input source code into the output file(s) as comment
statements. Each Small-C statement appears with a semicolon as
the first character (to make it a comment to ASM) followed by the
assembly language code generated by the compiler for that
statement. This interleaving of source code and generated code is
very useful in learning how the compiler implements various Small-C
statements. Choosing this option causes the output files to be
larger, however. An 'N' response will cause the compiler to omit
writing the Small-C source to the output file.
The third question asked is:
Compiling 'main()' (Y,n)?
A response of 'Y' to this question causes the compiler to define
space for any global variables. An 'N' response causes the compiler
to define global variables as externally defined references.
The three previous questions are followed by requests for input
and output filenames. There are no default extensions supplied
by the compiler. Each input file generates a separate output
file.
The next request by the compiler is:
Input filename?
The Small-C source code is contained in the file you name in
response to this question. There is no default extension supplied
by the compiler.
A single function definition cannot be spread out across
multiple input files. This is because the compiler assumes the
output file corresponding to each input file will be separately
assembled. It writes extra assembly language statements into
each output file to support this. A function spread across two
input files may not assemble correctly. Also, due to the way the
compiler handles externals, it is possible that a function name
could be multiply defined and the compiler not detect it. This
can happen if the separate definitions occur in different input
files. In this circumstance, the error will be detected by your
linkage editor.
The runtime library (SMCLIB.ASM) is not input to the compiler
as in other incarnations of Small-C. Instead, it is input to
your linkage editor as just another object file. Your linkage
editor will bind all of the object inputs together to produce
an executable file.
If your response to the input filename request is the return
key or a space (as the first character), the compiler terminates
and returns control to the CLI. This is the way the compiler is
normally ended.
Following the input filename request is the question:
Output filename?
The assembly language generated by the compiler for the
previous input file is written into the named file. Normally
this file will have the extension .ASM (not supplied
automatically by the compiler) since it will be input to the
assembler. If you press return, instead of providing a file name,
the compiler will direct its output to the display. You might
try this initially to get a feel for the code the compiler
generates.
COMPILER ERROR REPORTING
When the compiler detects an error in the Small-C program, it
displays a message on the screen. An example would be:
Line 20, main + 0: missing open paren
main)
^
The error occurred on the 20th line in the input file. The
function being compiled was "main". The error occurred 0 lines
into the function. The error detected was a "missing open
paren". The caret character (^) shows where the compiler was,
in the input line, when it detected the error. The compiler
continues automatically if you responded 'N' to the first question
asked by the compiler (see example above). If you responded 'Y' to
this question, you will see the following message displayed:
Continue (Y,n,g) ?
Pressing 'Y' (or just the return key) causes the compiler to
continue processing the source input. If you respond with 'N',
the compiler displays the message:
Compilation aborted.
and returns to the CLI. If you answer 'G', the compiler continues
processing the source input, but will no longer pause after an
error.
In this first version of the Small-C compiler, there is no way
to stop the compiler once it has started, except to re-boot your
Amiga.
ASSEMBLING AND LINKING THE COMPILER OUTPUT
Once your Small-C program is compiled by the compiler without
errors, you are ready to see if your program will actually run.
To do so, you must first run the output of the compiler through
an assembler. The following command, issued at the CLI prompt,
will accomplish this:
a68k filename.asm
This command will work for the 68000 macro assembler written by
Charlie Gibbs. Other assemblers for the Amiga may be satisfactory,
but his assembler is the only one that the author knows will
definitely work.
The final step in creating an executable program is to run the
output of the assembler through a linkage editor. The following
command, issued at the CLI prompt, will accomplish this:
blink filename.o smclib.o small.lib to filename
This command will work for the linkage editor written by the
Software Distillery. Other linkage editors may be satisfactory, but
BLINK is the only one that the author knows will definitely work.