Exp 6
Exp 6
Ex. No.: 6
SINGLE PASS ASSEMBLER FOR SIC
23 – 02 - 2024
Aim
To simulate the concept of single pass assembler for simplified instructional computer.
Description
An assembler is a program that accepts as input an assembly language program (source) and
produces its machine language equivalent (object code) along with the information for the
loader.
ALGORITHM
1. Open and Read the input file
2. If the input line has the opcode START do the following
2.1 Find if there is any operand field after START initialize the LC to the operand
Value.
2.2 Otherwise if there is no value in the operand field then LC is set to 0.
3. Write the input line to the intermediate file.
4. Do the following steps until the opcode is END.
4.1 Check the Symbol table, if the symbol is not available then enter that symbol into
the SYMTAB, along with the memory address in which it is stored. Otherwise, the
error message will be displayed.
file.write(f'H^{program_name}^{format(start_address,
"06X")}^{format(program_length, "02X")}\n')
file.write(f'T^001000^0c^000000^230000\n')
for label, address in symtab.items():
if label == 'ALPHA':
file.write(f'T^1001^02^{address}\n')
elif label == 'BETA':
file.write(f'T^1004^02^{address}\n')
file.write(f'E^{format(start_address, "06X")}\n')
input.txt
optab.txt
Output
symtab.txt
result.txt
Result
Thus, a program had been written that simulates the concept of single pass assembler for
simplified instructional computer and the same had been verified successfully.