Is there an instruction to swap higher and lower words of a dword?
Posted on 2004-08-16 02:26:52 by optimus
rol/ror register,16 :)
Posted on 2004-08-16 03:12:05 by Mbee
Could do the swap during load, but it is slower and the memory has to be accessible two bytes before the data being loaded.
    WORD ?


TheData DWORD ?

mov eax, TheData - 2
mov ax, TheData + 2
Posted on 2004-08-16 09:35:13 by bitRAKE
How about this?

rol eax, 16
Posted on 2004-08-26 06:00:20 by DeX
How about this?
//Begin
LWORD dd ?
HWORD dd ?
code:
movzx LWORD,ax
rol eax,16
movzx HWORD ,ax
//end
i think it's also work; 8)
Posted on 2004-08-30 00:29:55 by Rey
Rey, MOVSX and MOVZX only supports registers as destination. From the intel instruction set reference:

0F B6 / r MOVZX r16,r/m8 Move byte to word with zero-extension
0F B6 / r MOVZX r32,r/m8 Move byte to doubleword, zero-extension
0F B7 / r MOVZX r32,r/m16 Move word to doubleword, zero-extension
Posted on 2004-08-30 01:09:07 by f0dder
rol eax, 16

This way is good! use it, that's right!

machine code size = 3 bytes;
2 machine cycles in .486;
1 machine cycle in .586 ...
Posted on 2004-08-30 05:07:43 by Kestrel
Thank you f0dder for your correcting,i now got it.
Posted on 2004-09-01 04:19:42 by Rey
hmm, can i see into the future, or was the exact question posted on the RCE board too, wtih exact the same answers? (where i answered rol eax,16 too). confusing, new boards and such :(
Posted on 2004-09-01 08:00:07 by lifewire