I'd like to get the fastest BSWAP for every x86 proc.
For all 486+, except P4, I assume

BSWAP EAX (1-2 cycles)

is the fastest. However what would I use for 386 or P4? AMD K6, K7?
I've come up with some code.... which can probably be optimized alot, because I'm not really good at that. So any help is welcome.

MOV EBX, EAX
SHL EAX, 24
MOV ECX, EBX
SHR EBX, 24
MOV EDX, ECX
AND EAX, EBX
SHL ECX, 8
SHR EDX, 8
AND ECX, 00FF0000h
AND EDX, 0000FF00h
AND ECX, EDX
AND EAX, ECX

Is this any good for 386 or P4?
Posted on 2004-07-17 13:40:04 by pmpch
BSWAP will still be fastest on a P4, K6, or K7 I would suspect.

On pre-486 processors


rol ax, 8
rol eax, 16
rol ax, 8


Mirno
Posted on 2004-07-17 14:07:29 by Mirno