6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 22, 2024 6:25 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Interrupts in cc65
PostPosted: Sun Sep 20, 2015 5:57 pm 
Offline

Joined: Mon May 25, 2015 1:12 pm
Posts: 92
I've been messing with interrupts written in C using cc65 as well as in Assembler. Trouble is that I very frequently just don't get sensible results with C. I suspect that I'm messing up the parameter stack. I'm hoping someone could post a succinct little example or put me out of my misery and tell me it's pointless and stick to assembler.


Top
 Profile  
Reply with quote  
 Post subject: Re: Interrupts in cc65
PostPosted: Sun Sep 20, 2015 8:55 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
DigitalDunc wrote:
I've been messing with interrupts written in C using cc65 as well as in Assembler. Trouble is that I very frequently just don't get sensible results with C. I suspect that I'm messing up the parameter stack. I'm hoping someone could post a succinct little example or put me out of my misery and tell me it's pointless and stick to assembler.

My recommendation is to write your interrupt service routines in assembly language. C will never produce the succinct code that should be in an ISR, plus there is the issue of what C is doing stack-wise.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: Interrupts in cc65
PostPosted: Mon Sep 21, 2015 4:45 pm 
Offline

Joined: Mon May 25, 2015 1:12 pm
Posts: 92
That's what I've been suspecting all along. Frankly the code I've seen emitted by cc65 looks plump and slow. Just like I'll be if I keep on eating the donuts. First I'm teased by the hints in the documentation and then I'm bludgeoned by the clubs of reality.


Top
 Profile  
Reply with quote  
 Post subject: Re: Interrupts in cc65
PostPosted: Mon Sep 21, 2015 5:21 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1738
Location: Sacramento, CA
I have never used the CC65 interrupt mechanism. I have used timers to provide periodic ticks for the clock function, but chose to handle them outside of CC65 in assembly.

It seems most feedback is that CC65 interrupts are not practical, as the overhead is too big and cumbersome.

However, I did find 1 tutorial on the web that may help you - it's for a Lynx system, but you might get something from it:

https://atarilynxdeveloper.wordpress.co ... nterrupts/

Daryl

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Interrupts in cc65
PostPosted: Tue Sep 22, 2015 6:02 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
DigitalDunc wrote:
That's what I've been suspecting all along. Frankly the code I've seen emitted by cc65 looks plump and slow. Just like I'll be if I keep on eating the donuts. First I'm teased by the hints in the documentation and then I'm bludgeoned by the clubs of reality.

If you are a reasonably proficient assembly language programmer then you shouldn't have much trouble writing an ISR. You need to be meticulous in planning for all possible cases in your code and massage it until it is as efficient as possible. It's really not all that difficult.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: Interrupts in cc65
PostPosted: Tue Sep 22, 2015 6:29 am 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 452
Location: Canada
For some of the FPGA based 6502's which run upwards of 100 MHz writing an interrupt routine in 'C' might look more appealing. The processors probably have sufficient performance to support it. I'm not sure what facilities there are to support interrupt routines in cc65. Does it have an interrupt specifier for function ? Interrupt routines should end with an RTI instruction.
I usually write interrupt subroutines in assembler initially to keep things simple. Later I go back and re-write them in a mix of C and asm with asm() statements as more complexity and functionality is required.

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
 Post subject: Re: Interrupts in cc65
PostPosted: Tue Sep 22, 2015 6:32 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
I saw this on the wiki: http://wiki.cc65.org/doku.php?id=cc65:i ... dlers_in_c


Top
 Profile  
Reply with quote  
 Post subject: Re: Interrupts in cc65
PostPosted: Tue Sep 22, 2015 5:17 pm 
Offline

Joined: Mon May 25, 2015 1:12 pm
Posts: 92
Thanks guys, I knew I could count on you. I'll have another play at the weekend and keep you posted on my progress. One key ingredient of my interrupt is a free running counter for non blocking delays. Can't have the 6502 twiddling it's thumbs all the time y'know.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 25 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: