6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat May 25, 2024 9:06 am

All times are UTC




Post new topic Reply to topic  [ 82 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6
Author Message
PostPosted: Mon Oct 24, 2022 3:25 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
i would still recommend going to the github and have the dev himself take a look at it. as i've never dabbled with interrupts with C (except for arduino stuff).


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 24, 2022 6:06 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8191
Location: Midwestern USA
arrow201 wrote:
Following up to my previous post, I have a home brewed 65C02 from the late 1980s...Next is interrupts. I don't know, but it seems setting up the IRQ will not work the way I want it to using the attribute commands or modifying the interrupt.h(which appears to have been made for the C64?)

What Proxy said about contacting the Calypsi developer.

I do not recommend using C to write an interrupt service routine (ISR) for the 65C02. The resulting machine code will be larger and slower compared to the assembly language equivalent. Some parts of an ISR may be time-critical, e.g., processing UART interrupts, which won’t mesh well with the capabilities of a typical C compiler targeting the eight-bit 6502 family.

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 24, 2022 6:16 pm 
Offline

Joined: Fri Jul 03, 2020 2:44 pm
Posts: 8
Thank you guys for your responses. :) Yes, after posting, I sent an email to the developer, pointing him to my post. Hopefully, he'll respond back here so everyone benefits. If not, and emails me directly, I'll repost any answers from the developer. BigDumbDinosaur( :) ), thank you, yes, I agree with you, but I would just like to see it work. :)

Thanks!


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 26, 2022 5:34 am 
Offline

Joined: Sun Oct 07, 2018 6:04 pm
Posts: 30
The load to 0x1000 looks right, that is the best way of doing it, using a custom named section and placing it at the address in the linker rules file.

You can define an interrupt function using the interrupt attribute:

Code:
__attribute__((interrupt))
void MyIRQ() {
  // some code
}


The compiler will take care of saving registers and generating the RTI instruction at the end.

Inline assembler is not currently supported. I have no immediate plans to implement it. Currently you need to separate C and assembly in different source files. If there is any specific reason/use-case you have for it, let me know. You can call functions written in assembler and the compiler should be able to handle at least some stuff you might want it for, using interrupt functions as shown above and by intrinsic functions (see the user guide and the provided header file intrinsics6502.h).


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 26, 2022 5:38 am 
Offline

Joined: Sun Oct 07, 2018 6:04 pm
Posts: 30
Regarding interrupts in C. If you do it, avoid making function calls as that will generate a lot of save overhead. Well, you can make calls to small functions provided that they are inlined. Refer to the user guide about inlining and how to control it (to some degree).


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 26, 2022 3:00 pm 
Offline

Joined: Fri Jul 03, 2020 2:44 pm
Posts: 8
Thank you much for your help :) I didn't realize that one can just put __attribute__((interrupt)), I thought an address was required.
As for inline asm, I can only think the use would be to save on overhead JSR/RTS calls, especially if it's just a few instructions.

Regarding calling asm from C(manual Sections 18.2/18.3), I'm not sure I totally get it since I have thick skull. :) Example: Say I want to pass the address to an asm function, would I do:
.c
Code:
extern void MBII_Display(uint16_t *pData);

int main ()
{
   const char Data[6] = "Hello";   

   MBII_Display((uint16_t *)&Data);
...
}

.s
Code:
; MBII_API.s
;
   .section code
   .extern _Zp ; pseudo zero page registers   

   .public MBII_Display
MBII_Display:
      pha
      ; store the Data addr at $00C8/$00C9
      lda zp:_Zp
      sta 0xC8
      lda zp:_Zp+1
      sta 0xC9
      jsr   0xE042    ;display the null terminated chars who's address is at $00C8/$00C9
      pla
      rts

Thanks!

* UPDATE * - the above is correct. If passing down a byte it will use the accumulator, after that or if passing a 16 bit var, it'll use the _Zp pseudo registers, as per the 6502 guide. This info can be found at 18.3 Calling convention (P.94) (for v.3.6.10)
I haven't written anything huge, only test programs, but find this compiler works very well. Simple VIA(6522) port toggling, and counter IRQs. Sounds via a PSG(AY-3-8910), serial and memory tests all work without a hitch. :)
Thanks guys for your help! :)


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 16, 2023 8:06 pm 
Offline
User avatar

Joined: Tue Aug 14, 2012 12:47 pm
Posts: 18
Location: Austria - Vienna
BillG wrote:
I thought I felt my ears burning...
[..]
https://www.lucidtechnologies.info/6803_instr.pdf


Meanwhile reachable only at https://web.archive.org/web/20211126214 ... _instr.pdf


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 82 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6

All times are UTC


Who is online

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