SNES in CA65: Long Instructions Help

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
User avatar
Posts: 7738
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada

Re: SNES in CA65: Long Instructions Help

Post by rainwarrior » Wed May 01, 2019 12:41 am

I think I have a fix for the bug where you declare a segment as .far too late in the file for the first pass to catch it:

I don't have a lot of internal cc65 experience, so I'm not 100% confident it's a complete solution to that bug, but it passes my own tests and doesn't fail cc65's regression test suite. Binary build is attached if anyone wants to help give it a test.

All the above suggestions still apply, this has nothing to do with having the assembler understand DP/DB, but I think it addresses the critical error of accidentally generating 16-bit addresses where you wanted 24-bit.

Basically as long as a label is in a :far segment it should be error checked for you now, regardless of whether it's declared above or below. The default addressing is still 16-bit (as it should be), but if the symbol isn't declared as far before its used, you'll get a range error because it would have assumed the default, which you can quickly resolve by adding a f: prefix on the operand (or e.g. using JSL instead of JSR).

Also note that if you use .global : far as a forward declaration, the .segment the label is in still has to be : far. Segment overrides import/export declarations. (This is good, though, it means you can use a symbol as a near address within the file, then .export it with a far address to be used elsewhere.)
(431.81 KiB) Downloaded 166 times

Post Reply