41 lines
751 B
Python
41 lines
751 B
Python
from zbirnik.code import Code
|
|
from zbirnik.EmitCtx import EmitContext
|
|
from zbirnik.ukazi.f3 import f3
|
|
from zbirnik.ukazi.storage import storage
|
|
from zbirnik.adressing import AddrMode
|
|
|
|
OPCODES = {
|
|
"LDA": 0x00,
|
|
"STA": 0x0C,
|
|
}
|
|
|
|
REGISTERS = {
|
|
"A": 0, "X": 1, "L": 2,
|
|
"B": 3, "S": 4, "T": 5, "F": 6
|
|
}
|
|
|
|
code = Code("TEST")
|
|
|
|
code.add(f3(
|
|
operand="A",
|
|
mnemonic="LDA",
|
|
label=None,
|
|
index=False,
|
|
adr_mode=AddrMode.SIMPLE
|
|
))
|
|
|
|
code.add(storage(
|
|
name="WORD",
|
|
value=5,
|
|
label="A"
|
|
))
|
|
|
|
code.pass1()
|
|
print("SYMTAB:", code.symtab)
|
|
print("START:", hex(code.start_address))
|
|
print("LENGTH:", code.program_length)
|
|
|
|
ctx = EmitContext(opcodes=OPCODES, symtab=code.symtab)
|
|
binary = code.pass2(ctx)
|
|
|
|
print("BINARY:", binary.hex())
|