I've been working on an FPGA-based 6502 system as described in this thread ->
viewtopic.php?f=10&t=5559I'm using cc65 built directly from git (
https://github.com/cc65/cc65 ) on a Fedora linux system to compile C for the ROM in the FPGA using the suggestions on the wiki for creating a custom target and I've generally been successful as long as I don't try to do anything too fancy - simple counters, GPIO and basic text printing with strings. I'm trying to expand the functionality of the system with a command line parser similar to things I've done before using code that relies more heavily on the C library functions like strtok() etc. and I'm running into weird problems. At first I thought it might have to do with my ACIA ISR trashing the C software stack so I rewrote the ISR entirely in assembly, but I'm seeing the exact same problems.
For example - when trying to use strtok() to parse a string containing "this is a test" on a delimiter of " ", instead of getting four tokens "this", "is", "a", "test" I get instead "is is a test", " is a test", "s a test", etc - the tokens are just spaced at intervals of two characters for every call to the function.
So the question is - what am I doing wrong? Is the cc65 C library well tested and I'm just screwing up in the way I'm using it, or is it unreliable and I should just be doing everything in assembly? I've read through some of the articles on the wiki and am aware of some of the suggestions for accommodating the shortcomings in the compiler, but even with those usage changes it seems things are still not working as they ought to.
Thanks for any insight.