| 483 | return instr, operand, length, value |
| 484 | |
| 485 | def get_instruction_info(self, data:bytes, addr:int) -> Optional[InstructionInfo]: |
| 486 | result = M6502.decode_instruction(data, addr) |
| 487 | if result is None: |
| 488 | return None |
| 489 | instr, operand, length, _ = result |
| 490 | assert length is not None |
| 491 | result = InstructionInfo() |
| 492 | result.length = length |
| 493 | if instr == "jmp": |
| 494 | if operand == ADDR: |
| 495 | result.add_branch(BranchType.UnconditionalBranch, struct.unpack("<H", data[1:3])[0]) |
| 496 | else: |
| 497 | result.add_branch(BranchType.UnresolvedBranch) |
| 498 | elif instr == "jsr": |
| 499 | result.add_branch(BranchType.CallDestination, struct.unpack("<H", data[1:3])[0]) |
| 500 | elif instr in ["rti", "rts"]: |
| 501 | result.add_branch(BranchType.FunctionReturn) |
| 502 | if instr in ["bcc", "bcs", "beq", "bmi", "bne", "bpl", "bvc", "bvs"]: |
| 503 | dest = (addr + 2 + struct.unpack("b", data[1:2])[0]) & 0xffff |
| 504 | result.add_branch(BranchType.TrueBranch, dest) |
| 505 | result.add_branch(BranchType.FalseBranch, addr + 2) |
| 506 | return result |
| 507 | |
| 508 | def get_instruction_text(self, data: bytes, addr: int) -> Optional[Tuple[List[InstructionTextToken], int]]: |
| 509 | result = M6502.decode_instruction(data, addr) |