From: Maarten B. <sou...@ds...> - 2008-02-01 10:57:39
|
Hello Raphael, I posted this question to the developer list last week and was hoping for an answer from you. Alas there was none and so I ask again. First of all, let me state that I know next to nothing about PIC's nor about SDCCs pic ports. That's why I'm asking int he first place. What I would like to know is how does the PIC16 pass parameters to a function when called through a function pointer? For most ports all parameters which cannot be passed in registers SDCC creates (statically allocated) symbols with the function name in it (e.g. _foo_PARM1) and fills them before making the call. For a function pointer this does not work of course because the pointer does not have the same name as the pointed-to function. Only when the function is declared reentrant these parameters will be passed on the stack and thus there is no problem where to write and read them. Can you please shed some light on this so I can commit my code without breaking the PIC16 port? Thanks, Maarten > To Raphael (and the rest), > > After the mail from Kustaa Nyholm I looked why there was no warning or > error about calling function pointers with statically allocated > parameters. I found there was one in SDCCast.c: processParms() but it > wasn't triggered (don't know why exactly). But it was also explicitly > disabled by Raphael (tecodev) almost 3 years ago (#3669) for PIC16. > > Now I intend to add another test for parameters not passed in registers > to non-reentrant function pointer calls (see below). But I'm unsure if I > need to disable it for PIC16 too or not. Please advise. > > Btw. I also intend to upgrade the severity of W_NONRENT_ARGS from > warning to error. > > Greets, > Maarten > > end of ProcessParms: > > /* make a copy and change the regparm type to the defined parm */ > (*actParm)->etype = getSpec ((*actParm)->ftype = copyLinkChain > ((*actParm)->ftype)); > SPEC_REGPARM ((*actParm)->etype) = SPEC_REGPARM (defParm->etype); > SPEC_ARGREG ((*actParm)->etype) = SPEC_ARGREG (defParm->etype); > + > + /* if the function is being called via a pointer & */ > + /* this parameter is not passed in registers */ > + /* then the function must be defined reentrant */ > + if (IS_FUNCPTR (func->ftype) && !SPEC_REGPARM ((*actParm)->etype) > + && !IFFUNC_ISREENT (functype) && !options.stackAuto) > + { > + werror (E_NONRENT_ARGS); > + fatalError++; > + return 1; > + } > + > (*parmNumber)++; > return 0; > } > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > sdcc-devel mailing list > sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-devel > |