POV-Ray : Newsgroups : povray.off-topic : Teach yourself C++ in 21 days : Re: Days 5- Server Time
29 Jul 2024 10:18:31 EDT (-0400)
  Re: Days 5-  
From: Le Forgeron
Date: 17 Apr 2012 07:58:09
Message: <4f8d5ad1@news.povray.org>
Le 17/04/2012 12:47, Invisible a écrit :
> 
> Still, it does answer something I've always wondered about: What *is*
> the C calling convention? Apparently it's to pass all function arguments
> and function results via the stack, and also to store all local
> variables on the stack. (By contrast, if you're coding in assembly,
> usually you pass everything in registers. Apparently C doesn't do this.)

C cannot assume a single processor, hence cannot have a set of registers
for arguments.
(on a M68000, what would you do if your functions has more than 16
arguments (D0-D7 and A0-A7) ? And on that small i286, more than 4 16 bits ?)

Not only does everything goes on the stack, but the alignment on the
stack is also sensible to the compiler (and the ABI mode).

(and in C, there is sometimes a difference in the stacking of arguments
when K&R or ANSI prototype has been provided (or not, in which case K&R
is assumed); C++ does not have that issue, as prototype is mandatory)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.