Пример #1
0
 def state(self):
     """Return a string representation of the current state"""
     registers = [
         ("PC", 2),
         ("IR", 1),
         ("D", 1),
         ("AC", 1),
         ("X", 1),
         ("Y", 1),
         ("OUT", 1),
         ("XOUT", 1),
     ]
     heading = " ".join([r.rjust(w * 2 + 1)
                         for r, w in registers] + ["Loaded instruction"])
     separator = " ".join(["-" * (2 * w + 1)
                           for _, w in registers] + ["------------------"])
     values = " ".join([("${:0%dx}" % (w * 2, )).format(getattr(self, r))
                        for r, w in registers] +
                       [asm.disassemble(self.IR, self.D)])
     return "\n".join([heading, separator, values])
Пример #2
0
def test_assemble_disasseble_cycle():
    code = assemble(asm)

    assert assemble(disassemble(code)) == code
Пример #3
0
def test_disassemble():
    assert disassemble(prog) == asm