6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 20, 2024 8:34 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: cc65 weirdness
PostPosted: Sun Mar 10, 2019 3:44 am 
Offline
User avatar

Joined: Fri Mar 08, 2019 4:16 pm
Posts: 28
I've been working on an FPGA-based 6502 system as described in this thread -> viewtopic.php?f=10&t=5559

I'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.


Top
 Profile  
Reply with quote  
 Post subject: Re: cc65 weirdness
PostPosted: Sun Mar 10, 2019 4:07 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1738
Location: Sacramento, CA
I've used the Windows compiled version to build Adam Dunkels' uIP for my SBC's. I cannot speak to what routines it uses, but it worked well for me in that instance.

I cannot offer any solutions to the issues you are seeing.

Good luck!

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
 Post subject: Re: cc65 weirdness
PostPosted: Sun Mar 10, 2019 5:32 am 
Offline
User avatar

Joined: Fri Mar 08, 2019 4:16 pm
Posts: 28
OK - I figured it out. Me being dopey:

The tutorial I used to set up my cc65 target was https://cc65.github.io/doc/customizing.html which is based on the "supervision" target that uses a 65C02. My system is based on Arlet Otten's Verilog model of the baseline 6502, so the library I used was for the wrong CPU. Tweaking the library setup instructions to use the "none" target which is for a plain 6502 fixed my problem with the strtok() function.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 45 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: