Re: double bytes

From: Johan Klockars <>
Date: Mon, 27 Apr 1998 12:18:55 +0200 (MET DST)

> > >how to quickly expand a data word into long so that every byte is
> > >doubled? I need it for wider picture on higher NOVA resolution.
> > MOVE D0,D1
> > LSL 8,D0
> > BFINS D1,D0{0:8}
> > LSR 8,D1
> > BFINS D1,D0{24:8}

On an '040 and assuming that the memory is slow, like when writing via the
ST-RAM bus, that may be as fast as it goes. The bitfield instructions are
quite slow, however, so if you're writing to fast memory (or if you're on
an '030) one of the following should be quite a bit faster:

        move.w d0,d1
        swap d0
        move.w d1,d0
        ror.w #8,d0
        ror.l #8,d0

        move.l #$ff0000ff,d2 ; assume another free register
        move.w d0,d1
        swap d0
        move.w d1,d0
        and.l d2,d0
        ext.l d1
        lsl.l #8,d1
        or.l 1,d0

It's a bit hard to count cycles on the '030 and '040, but I believe the
last one above should be fastest. Rotates are slower than shifts and both
are slower than normal arithmetic instructions.

> Looks fine to be, but if he's only doing it once per pixel, then four
> move's would probably be faster.

Possibly on an old 68000 or if you have copyback cached memory. In general
you want to keep the number of memory accesses down, though.

> move.w d0,(a0)
> move.w d0,2(a0)
> move.b (a0),1(a0)

At least make that a 'move.b d0,1(a0)' if you want to try this.

> move.b 3(a0),2(a0)

If you are writing to NOVA video RAM, this code should be a lot slower
than either of the examples above.

  Chalmers University   | Why are these |  e-mail:
     of Technology      |  .signatures  |  
                        | so hard to do |  WWW/ftp:
   Gothenburg, Sweden   |     well?     |            (MGIFv5, QLem, BAD MOOD)
Received on ma. april 27 1998 - 18:32:00 CEST

This archive was generated by hypermail 2.3.0 : ti. nov. 03 2015 - 20:07:54 CET