Is there an instruction to swap higher and lower words of a dword?
rol/ror register,16 :)
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
How about this?
rol eax, 16
rol eax, 16
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)
//Begin
LWORD dd ?
HWORD dd ?
code:
movzx LWORD,ax
rol eax,16
movzx HWORD ,ax
//end
i think it's also work; 8)
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
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
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 ...
Thank you f0dder for your correcting,i now got it.
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 :(