Add brl long branch ($82) to the assembler - #90
Merged
Merged
Conversation
The disassembler already knew $82; the opcode table lacked it, forcing jmp.w for long intra-routine jumps. brl stays PC-relative (16-bit signed, +/-32K), so it never touches the symbol table.
Deploying a816 with
|
| Latest commit: |
e9f2d53
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8772b65a.a816.pages.dev |
| Branch Preview URL: | https://feat-brl-long-branch.a816.pages.dev |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why
brl($82) — the 65816's unconditional 16-bit PC-relative branch (±32 KB) — was assemble-unsupported. The disassembler already decoded it (0x82: ("brl", RELATIVE_LONG, 2)), but the opcode table had no entry, so you could readbrlbut not write it.The consequence: a long intra-routine back-edge (loop body > 127 bytes, past
brarange) had to usejmp.w <local>— absolute, deferred to the linker, touching the symbol table. That's the exact path behind the recently-fixed local-label collisions (#88, #89).brlis the correct primitive: PC-relative, resolved in-section at assemble time, layout-invariant, never consults a symbol — immune to that whole class.Closes the "natural fix" the jmp.w-local report flagged.
What
RelativeJumpOpcodeparametrized by offset width (OFFSET_BYTES); displacement =dest - pc - (1 + OFFSET_BYTES). Existing 8-bit branches unchanged.RelativeLongJumpOpcode(2-byte signed offset, range ±32767) →brl=$82.Test plan
brl <backward label>/<forward label>encode82 lo hiwith the correct signed-16 displacement, both directions.bra/bcc/…) still encode identically (shared, re-parametrized path).