Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template symbols produced by MWCC diff incorrectly #171

Open
1superchip opened this issue Oct 7, 2024 · 0 comments
Open

Template symbols produced by MWCC diff incorrectly #171

1superchip opened this issue Oct 7, 2024 · 0 comments

Comments

@1superchip
Copy link
Contributor

1superchip commented Oct 7, 2024

image

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.
image

When the 2nd part of the template differs (split_off_address):
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant