| Deutsch English Français Italiano |
|
<_YOcnXSM0Is_2tj6nZ2dnZfqnPednZ2d@earthlink.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: local-1.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 26 Nov 2024 03:59:30 +0000
Subject: Re: Joy of this, Joy of that
Newsgroups: comp.os.linux.misc
References: <vhigot$1uakf$1@dont-email.me>
<6iKdnTQOKNh6AqD6nZ2dnZfqn_idnZ2d@earthlink.com>
<20241120081039.00006d2a@gmail.com> <vhlium$93kn$1@dont-email.me>
<vhmprp$iaf1$1@dont-email.me>
<LASdnSkA69I3yKL6nZ2dnZfqnPWdnZ2d@earthlink.com>
<vhoeap$r8gq$2@dont-email.me> <vhpmq3$14s79$2@dont-email.me>
<vhq1f7$16bou$1@dont-email.me> <vhqm4g$1aarf$1@dont-email.me>
<vhr2r7$1cdln$1@dont-email.me> <vhr8hh$1ddh7$2@dont-email.me>
<vhr9u1$1dh3s$1@dont-email.me> <vhrbsr$1dqca$2@dont-email.me>
<vhs3ji$1kb5c$1@dont-email.me> <vhtht6$1s5d5$5@dont-email.me>
<vhtplb$1tioh$1@dont-email.me> <vhuutu$26l4e$1@dont-email.me>
<vi05g5$2cuig$2@dont-email.me> <lqi36tFdu06U2@mid.individual.net>
<A0Wdndoii-yGt9n6nZ2dnZfqn_idnZ2d@earthlink.com>
<wwvh67vlm0j.fsf@LkoBDZeT.terraraq.uk>
From: "186282@ud0s4.net" <186283@ud0s4.net>
Organization: wokiesux
Date: Mon, 25 Nov 2024 22:59:29 -0500
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <wwvh67vlm0j.fsf@LkoBDZeT.terraraq.uk>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Message-ID: <_YOcnXSM0Is_2tj6nZ2dnZfqnPednZ2d@earthlink.com>
Lines: 63
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 99.101.150.97
X-Trace: sv3-2s216QlSqYR9XoZKKlD3sOCyy43PCWOwj9jRMIozpJnHfJKmlmhcL/piZRtwGYzhJFkH7SvPwjvjdB3!jcLOG5/mDwe0fXz9MKV6u0NeZLYNrCTIY+BZPSQ9lgSucNQIVGu3YAYMKhifOTVhWdmN/HeR4MGI!xEej3rEMuLmIE+2Lr23G
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
Bytes: 3994
On 11/25/24 4:07 AM, Richard Kettlewell wrote:
> "186282@ud0s4.net" <186283@ud0s4.net> writes:
>> Note though ... almost NO compu-geeks these days
>> know ASM. As such they will not be enlightened
>> about 'C' in that fashion. Today's geeks mostly
>> start with Python and MIGHT go a little further,
>> likely Rust.
>>
>> Just sayin'
>>
>> Things changed between 1984 and 2024.
>>
>> We Old Guys can kinda look at 'C' and see
>> the ASM it's going to become. Later gens
>> do not.
>
> It’s a common mental model for C, but it’s not accurate. The language
> spec leaves an awful lot of wiggle room for the generated code to
> diverge from the “I can see the assembler” model and compilers take full
> advantage of it.
>
> A simple example, based on a historical Linux kernel vulnerability
> (CVE-2009-1897):
>
> int f(int *xp) {
> int x = *xp;
> if(!xp)
> return 0;
> return x;
> }
>
> In the “assembler” model it would compile to something like this:
>
> mov eax,dword ptr [rdi]
> cmp rdi,0
> jne L1
> mov eax,0
> L1:
> ret
>
> In fact at -O2 the test on xp is optimized out:
>
> mov eax, dword ptr [rdi]
> ret
>
> https://godbolt.org/z/caKeTMTxf to play further.
>
Heh ... much of my 'C' looks like the top example, all
straight-forward and readable. As I said somewhere, 'C'
was the neat-o new lang back when I got started in things
so I strongly trend towards the K&R look and feel even now.
SO easy to write incomprehensible 'C' !
I agree that the optimization tech has become VERY good
these days. That final example shows how tight that
particular bit CAN be made. How the compiler figures
that out - NO idea ! Messing with microcontrollers
can be helpful in teaching how to shrink ASM - ya always
wanna save a few bytes, a few cycles.
"Tight memory" means "Only four gigabytes" to the
Gen-Z/A2 crowd :-)