Write an assembler for the T.B.Inc. machine. The program should accept T.B. Inc. 402 assembler code and produce an object file that the emulator can process. The assembler should also produce a user listing of both the original assembler program and the machine form of the program.
A. Source code requirements:
(1) Implement the mnemonics of the T.B.Inc. machine.
(2) In addition to (1), make it possible to use the following directives:
RESW, WORD, RESB, BYTE, CSECT, EQU, EXTDEF, and EXTREF.
(3) Programs may include decimal, hexadecimal, and character constant value expressions.
(4) Assume that each statement must fit on one line (80 characters).
B. User listing:
For each assembler language source statement in a source code file, your user listing should contain, in the following order:
the line number of the source statement (in decimal).
the location counter value associated with the object code generated by the source statement (in hex).
the source statement itself (verbatim).
the object code generated for that statement.
C. Object Code
The machine code generated by the assembler should have the format required by the emulator.
D. Error Processing
The assembler should detect certain syntax errors/warnings in the source code and print appropriate messages on the line below the error, if possible. Each error message should identify the error/warning and its location.
E. Note:
Later you will write a linker to put together the output file from your assembler.
F. Additional Information about Statements in the Language
Each statement may have:
- Maximum length of a label: 6 characters
- Labels must start with an alphabetic character and may be followed by up to 5 alphanumeric characters.
- Opcode mnemonic or pseudo-op set off by spaces
- Delimited by spaces on either side
- May be any of the following:
label
constant
| base ten
hex character literal |
ex. 27
ex. X'3C' ex. C'HELLO' ex. =X'2A3B4C' |
- Comma followed by I,X,N, or XN
- Default is blank
Pseudo-ops
CSECT indicates starting point and name for a code block
BYTE generates constants in multiples of bytes
WORD generates constants with length 1 word
RESB reserves memory in bytes
RESW reserves memory in words
A Sample Program
| PROG | CSECT
LDCH BCONST,XN this is a comment STCH BVAR LDA WCONST STA WVAR LDCH C’A’,I HALT |
. This is also a comment
| BCONST
WCONST BVAR WVAR |
BYTEX’3’
WORD 11 RESB2 RESW 1 |