Thread View: comp.lang.c
7 messages
7 total messages
Started by fir
Fri, 23 Oct 2026 06:08
one calling convention (so callled "the one")
Author: fir
Date: Fri, 23 Oct 2026 06:08
Date: Fri, 23 Oct 2026 06:08
53 lines
2356 bytes
2356 bytes
from longer time i think if in c should be not one calling convention
(or mainly the one)
the one is
( output* out) foo(input* in)
{
}
i mean all argument should be passed by one pointer,
not passed by stack it should be passed by register,
same as to output - all values should be returned by
outupu pointer also by register
im not totally sure it it could be named the one calling
convantion but maybe
(here the one means maybe sometimes main callin convention,
but sometimes maybe the one calling convention
the question is sometimes for efficiency reasons you would like maybe to
pass N input pointers (by registers) or N output pointers via registers
like if you pass two strings
foo("asdasD", "qweqwe");
its more handy to have it in say eax ebx than having in eax the
pointer to
arg {char*, char*}
but in many cased when you use
foo("asS", x, y)
pointer to {"asS", x, y} is okay
so maybe name by one convention th eone which mean
(one but sometimes many output*) foo (one but sometimes many input*)
?
Re: one calling convention (so callled "the one")
Author: David Brown
Date: Fri, 23 Oct 2026 09:16
Date: Fri, 23 Oct 2026 09:16
31 lines
2360 bytes
2360 bytes
On 23/10/2026 08:08, fir wrote:
> from longer time i think if in c should be not one calling convention
> (or mainly the one)
>
> the one is
>
> ( output* out) foo(input* in)
> {
>
> }
>
> i mean all argument should be passed by one pointer,
> not passed by stack it should be passed by register,
> same as to output - all values should be returned by
> outupu pointer also by register
>
For most calling conventions, "in" would be passed in a register and
"out" returned in a register. The details are from the platform ABI,
and are not relevant to the C language.
And if you want your inputs and outputs to be structs, you can already
do that in C. If these structs are under a certain size (determined by
the ABI), they are typically passed and returned directly in registers -
if they are bigger, they are passed using pointers to structs. (The
caller makes the struct for the parameter, and space for the return struct.)
You might like to try using godbolt.org and looking at the generated
assembly to see what code is actually generated.
Re: one calling convention (so callled "the one")
Author: fir
Date: Fri, 23 Oct 2026 12:52
Date: Fri, 23 Oct 2026 12:52
47 lines
2928 bytes
2928 bytes
David Brown pisze:
> On 23/10/2026 08:08, fir wrote:
>> from longer time i think if in c should be not one calling convention
>> (or mainly the one)
>>
>> the one is
>>
>> ( output* out) foo(input* in)
>> {
>>
>> }
>>
>> i mean all argument should be passed by one pointer,
>> not passed by stack it should be passed by register,
>> same as to output - all values should be returned by
>> outupu pointer also by register
>>
>
> For most calling conventions, "in" would be passed in a register and
> "out" returned in a register. The details are from the platform ABI,
> and are not relevant to the C language.
>
> And if you want your inputs and outputs to be structs, you can already
> do that in C. If these structs are under a certain size (determined by
> the ABI), they are typically passed and returned directly in registers -
> if they are bigger, they are passed using pointers to structs. (The
> caller makes the struct for the parameter, and space for the return
> struct.)
>
> You might like to try using godbolt.org and looking at the generated
> assembly to see what code is actually generated.
>
i was mostly aware the cdecl and this second one (pascal?) used on win32
- but it is weirdly vague in my brain now
conventions are various but what i say here is which ones ar eproper and
which are less
(less proper)
two bointers in registers seem to be the base one, but sometimes
indeed it may be few pointers in registers or maybe even by value in
registers, but the basic one is imo 2 pointers (in/out)
Re: one calling convention (so callled "the one")
Author: Chris M. Thomasson
Date: Fri, 23 Oct 2026 21:14
Date: Fri, 23 Oct 2026 21:14
5 lines
1439 bytes
1439 bytes
On 10/22/2026 11:08 PM, fir wrote: > from longer time i think if in c should be not one calling convention > (or mainly the one)[...] You don't like __cdecl? ;^)
Re: one calling convention (so callled "the one")
Author: chine.bleu
Date: Sat, 24 Oct 2026 10:42
Date: Sat, 24 Oct 2026 10:42
19 lines
1821 bytes
1821 bytes
fir wrote:
> from longer time i think if in c should be not one calling convention
> (or mainly the one)
>
> the one is
>
> ( output* out) foo(input* in)
> {
>
> }
This disablea function style calls as in Lisp and convert your language
into verbose assembly code (like Ada).
--
Siri Seal of Disavowal #777-000. Disavowed. Denied. @
NO KINGS For I desire mercy not sacrifice. /|\
The Church of the Holey Apple .signature 5.5 / \
of Discordian Mysteries. This post insults Islam. Mohamed
Re: one calling convention (so callled "the one")
Author: fir
Date: Sat, 24 Oct 2026 13:02
Date: Sat, 24 Oct 2026 13:02
20 lines
1852 bytes
1852 bytes
chine.bleu pisze:
> fir wrote:
>> from longer time i think if in c should be not one calling convention
>> (or mainly the one)
>>
>> the one is
>>
>> ( output* out) foo(input* in)
>> {
>>
>> }
>
> This disablea function style calls as in Lisp and convert your language
> into verbose assembly code (like Ada).
>
c is like verbose asembly imo (depending what verbose means as i not
sure as to this world)
c is not like lisp imo for sure..some could rethink if it can but this
is other story
Re: one calling convention (so callled "the one")
Author: fir
Date: Sat, 24 Oct 2026 13:05
Date: Sat, 24 Oct 2026 13:05
20 lines
1744 bytes
1744 bytes
Chris M. Thomasson pisze:
> On 10/22/2026 11:08 PM, fir wrote:
>> from longer time i think if in c should be not one calling convention
>> (or mainly the one)[...]
>
> You don't like __cdecl? ;^)
more wide i dislike passing arguments via stack (at least by main stack
and "by default")
imo it could be eventually as clearly stated
foo(stack7 int n) //uses stack7 to pass n
{
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads