[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Assembler Language




I think probably I sounded a little harsh, 'cos I'm about to agree with
pretty much everything you said!! It was the idea of writing a full
program in asm that I was talking about really, inline assembler is
deinitely something I approve of. 

Not sure I agree completely with the idea of learning what goes on behind
the scenes to improve your C-code though - although, it is horses for
courses. But, if you want to write good cross-platform code (I regularly
go from Linux x86 to SGI IRIX, for example) knowing the asm behind the
program can lead to silly optimisations, such as using 32-bit values
rather than 16 because it's quicker on some machines, etc. Certainly, if
you want to learn how computers work, assembler is a definite yes, but I
truly believe there are some optimisations which should not be applied by
hand, and most of them are hardware based: if you have two algorithms a
and b, of O(n) and O(log n) respectively, it is a correct choice to use
algorithm a. If you choose algorithm a over b because a uses some
instructions / facility that is faster on the hardware you're using (few
clock cycles per fpu instruction, for example) that to me is silly, unless
you're intending to throw the program away after using it, or there is
some cast - iron reason to squeeze every clock cycle out of the cpu ;))

Cheers,

Alex.

On Sun, 27 Feb 2000, Dr A V Le Blanc wrote:

> I think this is a little naive.  I agree that it is usually a bad
> idea to write a program entirely in assembler, though there are
> cases in which I have had to do so.  (For example, to do something
> simple when the standard utility won't fit on a crowded floppy.)
> I have also had programs investigating a mathematical model in which
> I could (a few years ago) squeeze another 30% improvement out of the
> best gcc could do with full optimisation by putting a critical loop
> in very carefully coded inline assembler.  (Gcc's optimisations are
> far better on the x86 platforms than on some other architectures,
> such as MIPS and PA-RISC; at least, that was the case a few years
> ago.  Recent work has been improving things overall, though.)
> 
> While I would, in general, agree with Al Hudson in practical cases,
> there is one very good reason to do some assembler programming: to
> learn what is actually going on 'behind the scenes'; this can help
> you write better code in C (or in any programming language).
> 
>      -- Owen
>      LeBlanc [at] mcc.ac.uk
> ---------------------------------------------------------------------
> Sheffield Linux User's Group - http://www.sheflug.co.uk
> To unsubscribe from this list send mail to
> - <sheflug-request [at] vuw.ac.nz> - with the word 
>  "unsubscribe" in the body of the message. 
> 
>   GNU the choice of a complete generation.
> 
> 
> 

---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word 
 "unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.