Skip to content

Confusing instruction line highlight #30

Closed

Description

@brunobord

Using the interactive terminal mode, sometimes, the highlighted line does not correspond to the instruction that is ready to be executed, which may confuse the user.

Most of the time, it's right after a jmp instruction, or a BRNE, for example.

For example with this program

1: ldi r16, 10
2: loop:
3: dec r16
4: brne loop
5: done:
6: jmp done

Steps:

  • 0 - Highlight at line 1, ldi instruction
  • 1 - Highlight at line 5, dec r16
  • 2 - Highlight at line 1 (ldi r16, 10), but the first line of the CLI output says the instruction is BRNE loop, which is at line 6.
  • 3 - Highlight at line 3, dec r16 instruction.
  • ... it goes on until the Z flag is set and thus, it breaks out of the loop
  • 21 - Highlight at line 4 (brne loop), but the 1st line of the CLI output says that the instruction is JMP done.

So that's a strange behaviour. Sometimes, the highlight is on the instruction that is just about to be executed, and some other times, it's the instruction line right before this one.

Do you think it can be improved in a way or another?

Activity

  1. sql-hkr commented on Nov 12, 2025

    @sql-hkr
    Owner

    Thanks for the report!

    The highlight mismatch happened because we looked up the source line after executing instructions. Branch/jump instructions change PC, so the highlight sometimes pointed to the wrong line.

    Fix: save PC before execution and use it to look up the source line. Now the highlight always matches the instruction being executed.

  2. added a commit that references this issue on Nov 12, 2025
  3. linked a pull request that will close this issuefix: terminal highlight (#30) #31on Nov 12, 2025
  4. added a commit that references this issue on Nov 12, 2025
  5. brunobord commented on Nov 12, 2025

    @brunobord
    Author

    thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions