def test_analyze_makes_lab_symbol_for_jump_target(self): table = symbols.SymbolTable() analyzer = symbols.SymbolCreatingAnalyzer(table) mem = memory.Memory(bytearray(0x10000)) intable = disasm.Instruction(location=0xF000, opcode=0x60, addr_mode=AddressModes.Implied) mem.set_instruction(0xF000, intable) mem.annotate_jump_target(0xF000) analyzer.analyze(mem) self.assertEqual(table[0xf000].name, 'lab_f000')
def test_analyze_doesnt_overwrite_code_exitableing_symbol(self): table = symbols.SymbolTable() analyzer = symbols.SymbolCreatingAnalyzer(table) mem = memory.Memory(bytearray(0x10000)) mem.annotate_jump_target(0xF000) mem.annotate_call_target(0xF000) intable = disasm.Instruction(location=0xF000, opcode=0x60, addr_mode=AddressModes.Implied) exitableing_symbols = {0xf000: ('print', '')} table = symbols.SymbolTable() table[0xf000] = symbols.Symbol(address=0xf000, name="print") analyzer.analyze(mem) self.assertEqual(table[0xf000].name, "print")
def test_analyze_doesnt_make_symbol_for_jump_to_mid_Instruction(self): table = symbols.SymbolTable() analyzer = symbols.SymbolCreatingAnalyzer(table) mem = memory.Memory(bytearray(0x10000)) intable = disasm.Instruction(opcode=0x31, operands=( 0xaa, 0xbb, ), addr_mode=AddressModes.Absolute) self.assertTrue(len(intable), 3) mem.set_instruction(0xF000, intable) self.assertTrue(mem.is_instruction_start(0xF000)) self.assertTrue(mem.is_instruction_continuation(0xF001)) mem.annotate_jump_target(0xF001) # middle of Instruction analyzer.analyze(mem) self.assertEqual(table._symbols_by_address, {}) # xxx add accessor