Page 1 of 1

Calling a C function from Assembly

Posted: Wed Dec 21, 2022 6:47 pm
by giltal
ESP32:
I have an interrupt service routine written in Assembly
I am trying to call a C function and get a double exception error.
Any Idea?

movi a14, intFunc
callx0 a14

extern "C" void IRAM_ATTR intFunc()
{
counter2++;
}

Re: Calling a C function from Assembly

Posted: Thu Dec 22, 2022 2:38 am
by ESP_Sprite
The ESP32 uses the windowed ABI; rather than callx0 you should use one of callx4, callx8 or callx12. Note that if you want to pass arguments to the C function, this also shifts the registers these argument are passed in.

Re: Calling a C function from Assembly

Posted: Fri Dec 23, 2022 12:02 pm
by giltal
Thanks for your answer ... :)
I am aware of it :-)
Tried all options, still same starnge behaviuor