[chbot] GCC and recursion

Charles Manning cdhmanning at gmail.com
Sat Apr 13 07:42:08 BST 2024


I am curious Mark: did you get the recursion working?


On Sat, Mar 30, 2024 at 1:25 PM Mark Atherton <markaren1 at xtra.co.nz> wrote:

> All,
>
> The cross assembler is x86 based, has a deterministic exit condition,
> and debug code showing return values. It only exits once, hence checking
> compiler constraints before looking closer look for stupidity on my part.
>
> Thanks for all the comments.
>
> Mark
>
> On 3/30/2024 12:15 PM, Volker Kuhlmann wrote:
> >> I am building an RPN expression evaluator for the uCPU assembler; I
> can't
> >> see any other way to go other than to use recursion to do the nested
> >> processing that I wish.
> >
> > I agree that that should have nothing to do with gcc, although it is
> > possible that gcc has quite a few bugs affecting correct code generation
> > for some µC cores. Those are gcc version dependent too.
> >
> > What architecture are you generating code for? Is your assembler running
> > on x86? It's safe to assume for that that crashes are caused by your
> > code, not gcc.
> >
> > Recursive programming relies on having a reliable exit condition, taken
> > before resources like stack run out. An easy way to check is to write
> > out the parameters for each call on a single line, one line per call,
> > and any unrestrained criteria show up at the bottom of the screen.
> >
> >> It could be that the compiler is not generating re-entrant code.
> >
> > Not for x86. More likely a variable which changes with each call is not
> > local. A compiler bug, if it's for esoteric cores, would still be down
> > on my list.
> >
> > Why don't you just compile for x86 and test in a high-resource
> > environment first?
> >
> > Volker
> >
>
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20240413/4cf0fe7c/attachment.html>


More information about the Chchrobotics mailing list