Re: A89: Addx


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

Re: A89: Addx




>Of course it adds what's there *before* (as described in the 68k
>User's Manual, by the way ...).

That's the free one from Motorola, right? I've been trying to figure out how
to order it. . .

So let's say that I have a "decimal" number being represented in a word, so
that the upper byte is the integer portion and the lower byte is the decimal
portion - therefore:

<00000010|10000000> represents 2.5 (the upper byte is 1*2^1, the lower byte
_represents_ 2^-1, or .5)

If I have this word in d1 want to round it off the get rid of the decimal
portion, will this work?

round:
    clr.w d3
    lsr.w #8,d1    ;integer part remains, x flag is set if the
                   ;MSB in the decimal portion is set
    addx.w d3,d1   ;A68k won't allow addx.w #0,d1 - they must both be dx's

At this point, we should be left with d1 containing THREE (2.5 rounds up),
right? That was the whole point of the original question - I'm working on
some trig functions for a 360 degree tilemap engine and need to be able to
round =)

    -Scott



Follow-Ups: