asm-differ
asm-differ copied to clipboard
Template symbols produced by MWCC diff incorrectly
The instructions in this image may be using https://github.com/simonlindholm/asm-differ/blob/main/diff.py#L3113 and https://github.com/simonlindholm/asm-differ/blob/main/diff.py#L3114.
split_off_address handles instructions with address immediates (generally branch instructions).
The line is split by a comma in split_off_address. We want the entire address/symbol to be diffed for highlighting rather than just a part of it.
def split_off_address(line: str) -> Tuple[str, str]:
"""Split e.g. 'beqz $r0,1f0' into 'beqz $r0,' and '1f0'."""
parts = line.split(",")
if len(parts) < 2:
parts = line.split(None, 1)
if len(parts) < 2:
parts.append("")
off = len(line) - len(parts[-1].strip())
return line[:off], line[off:]
This image shows that when the first part of the template split by the comma differs, the line is not highlighted.
When the 2nd part of the template differs (split_off_address):