![]() | ![]() | ![]() | An Input/Output Library? |
To make your compiler useful, you must provide a standard set of input/output routines. These routines should be named outnum, getnum, outch, and getch. They should provide a way to execute the corresponding 34000 instructions from a Co program. The routines outnum and outch will behave as procedures that expect one value parameter (of type integer). The routines getnum and getch will be integer functions taking no parameters.
To make it easy for you to add support for this input/output "library" to
your compiler, I have done three things: 1) I have included code in the
init_symbtab
routine which creates declaration descriptors
for these procedures and adds them to the symbol table; 2) I have
provided you with code (in a file named IOlib.c
) which includes
procedures you can use to set the entrylbl
components of the
declaration descriptors for the I/O procedures; and 3) I have provided
you with a file of 34000 assembly language code named iolib.h
that contains the actual assembly language code for these procedures.
Like the code I gave you in ~tom/shared/434/Cdim/phase2/stmtgen.c
you
may find that you have to modify the code in my IOlib.c
and
iolib.h
files
before you can use it. As a result, I will expect all of you to
submit copies of the actual versions of these files you used. To make
sure that this happens, you must include IOlib.c
in the SRC
line of your Makefile and iolib.h
in the HDR line.
The routine provided in IOlib.c
for setting the entrylbl
components of each I/O procedure's declaration descriptor is called
initIOlib
. You should call this routine just before you begin
code generation. It works by calling another routine named
initProcLabel
for each of the four I/O procedures. The
initProcLabel
routine assumes that the appropriate way to
set entrylbl
is to allocate a structure of type CODELBL
,
put the address of the allocated structure into entrylbl
and
then call a routine you must supply named initLabel
to actually
set the contents of the codelabel
to a "new" label.
You may have to write a special routine for initializing these labels,
because you need the ability to specify the exact name associated
with the label (the names used must match those in iolib.h
).
The iolib.h
file is not a C header file. It is a file of
assembly language code to be included with the code you generate.
Since cdimc
runs the assembly code you produce through the
C pre-processor, you can use this file by including the line
#include "iolib.h"
![]() | ![]() | ![]() | An Input/Output Library? |