delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/02/09/21:26:15

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: inline assembly and c struct
Date: 9 Feb 2001 12:29:27 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 32
Message-ID: <960nr7$epu$1@nets3.rz.RWTH-Aachen.DE>
References: <957ghs$kl$1 AT news DOT onet DOT pl> <959619$f3k$1 AT murdoch DOT acc DOT Virginia DOT EDU> <95f5mk$cug$1 AT news DOT onet DOT pl> <95h3j1$frf$1 AT murdoch DOT acc DOT Virginia DOT EDU> <95uqes$643$1 AT news DOT onet DOT pl>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
Mime-Version: 1.0
X-Trace: nets3.rz.RWTH-Aachen.DE 981721767 15166 137.226.32.75 (9 Feb 2001 12:29:27 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 9 Feb 2001 12:29:27 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

clusty <clusty AT poland DOT com> wrote:

> Użytkownik "Clark L. Coleman" <clc5q AT cobra DOT cs DOT Virginia DOT EDU> napisał w wiadomo¶ci
> news:95h3j1$frf$1 AT murdoch DOT acc DOT Virginia DOT EDU...

>> Could you answer my question: Why does it have to be inline assembly
>> when it could be done in C code?

> Because it has to be. In case you didn't know its faster that way. :)

Nonsense --- at least in the absolutistic way you put it. Yes, inline
assembly can be faster than compiled C, for certain operations. But
nothing I see in this thread gives a good reason why *this* particular
operation might profit from being written in inline assembly. GCC is a
C compiler, so computing and applying structure offsets to addresses
is something it's almost necessarily rather good at, already.

Always keep in mind: to make inline assembly noticeably faster than
compiled code, your understanding of the CPU usually has to be better
than that of the GCC authors.  Do you *really* think you're that good?
Have you ever looked at the assembly generated by gcc -O2 or higher to
validate that opinion?  And, if you really are consistently better
than GCC: why don't you spend your work time on improving GCC,
instead, to get the maximal effect out of it?

And that's not yet taking into account that badly written inline
assembly (e.g.: most occurences of __asm__ __volatile__) can easily
make GCC's remaining task so much harder that, over all, the whole
things is *slower* than without the asm.
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019