and eax,0FFFFh
Posted on 2001-04-12 00:34:00 by The Svin
would this work?:

xor ah,ah

mov ah,NULL
thats my go at it.... -brad
Posted on 2001-04-12 01:16:00 by Rage9
xor ah,ah
This clears byte 1 of 4 bytes, not the top two bytes (or hiword) of eax. (Byte 1 because we should all start counting at 0.... :P ) The Svin is right,
and eax, 0FFFFh
is the way to go on this one. Any simple elimination of particular bits is best done with "and", which is why its sometimes refered to as "masking". Mirno
Posted on 2001-04-12 05:56:00 by Mirno
I usually use CWDE. This only works for EAX, but that was the question. Maybe Svin knows if this more or less efficient than AND ? Example: mov eax,wParam cwde ;convert word to doubleword extended
Posted on 2001-04-12 10:52:00 by anon
CWDE takes 3 clocks, and is not pairable (according to Agner's PPlain & MMX integer instructions list). AND takes 1 clock, and is pairable on both U & V. Plus it works on more reigsters. It also doesn't erase the hiword of eax, it extends the sign of ax through to the hiword of eax. So sometimes it may erase it, sometimes it will set it to all ones... Mirno
Posted on 2001-04-12 12:00:00 by Mirno
Thanks Mirno, I learn something new everyday !
Posted on 2001-04-12 16:21:00 by anon
What you want to do depends on what you need to do... if you are attempting to unpack the words from a dword (like a point stuck into lParam), and at the same time make dwords out of them, that's simple: movsz eax, WORD PTR lParam ; get the X part movsz ecx, WORD PTR lParam+2 ; get the Y part Personally, I use a 'packed DWORD' structure so my tired little brain doesn't have to remember the Y part is higher in memory. It ammounts to the same code.
Posted on 2001-04-12 18:00:00 by Ernie
and eax,0ffffh is the fastest way to make subj. it has the same size as movsz but 3 times faster. Movsz has reason to be used if size is matter and word is in other source. As it is in Ernie example. So if you want low word from eax to another dist - you may use movsz (if you want still keep the original value of eax) In other case usage movsz is wrong choice. The Svin.
Posted on 2001-04-13 04:28:00 by The Svin
Thanks, everyone. Where do I get a table with clock cycles ? Actually I found the table. Stupid me. Now I wonder - since I just looked it up :-) - why Iczelion pushes hInstance onto stack and pops it off again to fill window class member, though these take one cycles each while mov takes only one ? This message was edited by goofee, on 4/13/2001 8:53:38 AM
Posted on 2001-04-13 07:44:00 by goofee
You can't MOV from memory to memory, just from register to memory or memory to register. Sucks, but I guess Intel just couldn't figure out how to do it.
Posted on 2001-04-13 08:48:00 by Qweerdy
goofee, Its the same old story, convenience over the possible speed gain. mov eax, pMem1 mov pMem2, eax Is supposed to be faster but with 2 sequential actions on EAX, the 2 instructions will not pair anyway. push pMem1 pop pMem2 This does not have the problem of dependency and it does not use a register either so its fine to use it instead of a register. Regards,
Posted on 2001-04-13 08:50:00 by hutch--