Dodal tabelo opcodeu, main, mal prilagodil strukturo
This commit is contained in:
parent
4b2a7a3cc2
commit
195ca3c9fa
13 changed files with 216 additions and 39 deletions
41
ass3/zbirnik/tests/test_passes.py
Normal file
41
ass3/zbirnik/tests/test_passes.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
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())
|
||||
Loading…
Add table
Add a link
Reference in a new issue