Re: count2.asm





¬a\/b wrote:
>
> Is it possible that one can do some C code that assembly people can
> not do faster? (>0.1%) (i think yes, because i have seen that code)

Can not do faster? Absolutely. But they always be able to do it *as
fast* by simply copying what the compiler does.

Note that once code is optimal (meaning as good as it can get), you
aren't going to get any better. Sometimes, by design or by accident,
compilers do generate optimal code for a given sequence of
instructions. Indeed, in my experience (studying compiler output),
compilers have a habit of producing some *brilliant* code, that
generally beats what an assembly language programmer would write when
hand coding the same stuff. The only problem is that in other sequences
in the program, compilers tend to output brain-dead code that even a
beginning assembly programmer can beat. The combination of the two
still comes out pretty good, but an expert assembly programmer can copy
what the compiler does well and rewrite the stuff the compiler does
poorly, and wind up with slightly better code.

Of course, the *real* way to get better performance (or size) is to
think like the machine rather than thinking in abstract, high-level,
terms. An assembly programmer who acts as a "human compiler" for a C
code sequence isn't going to do much better than a C compiler, if they
do better at all. The real improvement comes when you think the problem
through at the machine level rather than in C and write your code
accordingly.

Also, on a smaller application, such as the character frequency app
being discussed here, there is less room for massive improvement
because the program is so small.
Cheers,
Randy Hyde

.



Relevant Pages

  • Re: AVR Beginner Questions - Ports and Speed
    ... On bigger processors, a good compiler will ... while the assembly programmer might use a full-blown divide ... > 3) One of the most productive strategies is to code in C, but optimise ... Chosing the optimal form for loops, ...
    (comp.arch.embedded)
  • Re: whats wrong with a pic ?
    ... They are just fine for an assembly programmer who is used to ... The Hi-tech C Compiler works fine with it. ... The code size is reason ... peripherals make it the right chip for many jobs. ...
    (comp.arch.embedded)
  • Re: code optimization in embedded systems
    ... target has instructions, that cannot be expressed in C, for example ... difficult targets often mean it's harder for the assembly programmer ... as well as the compiler (you already mentioned deep interlocked ... pipelines and large register files, but what about rotating register files, ...
    (comp.arch.embedded)
  • Re: Assembly vs Compiled (Was: reducing flash size in embedded processors?)
    ... > That depends highly on the assembly programmer. ... However code for modern 32-bitmicros is very difficult ... programmer could beat the world's best compiler. ... hence can perform some cross-module optimization. ...
    (comp.arch.embedded)
  • Re: Derived data types vs computation time
    ... >> or not, of SEQUENCE in the definition, the compiler may or may be forced ... the standard has no reason at all for the compiler ... Even for most sequence types, the standard does not really mandate ...
    (comp.lang.fortran)