-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (31 loc) · 1.17 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
from SICXE import Assembler
if __name__ == '__main__':
try:
file = sys.argv[1]
except IndexError:
file = input("Please input a full file name...>")
while not file:
print("You don't input a file.")
file = input("Please input again...>")
asm = Assembler().load_file(file)
print("=====Source code=====")
for i in asm.source:
print("{1}\t{0}\t{2}".format(i['operator'],
i['symbol'] if i['symbol'] else "\t",
i['operand'] if i['operand'] else "\t"))
print("\n=======OPTAB========\n")
for i, val in asm.OPTAB.items():
print(" {:6}\t{:2}\t{:02X}".format(i, val['format'], int(val['opcode'], 16)))
asm.pass_one()
print("\n======SYMTAB======\n")
print("{:^8}\t{:^5}".format('"symbol"', '"val"'))
for i, val in asm.SYMTAB.items():
print(" {:8}\t{:04X}".format(i, val))
if asm.LITERAL:
print("\n=======LITERALS========\n")
for i, val in asm.LITERAL.items():
print(" {:7}\t{:04X}".format(i, val))
asm.pass_two()
print("\n======Object Program=====\n")
print(asm.object_program)