Esempio n. 1
0
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"))
Esempio n. 2
0
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"))
Esempio n. 3
0
def test_unable_to_decode(dasm: Disassembler) -> None:
    rom_data = [0x99, 0x4E]
    dasm.seed_rom_data(rom_data)

    try:
        dasm.decode()
    except IndexError:
        pass
Esempio n. 4
0
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()
Esempio n. 5
0
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)
Esempio n. 6
0
def dasm() -> Disassembler:
    return Disassembler()
Esempio n. 7
0
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"}))
Esempio n. 8
0
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"}))
Esempio n. 9
0
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"}))
Esempio n. 10
0
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"}))
Esempio n. 11
0
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"}))