Skip to content

labels: add physical address/page operators $$$label and $$$$label, c…#329

Merged
ped7g merged 1 commit intomasterfrom
labels_ph_features_328
Apr 19, 2026
Merged

labels: add physical address/page operators $$$label and $$$$label, c…#329
ped7g merged 1 commit intomasterfrom
labels_ph_features_328

Conversation

@ped7g
Copy link
Copy Markdown
Collaborator

@ped7g ped7g commented Apr 19, 2026

Since internally these are tracked for SIZEOF implementation, it's reasonably easy to surface them to user as cross-over with already existing $$$ and $$$$ operators.

The label versions are not confined to device mode, but also the logical results come for regular labels only (for non-DISP the physical address and page is equal to regular address and page of course, inside DISP block the physical values show where the machine code landed).

For EQU/DEFL/SMC-offset labels the results are less designed and more "what happens as implementation side-effect", but they are documented by adding them to the test, so the user can actually depend on this "logic" in their own source, in case it is practical for anything.

The only really "unfortunate" behavior is struct-member-label which has physical address of the whole structure, not the member field, this is noted in test as "unfortunate" and workaround for more logical physical address of member expression suggested.

But I think I will not ever change even that, doesn't seem to be worth the extra complexity of implementation for feature which has probably no real world use case, and can be easily worked around if really needed.

Summary by CodeRabbit

  • New Features

    • Added $$$label and $$$$label operators to query physical address and page information for any label, complementing existing physical program counter operators.
  • Documentation

    • Extended label operator documentation with usage examples and semantics for non-regular labels (EQU, DEFL, SMC-offset labels).

@ped7g ped7g added this to the v1.23.0 milestone Apr 19, 2026
@ped7g ped7g self-assigned this Apr 19, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

Warning

Rate limit exceeded

@ped7g has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 2 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 43 minutes and 2 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3b765997-655a-484a-9eef-683338ce0225

📥 Commits

Reviewing files that changed from the base of the PR and between d0f2537 and 7b395ff.

📒 Files selected for processing (5)
  • docs/documentation.xml
  • sjasm/parser.cpp
  • sjasm/tables.cpp
  • sjasm/tables.h
  • tests/devices/get_label_physical_memory_operators.asm
📝 Walkthrough

Walkthrough

The pull request adds two new label expression operators ($$$label and $$$$label) to read physical address and page information for any label. Parser support, helper functions, type declarations, comprehensive documentation, and test coverage are implemented to enable this functionality.

Changes

Cohort / File(s) Summary
Documentation Updates
docs/documentation.xml
Documented new $$$label and $$$$label operators for reading physical address/page of labels, with extended narrative on semantics for special label types and reference to test file.
Label Lookup Functions
sjasm/tables.h, sjasm/tables.cpp
Added GetLabelPhPage and GetLabelPhValue helper functions to retrieve physical page and physical address values for labels, without relocation logic.
Parser Expression Handling
sjasm/parser.cpp
Extended ParseExpPrim to recognize and evaluate $$$<label> and $$$$<label> patterns by invoking the new label lookup functions.
Feature Tests
tests/devices/get_label_physical_memory_operators.asm
Comprehensive test suite covering physical label operators across multiple contexts: regular labels, .local variants, EQU definitions, DEFL behavior, STRUCT members, self-modifying code, and device-agnostic scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • labels: SIZEOF operator #325: Directly overlaps with label-table extensions and parser support for label-address operators (ph_value/ph_page and $$$/$$$$ variants).

Poem

🐰 A leap through labels, both virtual and true,
Physical pages revealed in $$$ and $$$$ anew,
From parser to tables, the address takes flight,
Each label's real home now shines crystal bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: introducing two new label operators ($$$label and $$$$label) for accessing physical address/page information, which is the primary focus of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch labels_ph_features_328

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ped7g ped7g linked an issue Apr 19, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
sjasm/parser.cpp (1)

84-89: LGTM — ordering is correct.

Placing these before the existing DISP_NONE != PseudoORG && '$' == p[0] && '$' == p[1] && '$' == p[2] branch at line 90 is the right choice: the new branches require isLabelStart(p+3) / isLabelStart(p+4), so the bare $$$ / $$$$ operators inside DISP still fall through to the existing handler, and $$<label> at line 100 is unaffected. Buffer reads of p[1..4] are safe thanks to short-circuit evaluation against the NUL terminator.

One minor nit (optional): the four-way '$' == p[0] && '$' == p[1] && ... chain duplicates logic with line 90; a small helper like dollarRun(p, n) or a precomputed count would read a bit cleaner, but given the localized scope it's fine as-is.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sjasm/parser.cpp` around lines 84 - 89, Duplicate inline checks for
consecutive '$' characters in parser.cpp can be replaced by a small helper to
improve readability; add a helper like int dollarRun(const char *p) or bool
dollarRun(const char *p, int n) and use it in the branches that currently use
chains like '$' == p[0] && '$' == p[1] ... (the branches that call
GetLabelPhPage and GetLabelPhValue and the existing DISP_NONE != PseudoORG
branch), then update those conditionals to call the helper while preserving the
existing isLabelStart(p+3)/isLabelStart(p+4) checks and short-circuit/NUL-safety
so behavior remains identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/documentation.xml`:
- Line 213: Update the changelog text to show the label operand by replacing the
zero-operand examples with the operand forms: change the occurrences that
currently read `$$$` and `$$$$` to `$$$label` and `$$$$label` respectively so
the meaning is unambiguous; edit the entry that references the link IDs
op_label_ph_val and op_label_ph_page to use these operand forms.
- Around line 1167-1168: Fix the inconsistent placeholder name by changing the
second entry’s "lb" occurrences to "lab": update the placeholder token $$$$lb to
$$$$lab, the primary token (currently $$$$label) if it contains the short name
to use $$$$label with "lab" as appropriate, and replace the quoted "lb" label
text with "lab" in the indexterm with id "op_label_ph_page" so both entries
consistently use "lab".

In `@tests/devices/get_label_physical_memory_operators.asm`:
- Around line 1-90: The test assembly file
tests/devices/get_label_physical_memory_operators.asm is missing its expected
output artifact; add a companion file with the same stem named either
tests/devices/get_label_physical_memory_operators.lst (if you want to capture
assembler listing/errors) or
tests/devices/get_label_physical_memory_operators.bin (if the asm assembles
successfully) so the test runner can validate output; place the expected listing
or binary corresponding to the assembly that defines labels like
orgL1/dispL1/Equ1/MyS2/MainLab so the test harness can compare results.

---

Nitpick comments:
In `@sjasm/parser.cpp`:
- Around line 84-89: Duplicate inline checks for consecutive '$' characters in
parser.cpp can be replaced by a small helper to improve readability; add a
helper like int dollarRun(const char *p) or bool dollarRun(const char *p, int n)
and use it in the branches that currently use chains like '$' == p[0] && '$' ==
p[1] ... (the branches that call GetLabelPhPage and GetLabelPhValue and the
existing DISP_NONE != PseudoORG branch), then update those conditionals to call
the helper while preserving the existing isLabelStart(p+3)/isLabelStart(p+4)
checks and short-circuit/NUL-safety so behavior remains identical.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 283c1201-b8a4-401d-a266-7a6977cfc5f7

📥 Commits

Reviewing files that changed from the base of the PR and between 299b826 and d0f2537.

📒 Files selected for processing (5)
  • docs/documentation.xml
  • sjasm/parser.cpp
  • sjasm/tables.cpp
  • sjasm/tables.h
  • tests/devices/get_label_physical_memory_operators.asm

Comment thread docs/documentation.xml Outdated
Comment thread docs/documentation.xml
Comment thread tests/devices/get_label_physical_memory_operators.asm
…lose #328

Since internally these are tracked for SIZEOF implementation, it's
reasonably easy to surface them to user as cross-over with already
existing $$$ and $$$$ operators.

The label versions are not confined to device mode, but also the logical
results come for regular labels only (for non-DISP the physical address
and page is equal to regular address and page of course, inside DISP
block the physical values show where the machine code landed).

For EQU/DEFL/SMC-offset labels the results are less designed and more
"what happens as implementation side-effect", but they are documented by
adding them to the test, so the user can actually depend on this "logic"
in their own source, in case it is practical for anything.

The only really "unfortunate" behavior is struct-member-label which has
physical address of the whole structure, not the member field, this is
noted in test as "unfortunate" and workaround for more logical physical
address of member expression suggested.

But I think I will not ever change even that, doesn't seem to be worth
the extra complexity of implementation for feature which has probably no
real world use case, and can be easily worked around if really needed.
@ped7g ped7g force-pushed the labels_ph_features_328 branch from d0f2537 to 7b395ff Compare April 19, 2026 20:04
@ped7g ped7g merged commit 7b395ff into master Apr 19, 2026
13 checks passed
@ped7g ped7g temporarily deployed to github-pages April 19, 2026 20:12 — with GitHub Pages Inactive
@ped7g ped7g deleted the labels_ph_features_328 branch April 19, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add $$$label and $$$$label operators

1 participant