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

Feature Suggestion: Add ability to declare labels for defined ranges (i.e. per-subroutine Zero-Page local variables) #20

Open
phillipeaton opened this issue Feb 7, 2023 · 2 comments

Comments

@phillipeaton
Copy link

phillipeaton commented Feb 7, 2023

The 6502 CPU doesn't have many registers, but Zero-Page memory would appear to be used by many programs to perform a similar function to registers.

In practice, this means that many program subroutines use the same Zero-Page memory locations for different short-term purposes (i.e. like a register or local variable), such that you are not able to globally label some Zero-Page memory locations for any given program with useful names, when using dasmfw.

A clunky workaround I'm using is to run a sed script (see listing) on the output from dasmfw to insert additional EQUs with extended names (lines 3-12) and update the usage of the plain ZPnn labels with the extended names on a particular range of addresses ($3601 to $3734, lines 15-24).

(It's possible that dasmfw multilabel functionality provides this local label ability, but I can't figure out how it works.)

image

Additional Info: I've learned that the 6502bench disassembler program has functionality that inserts locals into the listing, as can be seen in the picture below; $98 and $99 are used in many places throughout this assembly listing, with different names each time. It's documented here: https://6502bench.com/sgtutorial/local-variables.html

image

Thanks for reading.

@Arakula
Copy link
Owner

Arakula commented Feb 7, 2023

Definitely a good idea. Unfortunately, I'm currently deep into other things, so it will take a while until I could do anything about it.

Syntax could be something like
locallabel addr[-addr[/step]] addr[-addr] name
where the first range defines the region in which the second address range is mapped to name.
This would then insert the local label declaration directly before the disassembly of the first range and use it from there on until the end end of the first range (or EOF, if only a start is given).

Should do it, I think. Thoughts?

@phillipeaton
Copy link
Author

phillipeaton commented Feb 7, 2023

Thanks for the positive feedback, your proposal sounds pretty good to me. You could use local[label], like used[label], which would save some typing. We'll see what the spacing looks like when implemented.

Good luck with whatever else you're working on, I'll get by with sed for now 👍

FWIW, my setup is getting quite structured now:
image

This is half of my dasmfw output:
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

2 participants