While playing with a new macro (more (http://www.masm32.com/board/index.php?topic=12460.msg146634#msg146634)), I found out that Windows trashes practically all XMM regs in certain message handlers. FPU regs, on the other hand, seem not to be affected.
QuoteWndProc proc uses esi ebx hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL rc:RECT
movd eax, xmm0 ; variable whose changes are monitored is xmm0
inc msgCount
deb 4, "xmm0 change for ...", chg:eax
SWITCH uMsg
Sample output:
xmm0 change for ...
chg:eax -2142149313
msgCount 11
# uMsg # WM_PARENTNOTIFY
xmm0 change for ...
chg:eax 0
msgCount 12
# uMsg # WM_WINDOWPOSCHANGING
xmm0 change for ...
chg:eax 40
msgCount 20
# uMsg # WM_IME_SETCONTEXT
xmm0 change for ...
chg:eax -143169644
msgCount 31
# uMsg # WM_WINDOWPOSCHANGING
xmm0 change for ...
chg:eax -1080457848
msgCount 36
# uMsg # WM_SIZE
xmm0 change for ...
chg:eax 305419896
msgCount 43
# uMsg # WM_MOVE
xmm0 change for ...
chg:eax -2141256048
msgCount 46
# uMsg # WM_GETICON
xmm0 change for ...
chg:eax -1082123948
msgCount 48
# uMsg # WM_CTLCOLOREDIT
xmm0 change for ...
chg:eax 0
msgCount 51
# uMsg # WM_CTLCOLORSTATIC
Example attached.
http://www.masm32.com/board/index.php?topic=16552.msg137273#msg137273
If you are under 64-bit windows then SSE2 is implied.
Thanks, drizz. Strangely enough, Dave writes in that thread that a guy named Jochen has mentioned this problem in an older thread. It's called memory problems ::)
Here (http://www.rz.uni-karlsruhe.de/rz/docs/VTune/reference/vc129.htm) is a good description of FXSAVE/FXRSTOR, in case somebody needs to save those valuable xmm regs. Note that saving is easy, but restoring is a bit problematic because you get also your FPU set to previously stored values.