sdcc interrupts on m6502
category: code [glöplog]
Hey! Do we have any sdcc nerds here? I can't figure out how to set interrupt vectors on the m6502 target. I've read that I need to do this:
... and that does not work. I've tried (0,1,2). I've also looked at the list of arguments for sdcc and I don't see anything about interrupts. Maybe it's a linker-script thing?
Code:
void handler(void) __interrupt(2) {
// stuff
}
... and that does not work. I've tried (0,1,2). I've also looked at the list of arguments for sdcc and I don't see anything about interrupts. Maybe it's a linker-script thing?
Hello, I do mostly z80, but:
What __interrupt() does is just tell SDCC that this should be compiled as an interrupt handler. Depending on the CPU, the function prologue (saving registers, ...) and epilogue (exact type of RET instruction used, ...) is different.
What it doesn't do is make sure the function is called when there is an interrupt. That is up to you, either in a linker script, in assembler, or by some C tricks. Basically you should make sure that 0xFFFE contains a pointer to your function.
I think you can do this if you want to do it all from C sources:
Maybe your linker script and/or startup code provides other ways to set it (for example, it will "find" your interrupt function if it has the right name)
What __interrupt() does is just tell SDCC that this should be compiled as an interrupt handler. Depending on the CPU, the function prologue (saving registers, ...) and epilogue (exact type of RET instruction used, ...) is different.
What it doesn't do is make sure the function is called when there is an interrupt. That is up to you, either in a linker script, in assembler, or by some C tricks. Basically you should make sure that 0xFFFE contains a pointer to your function.
I think you can do this if you want to do it all from C sources:
Code:
unsigned int interupt_pointer __at(0xFFFE) = (unsigned int)(void*)handler;
Maybe your linker script and/or startup code provides other ways to set it (for example, it will "find" your interrupt function if it has the right name)
PulkoMandy> Thank you so much!!
