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

Enhance .sym file for bank switching #1

Open
thrust26 opened this issue Aug 29, 2019 · 7 comments · Fixed by #142
Open

Enhance .sym file for bank switching #1

thrust26 opened this issue Aug 29, 2019 · 7 comments · Fixed by #142
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@thrust26
Copy link
Member

It would be nice if the labels in the .sym file would contain bank information. That would make debugging of bank-switched files in Stella much easier.

Maybe one could add some pseudo-op (like SUBROUTINE) which defines the start of a new bank. And then generate a .sym file which outputs the bank too.

@thrust26 thrust26 added the enhancement New feature or request label Aug 29, 2019
@andrew-davie
Copy link
Member

andrew-davie commented Aug 29, 2019

Here is the macro from Boulder Dash/Sokoboo that does this for anyone wanting to do it before DASM is updated with this capability.

    MAC DEFINE_SUBROUTINE               ; name of subroutine`
BANK_{1}        = _CURRENT_BANK         ; bank in which this subroutine resides`
                SUBROUTINE              ; keep everything local`
{1}                                     ; entry point`
    ENDM

If DASM auto-generate the BANK_* as per the above. Then Stella could be modified to recognise banks. Instead of BANK_* though, perhaps something like __BANK_* to avoid clashing with names. Introduce a standard convention (say, double-underscore) to identify auto-generated DASM labels?

One gotcha, though - in the case where self-modifying code is copied to multiple RAM banks - then the __BANK_* is invalid, so we should be careful NOT to prevent Stella from having alternate banks attached to labels (including multiple banks to a single label).

@msaarna
Copy link
Member

msaarna commented Jan 21, 2020

If this can be done with a macro, is there a reason why we need to embed this functionality directly into dasm? If it can be done with a macro, it would be better to leave it there.

Is there an envisioned convenience, or some additional functionality embedding would give, that I'm missing? (bear in mind that any bank-aware dasm enhancement needs to be applicable to other supported platforms, in addition to the wide variety of 2600 schemes.)

@thrust26
Copy link
Member Author

thrust26 commented Feb 4, 2020

The idea is to define a standard, which Stella can understand and use for its disassembly. Currently an address in a .sym file is just that, an address. Which can be used in multiple banks. Then Stella's debugger does not know which label to display. Adding pseudo ops would allow DASM to create better .sym files and allow the debugger to create better disassemblies.

The burden would be solely on the developer, so DASM does not be aware of any bankswitching methods.

BTW: The same would be helpful for constants and variables too. Currently we also have clashes in the Stella debugger for these. And I am sure the same can happen for other platforms too.

@dionoid
Copy link
Member

dionoid commented Apr 22, 2020

I'm confused: It looks like Stella already can detect different address-ranges for each bank, however it only uses labels for the first bank in the Disassembly tab. So it this a bug in Stella?

Example: I have a F8 game, for which I did RORG $1000 for the first bank, and RORG $3000 for the second bank.
Now the .sym file contains the labels with the correct addresses (either TIA/RIOT labels, or my own labels in the ranges $1000-$1ffff or $3000-$3fff).
When I open the Stella Debugger mode, it knows that this is an F8 cartridge, and even shows the correct address ranges $1000-$1ffff and $3000-$3fff:
image

However, when I go to the Disassembly tab, I only see labels from Bank 0. So also when I step into Bank 1, I see the (wrong) Bank 0 $1000-$1ffff labels, instead of the labels from Bank 1 $3000-$3ffff.

I have the feeling that I'm missing something :-)

@thrust26
Copy link
Member Author

Stella's disassembler (DiStella) is not well prepared for multi bank or multi segments ROMs. It "somehow" works, but is not 100% reliable.

dionoid pushed a commit that referenced this issue Aug 8, 2020
dionoid pushed a commit that referenced this issue Sep 16, 2020
dionoid pushed a commit that referenced this issue Oct 17, 2020
@thrust26
Copy link
Member Author

thrust26 commented Jun 2, 2023

Would it be easily possible to add an option to output symbols ordered by their definition appearance in the code?

@thrust26
Copy link
Member Author

thrust26 commented Jun 3, 2023

I went for it and created a pull request (not sure why the MacOS build doesn't want to start).

@dionoid dionoid added this to the 2.20.15 milestone Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants