def test_decode_operation(dasm: Disassembler) -> None: rom_data = [0x12, 0x4E] dasm.seed_rom_data(rom_data) opcode = dasm.read_opcode() operation = dasm.read_operation(opcode) expect(hex(operation)).to(equal("0x1000"))
def test_decode_address(dasm: Disassembler) -> None: rom_data = [0x12, 0x4E] dasm.seed_rom_data(rom_data) opcode = dasm.read_opcode() address = dasm.read_address(opcode) expect(hex(address)).to(equal("0x24e"))
def test_unable_to_decode(dasm: Disassembler) -> None: rom_data = [0x99, 0x4E] dasm.seed_rom_data(rom_data) try: dasm.decode() except IndexError: pass
def cli(rom_file: str, insight: bool) -> None: """Disassemble ROM_FILE. ROM_FILE is the rom binary file to load. """ click.echo("ROM File: ", nl=False) click.secho(f"{os.path.basename(rom_file)}", fg="green", bold=True) dasm = Disassembler(rom_file, insight) assert isinstance(dasm.rom_data, bytearray) dasm.decode() writer = Writer(dasm) writer.generate()
def test_no_opcode(dasm: Disassembler) -> None: rom_data = [0x99, 0x4E] dasm.seed_rom_data(rom_data) opcode = dasm.read_opcode() operation = dasm.read_operation(opcode) address = dasm.read_address(opcode) dasm.add_to_disassembly(operation, address)
def dasm() -> Disassembler: return Disassembler()
def test_Dxyn(dasm: Disassembler) -> None: rom_data = [0xD3, 0x47] dasm.seed_rom_data(rom_data) dasm.decode() expect(dasm.disassembly).to(equal({0x200: "DRW V3, V4, 0x07"}))
def test_Annn(dasm: Disassembler) -> None: rom_data = [0xA2, 0x02] dasm.seed_rom_data(rom_data) dasm.decode() expect(dasm.disassembly).to(equal({0x200: "LD I, lbl_0x0202"}))
def test_6xkk(dasm: Disassembler) -> None: rom_data = [0x67, 0x03] dasm.seed_rom_data(rom_data) dasm.decode() expect(dasm.disassembly).to(equal({0x200: "LD V7, 0x03"}))
def test_3xkk(dasm: Disassembler) -> None: rom_data = [0x32, 0x0A] dasm.seed_rom_data(rom_data) dasm.decode() expect(dasm.disassembly).to(equal({0x200: "SE V2, 0x0a"}))
def test_1nnn(dasm: Disassembler) -> None: rom_data = [0x12, 0x4E] dasm.seed_rom_data(rom_data) dasm.decode() expect(dasm.disassembly).to(equal({0x200: "JP lbl_0x024e"}))