Resurrecting the x816 cross-assembler

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Resurrecting the x816 cross-assembler

Post by calima »

byuu wrote:
Overall it does seem like the development scene is pretty slow even compared with the NES and Mega Drive, never mind the C64...
There's been a persistent barrier in that even the best, structured 65816 code is basically a write-only language (I've had to abandon several fan translations due to code rot.) And the CPU is just too slow and too limited (*one* accumulator, *two* index registers, awkward 8/16-bit toggling) to pull off a higher level language.

What has made the Mega Drive a breakout hit in homebrew is that you can write the non-critical sections in C. Any attempts at C with the 65xx chips produce unusably slow code.
I disagree. The 816 is relatively suitable for C, its stack modes in particular are useful for that; not as well as m68k, but far from unusable. I have several titles shipped in C for the NES, and Little Medusa for SNES, and given it's not unusably slow for NES, how could it be for the 1.5-2x faster SNES?

It's not the lack of suitability, but the lack of a compiler. Genesis has the latest GCC, arguably the best compiler in the world. SNES has nothing*, though I managed to use cc65 on it, cc65 doesn't count as a "real" SNES compiler in that it doesn't support it fully. It works, but it produces 8-bit code, which is not as fast as it could be on a 16-bit processor.

You can expect more SNES titles now that we have cc65 set up. Even with its limitations, it's a massive productivity improvement over asm.

*No, the WDC blob does not count. See previous threads.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Resurrecting the x816 cross-assembler

Post by Oziphantom »

while I will agree that 65816 is not the most readable language, and write only as you put it. I will however point out that 65816 is good solid chunk a head of 6502 in this regard, and the superlative specs of the SNES make it less of an issue compared to a C64.
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: Resurrecting the x816 cross-assembler

Post by Banshaku »

@Calima

I'm curious regarding your cc65 comment for the snes. What are the limitation to expect? Since I like more and more to write c code for the nes the logical thing would be to write some for snes too but it's always good to be aware about the trade off to do so.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Resurrecting the x816 cross-assembler

Post by calima »

In general, cc65 is limited in that it's not a C-level optimizing compiler. It just translates what you write, and applies some asm-level optimizations. SNES specifically, it doesn't do banking, but just like with NES banking, you can work around that, with trampolines for example.
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: Resurrecting the x816 cross-assembler

Post by Banshaku »

For banking that is not a big issue. What I would be more concerned is the comment about 8 bit generated code. That seems not much convenient. For UI screen it may be ok but more intensive code, I guess it need to be written in asm anyway.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Resurrecting the x816 cross-assembler

Post by Oziphantom »

yeah so not, direct banking, no 16bit code, not ,s stack relative commands, no faster 65816 versions of opcodes, the 65816 has a 6502 emulation mode.


How do you make a trampoline on the SNES, it doesn't have banking registers. Does CA65 at least you do something like

Code: Select all

_asm {
  JSL function
}
I guess it also forces you into LOROM only?

Honestly if you want to use C on the SNES you would be better of using the OCRA/C https://github.com/byteworksinc/ORCA-C it will at least make native 65816 code and use ,s
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Resurrecting the x816 cross-assembler

Post by calima »

ORCA-C's license has a no commercial use clause. That's a dealbreaker, so I didn't even look further at what it might be able to do.

When told to compile for 816, cc65 uses the best instructions it knows, which are the 65c02 extensions IIRC. Thus the code is better than when targeting NES, even if it doesn't know about 816-exclusive instructions. cc65 allows inline asm, and a SNES trampoline might work by a jump table, but many other ways too. Lorom yes, since it expects RAM in the same address space. It does not use the 6502 emulation mode, it runs natively, meaning any asm functions you've written can use anything new.

That's not much different from the NES; the speed-requiring functions are written in asm and everything else in C.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Resurrecting the x816 cross-assembler

Post by Oziphantom »

but does it understand 65816 asm or only 65c02 asm?

Also the ORCA suite is available to purchase https://juiced.gs/store/opus-ii-software/ which given its a language development suite would be fine for commercial purposes.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Resurrecting the x816 cross-assembler

Post by calima »

Yes, a paid version would not have that limitation. It would then still need to run on an Apple II (emulator), you couldn't change it, etc. which may not be obstacles to you.

cc65 inline asm passes it verbatim. ca65 supports 65816 fully.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Resurrecting the x816 cross-assembler

Post by lidnariq »

Oziphantom wrote:but does it understand 65816 asm or only 65c02 asm?
calima wrote:cc65 inline asm passes it verbatim. ca65 supports 65816 fully.
To expand on this, cc65 just generates asm, not an object file. So any inline asm simply doesn't get translated from C to asm, instead being copied over.
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: Resurrecting the x816 cross-assembler

Post by Banshaku »

I guess for my current needs cc65 is more than enough. I'm not ready to jump on a snes project yet but I may want someday to experiment a little bit so this could be what I'm looking for.

Maybe by the time I really make some project some new compiler etc may comes out, who knows? I'm used to take long break so I'm in no rush :D
Post Reply