Regarding cc65, I have a conumdrum.
I've gotten it to produce an EEPROM image(using the toolchain as intended is far easier than trying to belt it into submission), but it does not produce code that works. This code looks like it should work, even in the disassembly. I have code assembled using another tool that does work on the same hardware, and that is far more complex than what I am trying to get cc65 to produce.
It appeared to be messing up around the first subroutine call initially, so I probed around that area, and it turns out that it was ending up with a return address of zero, somehow. The stack pointer was in the right place, too. That explains why it went comatose. (I've got a write-up of a small battery of tests I conducted that I can produce if it's helpful).
I am now trying to explain why the stack appears to be getting fouled, and this is giving me something of a problem. I have used this code to test it:
Code:
_init: CLI
CLD
LDX #$FF
TXS
;The VIA in my system is mapped to $7FEx
STX $7FE2 ;VIA.DDRB
STX $7FE3 ;VIA.DDRA
STX $7FEC ;VIA.PCR
LDA #$AA
STA $01FF
LDA #$55
STA $01FE
LDA $01FF ;low byte
STA $7FE0
LDA $01FE ;high byte
STA $7FE1
STP
This should have resulted in $AA55 being displayed on LEDs that I have connected to the VIAs output ports(I have them arranged the other way around). Free-running it resulted in $0000 being displayed. Single-cycling revealed that the 65c02 was writing and reading the RAM correctly, but it was writing $0000 to the VIA. I'd reverse-volted the whole thing recently, and it was suggested that there could be subtler damage.
I suspected that A might have been broken, but that doesn't hold water, because the immediate loads work out completely fine, and when I run a program that does the same thing, but without clobbering the stack first, it works. I also tried the EEPROM version using Y instead of A, but it had the same result. I did not single-step that version, because it took quite a while to do the first one.
I've been using seperate EEPROMs for cc65 and the existing firmware, so I don't have to keep re-writing it. I don't have duplicates of any of the other silicon, though.
Does anyone have any ideas as to what could be causing this, and as to ways I could test things(the program, hardware, and/or toolchain) to see what's going wrong. Because I don't know what's going on with the stack there, or where the problem really lies.