fadden / 6502bench

A workbench for developing 6502 code
https://6502bench.com
Apache License 2.0
166 stars 33 forks source link

How does 6502bench handle Zero Page storage used for multiple purposes #142

Closed phillipeaton closed 1 year ago

phillipeaton commented 1 year ago

Hello, I'm currently using dasmfw disassembler to reverse engineer the game JETPAC for the VIC-20. This is the first 6502 program I've worked on. It works similar to 6502bench, albeit without the interactive GUI.

I've tended to use "code block" comments (i.e. code description comments in a few lines preceeding the code in question) and long variable and label names to explain what the code is doing, instead of individual line comments on the right hand side of the listing.

Something that's causing me a problem is that this game uses the Zero Page storage locations for multiple different things, almost like subroutine local variables/registers, so giving a Zero Page address a meaningful label isn't really possbile. As a workaround, I'm using GNU 'sed' to modify the created source code to contain local named Zero Page address labels, which is a bit clunky.

Assuming this makes sense to you, I'm interested to know how 6502bench would handle this?

Thanks!

fadden commented 1 year ago

Multi-line block comments are supported; they're just called "long comments". SourceGen will even put a nice box of asterisks around them for you. :-)

Per-subroutine zero-page local variables are supported. They're demonstrated briefly in one of the advanced tutorial sections.

For example, if you scroll up a bit here you can see $98/$99 defined to be temp/saved_y, and then a couple of pages down you can see them redefined as small_part/large_part. The symbols are valid until they're redefined or you clear the table.

I tend to show them prefixed with ']', but that's configurable, and may be completely different in generated assembly output. (Most assemblers have this feature, but ACME is a bit rough.)

phillipeaton commented 1 year ago

Thanks for the detailed answer, I had a quick look at the code and it looks like a clean solution. I'll check out the tutorial also, that's a great help for users.