Calling a C function from Assembly

giltal
Posts: 4
Joined: Wed Sep 30, 2020 5:34 am

Calling a C function from Assembly

Postby giltal » Wed Dec 21, 2022 6:47 pm

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++;
}

ESP_Sprite
Posts: 9725
Joined: Thu Nov 26, 2015 4:08 am

Re: Calling a C function from Assembly

Postby ESP_Sprite » Thu Dec 22, 2022 2:38 am

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.

giltal
Posts: 4
Joined: Wed Sep 30, 2020 5:34 am

Re: Calling a C function from Assembly

Postby giltal » Fri Dec 23, 2022 12:02 pm

Thanks for your answer ... :)
I am aware of it :-)
Tried all options, still same starnge behaviuor

Who is online

Users browsing this forum: No registered users and 72 guests