In order to make the parsing of SCA as simple as possible we have adopted the fixed field width format. Each line of SCA code not started with a semicolon is divided into four distinct fields, each with its own width, given in number of characters. Fields start on a specified column and should be separated by spaces. A full line is 80 columns [0..79]. The Label field starts at column 0 and runs for 15 characters. There must be at least one space separating fields. The Mnemonic field starts on column 16. The Operands field starts at column 24 and the Comments field starts at column 48. All labels, operands and comments must be completely contained within these field limitations.
Labels, as well as all other fields except comments must be written in uppercase.
|
DIRECTIVE |
OPERANDS |
EXPLANATION |
|
ORG |
Number |
Sets origination address of program counter. |
|
END |
None |
Terminates program listing. |
|
DB |
Number (-128 to 127) or character in single quotes, e.g., ‘H’ or string of text in double quotes, e.g., “Hi there”. \t = tab; \n = newline; \0 = terminator |
Sets the value of a byte of memory to number value or ASCII value of character (usually takes a label). If a string is given the assembler reserves the number of bytes in the string, setting values of each byte to the corresponding ASCII value. |
|
DW |
Number –215 to 215 |
Same but for a full 16 bit word |
|
RB |
Number |
Reserves number of bytes designated in operand. No initialization occurs |
|
RW |
Number |
Reserves number of words in memory. No initialization occurs. |
1234d or 1234 – decimal
1234o or 01234 – octal
1234h or 0x1234 – hexadecimal
1111b or 001111 – binary
Short: Signed value –128..+127
Character: Any ASCII character in single quotes. Escaped characters, e.g., ‘\n’ are interpreted as single bytes.
Integer Signed value –1x215..1x215-1
String: any sequence of ASCII characters enclosed in double quotes. Strings must fit within the operand field so it may be necessary to break a string across two or more statements, e.g., “Hello ” “world!”.
A comment field must start with a semicolon if a comment is present. Comments must end at column 78 (leaving room for a newline).
Assuming successful assembly, the assembler constructs two files. These are the assembly listing file and the program load file. The listing file has a similar format to the source file but contains the addresses and generated code fields appended. The load file is a text file in hex format that can be loaded by the SimpComp simulator and run. Examples of these files.
The assembler reports syntax errors if they occur during the assembly process.