Hello,
A few days ago I downloaded the wdctools package to try out the c-compiler for the 65816. I know that most people seem to prefer assembly for this CPU, but that is just a bridge to far for me. Also I have to port some existing c-code and even that is outside my normal comfort zone as I mostly work with the more "modern" high level languages in my day to day
.
I more or less got my "hello world" sample to run in the simulator. Now I want to get the interrupts to work, but between the "not so great" manual and my limited c experience I'm running into problems I do not understand. Hopefully someone here knows how this tool-set works and give me some assistance.
I created this simple C-file. It has a counter loop so I can see something happening in memory while simulating. The IRQ section is straight from the manual, I only added a tab before both assembly lines to prevent another error from the compiler. I guess the manual is wrong there to...
Code:
int far Int_happened = 0;
int far counter = 0;
int far dummy = 0;
interrupt void IRQHandler(void)
{
Int_happened = 1;
}
#asm
org $ffee ; 65816 IRQ vector
dw ~~IRQHandler
#endasm
void main(void) {
// Infinite loop
while(1) {
counter++;
dummy = counter;
if (dummy == 200)
dummy = 0;
}
}
If I comment out the #asm -#endasm section it compiles fine and runs in the simulator using:
wdc816cc -ML simple.c -bs
wdcln -HZ -G -V -T -P00 simple.obj c0l.obj -LCL -O simple.bin
wdcdb simple.bin
The manual says the raw asm startup code from c0l.obj should be available in the tools package but only the object file is in the lib folder. I tried to contact support but no response so far.
Does anybody here know how to help me define the interrupt routine properly using the wdc startup code for the large memory model?
Must be something simple I'm missing, but I cannot seem to figure it out at the moment.