Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By MarekB
#6716 So I have a function
Code: Select allvoid drawArc(uint16 cx, uint16 cy, uint16 radius, uint16 thickness, uint16 start)

this one works fine. If I add one more argument
Code: Select allvoid drawArc(uint16 cx, uint16 cy, uint16 radius, uint16 thickness, uint16 start, uint16 end)

the code gets stuck at the end of the function which called drawArc. Changing it to
Code: Select alltypedef struct {
   uint16 cx;
   uint16 cy;
   uint16 radius;
   uint16 thickness;
   uint16 start;
   uint16 end;
} drawArcParams;

void drawArc(drawArcParams params)

works fine. And it's also probably the better way to pass in a lot of arguments.
But just wondering where does the limitation to 5 function arguments come from?
User avatar
By jcmvbkbc
#6749
MarekB wrote:So I have a function
Code: Select allvoid drawArc(uint16 cx, uint16 cy, uint16 radius, uint16 thickness, uint16 start)

this one works fine. If I add one more argument
Code: Select allvoid drawArc(uint16 cx, uint16 cy, uint16 radius, uint16 thickness, uint16 start, uint16 end)

the code gets stuck at the end of the function which called drawArc.

This was an issue with the initial call0 ABI implementation. I believe it's fixed in the current versions of https://github.com/jcmvbkbc/gcc-xtensa and https://github.com/jcmvbkbc/crosstool-NG , specifically with the commit https://github.com/jcmvbkbc/gcc-xtensa/ ... 8f842a8acc
Please let me know if you see it with the latest gcc: there must still be a problem there then.
MarekB wrote:But just wondering where does the limitation to 5 function arguments come from?

Comes from the fact that arguments passed in registers occupy at most six registers a2-a7, but a7 is a frame pointer in case of windowed ABI and the compiler treats it specially. The initial call0 port didn't change that, so strange things may happen with 6th argument.
User avatar
By MarekB
#6825 Thanks jcmvbkbc for the explanation.
I am on windows and I using a pre-built lx106 toolchain I downloaded from here: https://drive.google.com/folderview?id=0BzWyTGWIwcYQendHbWlsNUZpX0E&usp=drive_web#list. I guess it is quite an old build at this time so your latest toolchain probably works fine in this regard.
I am not sure if there is a newer pre-built toolchain somewhere or how hard would it be to compile it on windows. Don't really have time to play around with this at the moment. If anybody has a link to a newer toolchain I can use, please post a link. thanks
User avatar
By peteben
#6865 I have since recompiled the toolchain in 32bit mode, and updated my instructions. You will find everything in the new Wiki here.

Let me know if the 32bit compiler has the same problem. If it does, I will try to compile an updated version if I can find it.

Pete