would this work?:
thats my go at it.... -brad
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,
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
and eax, 0FFFFh
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
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
Thanks Mirno, I learn something new everyday !
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.
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.
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
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.
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, email@example.com