[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Assembler Language
On Fri, Feb 25, 2000 at 08:23:35PM +0000, Al Hudson wrote:
> You might want to ask yourself why you want to go for assembly. The
> assembly option is generally not a valid one. You may say to yourself that
> you need that level of control and speed, and I wouldn't agree with you.
..
> You lose a lot of advantages by programming in assembly. I would suggest
> that if you want to try prorgamming assembly, try in-line first, with
> specific C code. Speed critical regions, where the operation may be pruned
> by hand to give a performance increase (typically, pixel plotting, BitBlt,
> etc. in graphics demos) may be written in assembly and interfaced to C.
> But still, even simple optimisations gcc will provide (such as
> unroll_all_loops) will be beyond the means of an assembly programmer -
> you'll have to think hard what optimisations can be made, where, and how
> they will impact the program. I have to say, if a routine can be speeded
> up by translating from C to ASM, it's generally because the C code was
> flabby - judicious use of inline, register and other such keywords will
> improve performance no end.
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.