On Fri, 21 Oct 2022 20:31:52 +0300 Ori Idan <o...@heliconbooks.com> wrote:
> I am not familiar with how SDCC does it but in C calling convention the > function does not have to know the number of parameters, therefore can not > adjust the stack. Only the caller can do it. Not since 1989. ANSI C distinguishes between prototyped, variable argument list (ie "...") and prototype-free declarations. For stuff with potentially variable numbers of arguments you are mostly correct but not entirely. A calling sequence where the previous frame pointer is exposed to the called function means on some architectures it is possible if rather unusual to do cleanup callee side for varargs. For a prototyped function you can do the cleanup in either place as the frame size is explicitly declared. Quite a few compilers do it this way on small machines for the size (cc65, cc6303 in 6800 mode, sdcc in some configurations, bcc for 8086 with some settings etc). Register heavy architectures pass most or all arguments to functions in registers which results in even less cleanup if any even for variable arguments. Alan _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user