The Help appears to be wrong. C allows VarArgs a variable number of parameters so they must be on the stack Right to Left since the Right side can have a variable about. I see this is Bruce’s Driver code but cannot recall where.
Asking AI about if C and Pascal are the same responded:
No, the C calling convention (specifically cdecl) is not the same as the Pascal calling convention, although they are related. While both involve pushing arguments onto the stack, the key difference lies in who is responsible for cleaning up the stack after the function call and the order in which arguments are pushed. In cdecl (the C calling convention), the caller is responsible for cleaning the stack, while in Pascal, the callee cleans the stack. Additionally, cdecl pushes arguments onto the stack from right to left, whereas Pascal pushes them from left to right.
Here’s a more detailed breakdown:
-
- The caller pushes arguments onto the stack from right to left.
- The caller is responsible for cleaning up the stack after the function returns (removing the arguments).
- This convention allows for functions with a variable number of arguments (varargs).
-
- The caller pushes arguments onto the stack from left to right.
- The callee (the function being called) is responsible for cleaning up the stack before returning.
- This convention does not support varargs.
-
Related Conventions:
In essence, while both cdecl and Pascal are calling conventions that involve pushing arguments onto the stack, the crucial distinction is who manages the stack after the call, and the order in which arguments are pushed.