On Wed, 2003-02-05 at 08:05, Sean Charles wrote:
> Ok, here goes... it *was late*, about midnight and in the run up to the 
> main blitter code I was actually doing things like this,
> 
> asm("move.w %0, %%d1" : : "g" (p->width*p->height)... );
> 
> and because the compiler had to generate some code to do the 
> multiplication, it *used some registers* that I had already loaded in 
> previous asm() statements, causing the problem. Mostly, I try to do 
> things like pre-calculations, clipping, all the boring stuff, in C as it 
> is quicker to think it out and more readable. I hope this explains what 
> I meant. If you still maintain that this should work I am going to have 
> to take a sanity check! *8-) It *was* late....it gets very cold in the 
> attic late at night so maybe the brain got frostbite. I must buy some 
> more of that fizzy canned anti-freeze.

One other gotcha: that '%0' above is a compiler-chosen register.  I was
bitten a few times by trying something like this:

asm("   
        move.w %0, %%d0
        move.w %1, %%d1
        move.w %2, %%d2
        move.w %3, %%d3
        move.w %4, %%d4
        move.w %5, %%d5
        move.w %6, %%d6
" : : 
        "g" (var1),
        "g" (var2),
        "g" (var3),
        "g" (var4),
        "g" (var5),
        "g" (var6),
        "g" (var7),
         );

and finding out by looking at the disassembly that the compiler chose d0
as the register to handle loading the value, and then putting it into
the target register.

Heh, that was a good couple glasses of wine to figure that one out...:^)

> Seriously though, asm() is very useful. I don't care what anybody else 
> says, I started out in assembler and twenty years on there is *still* a 
> case for it...sometimes you just cannot beat hitting the metal for that

Amen brother!  All worship at the altar of bit manipulation!

(First computer was a zx80 with a z80 chip...I'd hand-assemble code, and
poke the values into a string, and then jump to the location of the
screen. When macro assemblers came along, I thought I'd died and gone to
heaven!)

-Ken


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

Reply via email to