Compilers do a pretty good job, but in 30 years I have yet to find one that
could beat a decent assembly code programmer in a focused test. The point is
that they do a really good job and do it for thousands of opcodes, letting
you think about the app's logic on a higher level.

As a Palm programmer with an understanding of 68K assembly, you have an
edge: you can write in-line assembly when you need to gain an edge in faster
or tighter code. I'd argue that aren't many instances where it is needed in
Palm apps, but when you need it, it is a great skill to call upon.

JB

PS: I'm a little confused. Your optimization contains exactly the same
opcodes as the original (different order), takes the same number of bytes,
and runs in the same number of cycles. How is your code more optimized than
the original? More importantly, is this fragment of code called within a
tight loop hundreds of times, or just periodically?

PPS: You can make this code even faster in your release build by turning off
the A6 Stack Frames option in CodeWarrior. The frames are only needed for
debugging, and change your code to the following:

    move.w    4(a7),d0
    lsl.w     #5,d0
    move.w    4(a7),d1
    lsl.w     #6,d1
    add.w     d0,d1
    move.w    d1,d0
    rts

The LINK and UNLK opcodes are added to every function in your app if the
option is turned on: turning it off for release builds makes your code
smaller and faster.

on 11/4/00 3:07 PM, Garth Watkins at [EMAIL PROTECTED] wrote:

> link      a6,#0
> move.w    8(a6),d0
> lsl.w     #5,d0
> move.w    8(a6),d1
> lsl.w     #6,d1
> add.w     d0,d1
> move.w    d1,d0
> unlk      a6
> rts
> 
> wouldn't it be more efficient to copy the first parameter from the stack
> into d0, and then copy d0->d1, instead of re-copying
> the parameter off the stack into d1
> 
> 
> link      a6,#0
> move.w    8(a6),d0
> move.w    d0,d1        // changed code
> lsl.w     #5,d0
> lsl.w     #6,d1
> add.w     d0,d1
> move.w    d1,d0
> unlk      a6
> rts

----------------------------------------------
JB Parrett                 [EMAIL PROTECTED]
Palm, Inc.         

We grow a lot faster than trees,
so we miss a lot of stuff. - B. Andreas


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to