|
|
|
@ -3,7 +3,7 @@ from collections import namedtuple
|
|
|
|
|
import enum |
|
|
|
|
|
|
|
|
|
class rfield(enum.Enum): |
|
|
|
|
none, reg, imm_flag = range(3) |
|
|
|
|
none, reg, imm_flag, shift = range(4) |
|
|
|
|
|
|
|
|
|
Opcode = namedtuple('Opcode', ('mnemonic', 'rx', 'ry', 'addr')) |
|
|
|
|
|
|
|
|
@ -11,10 +11,10 @@ opcodes = [
|
|
|
|
|
Opcode('halt', rx=rfield.none, ry=rfield.none, addr=False), |
|
|
|
|
Opcode('ret', rx=rfield.none, ry=rfield.none, addr=False), |
|
|
|
|
|
|
|
|
|
Opcode('shl', rx=rfield.reg, ry=rfield.none, addr=False), |
|
|
|
|
Opcode('shr', rx=rfield.reg, ry=rfield.none, addr=False), |
|
|
|
|
Opcode('rol', rx=rfield.reg, ry=rfield.none, addr=False), |
|
|
|
|
Opcode('ror', rx=rfield.reg, ry=rfield.none, addr=False), |
|
|
|
|
Opcode('shl', rx=rfield.reg, ry=rfield.shift, addr=False), |
|
|
|
|
Opcode('shr', rx=rfield.reg, ry=rfield.shift, addr=False), |
|
|
|
|
Opcode('rol', rx=rfield.reg, ry=rfield.shift, addr=False), |
|
|
|
|
Opcode('ror', rx=rfield.reg, ry=rfield.shift, addr=False), |
|
|
|
|
|
|
|
|
|
Opcode('nand', rx=rfield.reg, ry=rfield.reg, addr=False), |
|
|
|
|
Opcode('and', rx=rfield.reg, ry=rfield.reg, addr=False), |
|
|
|
@ -89,6 +89,9 @@ def disasm(binary, origin = 0):
|
|
|
|
|
fields.append(f'r{contents.rx}') |
|
|
|
|
if opcodes[contents.opcode].ry == rfield.reg: |
|
|
|
|
fields.append(f'r{contents.ry}') |
|
|
|
|
elif opcodes[contents.opcode].ry == rfield.shift: |
|
|
|
|
shift = contents.ry if contents.ry != 0 else 4 |
|
|
|
|
fields.append(f'{shift}') |
|
|
|
|
if contents.immediate is not None: |
|
|
|
|
fields.append(f'#{contents.immediate:02x}') |
|
|
|
|
elif opcodes[contents.opcode].addr: |
|
|
|
|