.pl 66
.po 8
.ls 2	DOUBLE SPACED
.hy 14
.de hd	HEADER
.ev 1
.ul
'sp 2
.tl '1978 Thesis - M.Young''Page 4.%'
'sp 1
.tl ''Microprogram Translator / Emulator''
'sp 2
.ev
..
.de fo	FOOTER
'sp 3
..
.de pg	PARAGRAPH
.sp 2
.ti +5
..
.wh 0 hd
.wh -3 fo
.in 0
.ul
The C Programs.
.pg
The D-Machine emulator does the actual emulation within a large
loop containing a set of switch statements which select the data
path to be used, depending upon the micro-program bit pattern.
Before this loop is entered, the micro-code, S-Memory contents, and
option flags are read in and the D-Machine registers are cleared.
During the loop, S-Memory may be inspected and changed if a break
is set. The program will also read and write on standard input and
output if device read or device write instructions are encountered.
.pg
When the loop terminates, either by the micro-code for 'end' being reached,
or by some error condition such as time limit or illegal memory address
occurring, a final dump of all registers is produced and an S-Memory
dump is also done unless the '-n' flag was specified at the start.
.pg
The translator is in four sections. The first is an initialisation
section which reads the option flags and sets up the various files
and flags required later. Default files are standard input and
standard output, and if no hex listing file is given, the only
output is that required to be sent to the terminal by the various options.
The next two sections, which work together to do the translation,
are the parser (written in Yacc) and the lexical analyser. The
lexical analyser actually has to look ahead when it sees certain
key words to see the context in which they are being used. It
then returns a value to the parser which corresponds to that
usage. For example, the lexical analyser may encounter a comma,
after seeing a destination. This comma could therefore be
separating that destination from one to follow. However, the
comma could also be separating one component (a logic operation
containing destinations) from another. In the first case, the
lexical analyser returns 'DESTSEP' for a destination separator,
and in the second, 'COMPSEP' for a component separator.
.pg
The final section of the translator finds the values of the
labels used, and puts the result in the right place in the hex
listing. Labels are checked for multiple definition, and
error messages are printed if undefined labels or multiply-defined labels
are found.
.pg
The third program is a preprocessor for the translator, called prep.
This program reads standard input and writes to standard output,
converting lines between '.a' and '..' from ascii text into sets
of literal assignment statements which can then be accessed by
doing 'exec's of these lines from a print routine (see appendix I).
The preprocessor was written when the tediousness of typing in messages
as strings of literal assignments became apparent. Messages could be
stored in S-Memory, and this would allow the messages to be changed
more easily. However, there would then be two files to keep together,
and the message file would have to be concatenated with any other
S-Memory required.
.pg
Information on the use of the three C programs is included as appendix G.
The next two sections deal with some of the features of the C
programs and indicate which features were available in the Fortran version.
