Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The clothes have no emperor. -- C. A. R. Hoare, commenting on ADA.


devel / comp.lang.c / cdcl and floats and doubles

SubjectAuthor
* cdcl and floats and doublesfir
`- Re: cdcl and floats and doublesfir

1
cdcl and floats and doubles

<02222ec4-1bc2-4bb1-ba9f-ac954a311f61n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21729&group=comp.lang.c#21729

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:594a:0:b0:2f9:38c9:98ae with SMTP id 10-20020ac8594a000000b002f938c998aemr8292842qtz.391.1653423426620;
Tue, 24 May 2022 13:17:06 -0700 (PDT)
X-Received: by 2002:ad4:5967:0:b0:462:10a3:cbf6 with SMTP id
eq7-20020ad45967000000b0046210a3cbf6mr17537383qvb.127.1653423426484; Tue, 24
May 2022 13:17:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 24 May 2022 13:17:06 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.126; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.126
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <02222ec4-1bc2-4bb1-ba9f-ac954a311f61n@googlegroups.com>
Subject: cdcl and floats and doubles
From: profesor...@gmail.com (fir)
Injection-Date: Tue, 24 May 2022 20:17:06 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: fir - Tue, 24 May 2022 20:17 UTC

i find cdcl as not so stupid becouse it allows
to pass any number of arguments (as te first,
leftiside argument is closest to call when being push)
it also allows in fact to return variable arguments
when used like

void foo int x int y int z -> int a int b

which goes like

add esp 4
add esp 4
push (z)
push (y)
push (x)
call foo
sub esp 4
sub esp 4
sub esp 4
pop a
pop b

(in fact as stack is reversed it should be sub above and add down below)

i used word stupid as generally i find those stack using as stupid and in my compiler i think i implement my own fully static convention when x y z a b would be 5 static ints belonging to foo and 5 pops/pushes would be replaced by 5 more clear movs (and in case this is only one caller could be reduced to zero movs)

hovever using cdcl for floats and doubles im not sure is not even worse

i compiled
float foo(float x) { return x*2; } and find such code (im not sure if this is for
thia function but probably

sub esp 4
movss xmm0 (esp+8)
adds xmm0 xmm0
movss (esp) xmm0
fld (esp)
add esp 4
ret

which is probably idiotic for such simple task... (it is even compiled woth -O2 i guess)
it also mixes sse code iwth old and rather unused fpu code i mean fld
which probably cdcls says how floats (and doubles?) should be returned
(??)

when when pasing as i remember when one pases float to function it gies just simple push eax (with eax loaded by this float) and when passing double
it goes to 2 pushes with two halfs of double

i need to implement at least cdecl and my ovn conventions so i need
to learn details of this (govever i presently lost the momentum in writing the compiler and probably i will back to it in some future, im not sure yet)

in my ovn convention such float foo(float x) { return x*2; }
would probably be

foo:
movss xmm0 (foo.x) //or movd i dont remember
mulss xmm0 2
movss (foo.y) xmm0
ret

in fact those fastcall conventions are like even better but this static one is for now good enough as it simple

Re: cdcl and floats and doubles

<79de4aca-3b98-4e00-ba78-2bccddfefc18n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21732&group=comp.lang.c#21732

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:e205:0:b0:6a3:39d1:6292 with SMTP id g5-20020a37e205000000b006a339d16292mr16308298qki.525.1653425840025;
Tue, 24 May 2022 13:57:20 -0700 (PDT)
X-Received: by 2002:ac8:5915:0:b0:2f3:db7f:7ad8 with SMTP id
21-20020ac85915000000b002f3db7f7ad8mr21524548qty.77.1653425839879; Tue, 24
May 2022 13:57:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 24 May 2022 13:57:19 -0700 (PDT)
In-Reply-To: <02222ec4-1bc2-4bb1-ba9f-ac954a311f61n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.216; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.216
References: <02222ec4-1bc2-4bb1-ba9f-ac954a311f61n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <79de4aca-3b98-4e00-ba78-2bccddfefc18n@googlegroups.com>
Subject: Re: cdcl and floats and doubles
From: profesor...@gmail.com (fir)
Injection-Date: Tue, 24 May 2022 20:57:20 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3892
 by: fir - Tue, 24 May 2022 20:57 UTC

wtorek, 24 maja 2022 o 22:17:14 UTC+2 fir napisał(a):
> i find cdcl as not so stupid becouse it allows
> to pass any number of arguments (as te first,
> leftiside argument is closest to call when being push)
> it also allows in fact to return variable arguments
> when used like
>
> void foo int x int y int z -> int a int b
>
> which goes like
>
> add esp 4
> add esp 4
> push (z)
> push (y)
> push (x)
> call foo
> sub esp 4
> sub esp 4
> sub esp 4
> pop a
> pop b
>
> (in fact as stack is reversed it should be sub above and add down below)
>
> i used word stupid as generally i find those stack using as stupid and in my compiler i think i implement my own fully static convention when x y z a b would be 5 static ints belonging to foo and 5 pops/pushes would be replaced by 5 more clear movs (and in case this is only one caller could be reduced to zero movs)
>
> hovever using cdcl for floats and doubles im not sure is not even worse
>
> i compiled
> float foo(float x) { return x*2; } and find such code (im not sure if this is for
> thia function but probably
>
> sub esp 4
> movss xmm0 (esp+8)
> adds xmm0 xmm0
> movss (esp) xmm0
> fld (esp)
> add esp 4
> ret
>

i checked how it looks like in case of doubles
double xxx(float x)
{ return x*333;
}

sub esp 0xc
pxor xmm1 xmm1
movss xmm0 (0x406044)] ; .rdata: 0x00 0x80 0xa6 0x43
mulss xmm0 (esp+0x10)
cvtss2sd xmm1 xmm0
movsdd mmword ptr (esp) xmm1
fld qword prt (esp)
add esp 0xc
ret

> which is probably idiotic for such simple task... (it is even compiled woth -O2 i guess)
> it also mixes sse code iwth old and rather unused fpu code i mean fld
> which probably cdcls says how floats (and doubles?) should be returned
> (??)
>
> when when pasing as i remember when one pases float to function it gies just simple push eax (with eax loaded by this float) and when passing double
> it goes to 2 pushes with two halfs of double
>
> i need to implement at least cdecl and my ovn conventions so i need
> to learn details of this (govever i presently lost the momentum in writing the compiler and probably i will back to it in some future, im not sure yet)
>
>
> in my ovn convention such float foo(float x) { return x*2; }
> would probably be
>
> foo:
> movss xmm0 (foo.x) //or movd i dont remember
> mulss xmm0 2
> movss (foo.y) xmm0
> ret
>
> in fact those fastcall conventions are like even better but this static one is for now good enough as it simple

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor