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

ca65: HuC6280 zero-page is at $2000 and not at $0000 #317

Open
jbrandwood opened this issue Jun 30, 2016 · 3 comments
Open

ca65: HuC6280 zero-page is at $2000 and not at $0000 #317

jbrandwood opened this issue Jun 30, 2016 · 3 comments

Comments

@jbrandwood
Copy link
Contributor

@jbrandwood jbrandwood commented Jun 30, 2016

CA65 currently assumes that zero-page/direct-page references resolve to absolute address $0000-$00FF.

This isn't correct on the HuC6280 where zero-page/direct-page references resolve to absolute addresses $2000-$20FF.

This leads CA65 to generate inefficient/wrong code for instructions referencing addresses $0000-$00FF and $2000-$20FF on the HuC6280.

I'm adding a pull request for a fix to this that differentiates between instructions with one-byte immediate operands that are always $0000-$00FF (handled by the existing old Emit1() function), from instructions that have one-byte direct-page/zero-page references where the top-byte of the address is different on different processors (handled by the new EmitZP() function).

EmitZP() is just a copy of the existing Emit1() function but with the check for the top-byte changing depending upon the currently-selected processor.

@jbrandwood
Copy link
Contributor Author

@jbrandwood jbrandwood commented Jun 30, 2016

Added pull request #318

Loading

@jbrandwood
Copy link
Contributor Author

@jbrandwood jbrandwood commented Jun 30, 2016

Withdrawn the pull request.

Travis CI has shown an unintended side-effect of CA65's expression handling that this patch trips up on.

The issue remains, but the "fix" needs more thought.

Loading

@jbrandwood
Copy link
Contributor Author

@jbrandwood jbrandwood commented Jul 4, 2016

Added new Pull Request #319, with notes on the fix.

The only "safe" solution that I've been able to come up with causes the HuC6280 to assemble zero-page instructions for both $0000-$00FF and $2000-$20FF.

This isn't perfect, but it is acceptable because the PC Engine doesn't ever need to access $0000-$00FF if the VDC is accessed through one of its mirror locations in $0100-$03FF.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants