Just in-case this bites anyone else (highly unlikely, but you never know), I'd suggest that anyone using the cc65 package make sure they're up to date - especially if using ca65 and Sweet16.
There is a bug (Really probably a typo) in the original version held at
https://www.cc65.org/ involving the Sweet16 BS (Branch to Subroutine) operation - it generates the wrong opcode ($0B which is RS; Return from Subroutine) rather than the correct $0C...
I've upgraded to the latest at
https://github.com/cc65/cc65 - web page:
https://cc65.github.io/ and it's doing the right thing.
Cheers,
-Gordon
_________________
--
Gordon Henderson.
See my
Ruby 6502 and 65816 SBC projects here:
https://projects.drogon.net/ruby/