You shall develop an absolute translator for a subset of the SIC/XE machine instructions described in your course text (BECK). It will use the same machine instruction mnemonics, opcodes, registers, formats, and requirements as described in BECK, except where noted. The subset will be referred to as a SIC/EM machine (SIC Economy Model).
BECK Appendix A is an important reference for machine instructions. Chapter provides further details, such as the numerical designations for the different registers.
Your translator shall read a special language described below, and generate at most a single machine instruction for each statement it reads.
The SIC/EM machine, as an economy model of the SIC/XE, is missing some of the features of the SIC/XE, but like the SIC/XE, is upward-compatible with the basic SIC machine. Also, SIC/EM programs will run on a SIC/XE machine, as the SIC/EM does not introduce any new features.
The SIC/EM machine lacks a floating-point unit, and so does not have a floating-point register, nor does it handle any of the floating-point instructions specified for the SIC/XE. Also, the SIC/EM does not have a base register, so no base-relative addressing modes are provided. (The "b" bit is always zero in a SIC/EM instruction.) Only direct addressing and PC-relative addressing are understood by the SIC/EM machine. Further, the SIC/EM does not support channel I/O, so those instructions are likewise not supported.
The translator shall read statements until an EOF (end of file) is read. Each statement will be read and then processed. Each statement shall have the following format:
MNEMONIC MODE OPERAND MODIFIER ;COMMENT
Symbols and instructions are not case sensitive. (You may cast all input to upper or lower case as you desire.) All symbols begin with a character in A..Z (or a..z), and are followed by up to seven additional characters in A..Z0..9 (or a..z0..9). Symbols longer than eight characters should generate an error. No user-defined symbol may be the same as any instruction or psuedo-operation.
Note that since a ,P (PC-relative addressing) mode is explicitly specified, the assembler does not have to decide whether or not to choose simple addressing over relative addressing. However, it still must check -- if PC-relative addressing is specified, and the specified location is not in the range PC-2048..PC+2047 (PC-x800..PC+x7FF), then an error should occur ("Operand out of range"). This is not the techniqued specified by BECK.
A number of psuedo-operations, or assembler directives, are defined for this assembler.
EQU symbol expr
expr must be a decimal number or an expression in terms of
previously defined symbols. If the expr is a *, then it is taken
as the value of the location counter. Note that this has the effect of
defining a label.
START symbol expr
expr must
be an expression that is already defined (either a symbol defined with EQU or a
decimal number). The effect is to set the initial value of the location
counter and to also assign that value to the specified symbol.
END expr
BYTE absexpr
WORD expr
expr is an absolute or relocatable expression. For example:
WORD 63
WORD ALPHA
WORD *
RESB absexpr
absexpr must be already been defined, or it
must be a decimal number. No output records need to be produced, just the
location counter advanced.
RESW absexpr
absexpr must already be defined, or it must be
a decimal number. No output records need to be produced, just the location
counter advanced.
Sample input and output files will be provided.