Formats 1 to 4
The opcode table records the base format, while a leading plus selects extended format 4.
Systems programming
This course project translates SIC/XE assembly into object code. The first pass assigns addresses and builds a symbol table. The second resolves operands, chooses addressing modes, and emits header, text, modification, and end records.
Assembly pipeline
Pass 1
The location counter starts at the operand of START. Each
instruction advances it by format length; directives such as
WORD, BYTE, RESW, and
RESB apply their own sizes. Labels are inserted into a
chained hash table, and duplicate symbols are reported as the listing
is built.
The opcode table records the base format, while a leading plus selects extended format 4.
START, END, BASE, NOBASE, WORD, BYTE, RESW, and RESB affect state without all producing object bytes.
A compact hash table maps labels to six digit addresses for operand resolution in pass 2.
Pass 2
The encoder handles immediate, indirect, indexed, program counter relative, base relative, and extended addressing. Format 4 symbol references also produce modification records. Text records stop at 30 bytes and split across reserved storage gaps.
| Syntax | Meaning | Encoding effect |
|---|---|---|
#VALUE |
Immediate | n = 0, i = 1 |
@VALUE |
Indirect | n = 1, i = 0 |
VALUE,X |
Indexed | x = 1 |
+JSUB TARGET |
Extended | e = 1 with a 20 bit address and modification record |
Object program
H^COPY ^000000^00107A
T^000000^1E^...
M^000004^05
E^000000
The sample COPY program exercises device I/O, subroutines, base addressing, format 4 calls, reserved memory, and byte constants.
Build and run
make
./assembler input.asm
The assembler writes the generated records to
output.obj and prints both pass listings to the terminal.