TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: THE NATURAL PHILOSOPHER
from: RICHARD KETTLEWELL
date: 2018-04-23 10:59:00
subject: Re: Apologies where they

The Natural Philosopher  writes:

> On 23/04/18 09:55, jack4747@gmail.com wrote:
>> Il giorno lunedì 23 aprile 2018 10:16:01 UTC+2, Gordon Henderson ha
scritto:
>>
>>> I have looked at compiling my BASIC to native code - and there is more
>>> or less a 1:1 relationship with a line of BASIC and a Line/Block of ASM
>>> - it's no-where near efficient as C though (and 'compiling' BASIC into
>>> C is just as easy and may actually result in faster code, but that's a
>>> job for another day)
>>
>> It's not that C is inherently efficient, it's the compiler that
>> optimize the asm.
>> If you compile a C source code with optimization disabled, you'll
>> get a (almost) 1:1 relationship line of C : line of asm.
>
> I think that is only half of it: The other half is that C IS
> assembler, written in shorthand. I cannot offhand think of any native
> c operation that is not an atomic assembler operation.
>
> Ok sometimes on some processors operation on the contents of memory
> are two opcodes.

! compiles to two instructions on ARM and three on x86, in
isolation. Signed division is a subroutine call on ARM and two
instructions on x86. Initialization and assignment of large objects may
involve many instructions or a subroutine call.

The prevalence of undefined behavior in C also punches a rather large
hole in any assumption of a direct mapping into assembler.

--
https://www.greenend.org.uk/rjk/

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.