delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/27/08:59:50

From: "Bas Hamstra" <bas DOT hamstraNOSPAM AT wxs DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Again: I need help (inline assembly)
Date: Fri, 27 Aug 1999 11:08:13 +0200
Organization: Planet Internet
Lines: 56
Message-ID: <7q5kg8$2hv9i$1@reader2.wxs.nl>
References: <37c1e222 DOT 1224982 AT news DOT telepac DOT pt>
NNTP-Posting-Host: gn0280-2.dial.wxs.nl
Mime-Version: 1.0
X-Trace: reader2.wxs.nl 935744840 2686258 195.121.153.24 (27 Aug 1999 09:07:20 GMT)
X-Complaints-To: abuse AT wxs DOT nl
NNTP-Posting-Date: 27 Aug 1999 09:07:20 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3155.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

You have to be a very good assembly programmer to outperfom the gcc
compiler. If you only occasionaly do some assembler, you are no expert and
compiled c-code is probably faster. I recommend a little experminent: take
your old ultrafastest little assembler routine. And measure the speed. Now
write it in C and measure the speed. You very probably will be surprised.

What assembler is good for, in my opinion, is when there is no C equivalent
for certain CPU instructions. For example Borland has no function for
seeking the last bit (gcc has ffs()). There you can gain speed by using the
asm BSF instruction.

Of course it is possible to outperform gcc with assembler, but you have to
know the CPU very well.

(I remember an the expert assembler programmer Ed Schroder, doing chess
programs, complaining it was not easy to outperfom the c compilers nowadays.
Years ago you could gain a factor 2. Now he had a hard time going 40%
faster. And that's an *expert*).


Regards,
Bas Hamstra.





aperes heeft geschreven in bericht <37c1e222 DOT 1224982 AT news DOT telepac DOT pt>...
>The problem is simple:
>
>I have two arrays, for example:
>
>   int source[10], target[10]
>
>How can i copy source to target using inline assembly and DJGPP?
>
>#include <something.h>
>
>int main(void)
>{
>    int source[10], target[10], i;
>
>   for(i=0; i < 10; i++)
>      source[i] = i;
>
>  asm("
>            ???????
>         );
>
>  return 0;
>}
>
>thanks in advance
>
>APeres

- Raw text -


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