windows计时器,完全搞晕了
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
includewindows.inc
includeuser32.inc
includelibuser32.lib
includekernel32.inc
includelibkernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ID_TIMER1equ1
ID_TIMER2equ2
ICO_1equ1
ICO_2equ2
DLG_MAINequ1
IDC_SETICONequ100
IDC_COUNTequ101
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstancedd?
hWinMaindd?
dwCountdd?
idTimerdd?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 定时器过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcTimerproc_hWnd,_uMsg,_idEvent,_dwTime
pushad
invokeGetDlgItemInt,hWinMain,IDC_COUNT,NULL,FALSE
inceax
invokeSetDlgItemInt,hWinMain,IDC_COUNT,eax,FALSE
popad
ret
_ProcTimerendp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 窗口过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcDlgMainprocuses ebx edi esi,hWnd,uMsg,wParam,lParam
moveax,uMsg
;********************************************************************
.ifeax ==WM_TIMER
moveax,wParam
.ifeax ==ID_TIMER1
incdwCount
moveax,dwCount
andeax,1
inceax
invokeLoadIcon,hInstance,eax
invokeSendDlgItemMessage,hWnd,IDC_SETICON,STM_SETIMAGE,IMAGE_ICON,eax
.elseifeax ==ID_TIMER2
invokeMessageBeep,-1
.endif
;********************************************************************
.elseifeax ==WM_INITDIALOG
pushhWnd
pophWinMain
invokeSetTimer,hWnd,ID_TIMER1,250,NULL
invokeSetTimer,hWnd,ID_TIMER2,2000,NULL
invokeSetTimer,NULL,NULL,1000,addr _ProcTimer
movidTimer,eax
;********************************************************************
.elseifeax ==WM_CLOSE
invokeKillTimer,hWnd,ID_TIMER1
invokeKillTimer,hWnd,ID_TIMER2
invokeKillTimer,NULL,idTimer
invokeEndDialog,hWnd,NULL
;********************************************************************
.else
moveax,FALSE
ret
.endif
moveax,TRUE
ret
_ProcDlgMainendp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invokeGetModuleHandle,NULL
movhInstance,eax
invokeDialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,NULL
invokeExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
endstart
.ifeax ==WM_TIMER
moveax,wParam
.ifeax ==ID_TIMER1
incdwCount
moveax,dwCount
andeax,1
inceax
invokeLoadIcon,hInstance,eax
invoke SendDlgItemMessage,hWnd,IDC_SETICON,STM_SETIMAGE,IMAGE_ICON,eax
.elseifeax ==ID_TIMER2
invokeMessageBeep,-1
.endif
_ProcTimerproc_hWnd,_uMsg,_idEvent,_dwTime这一段代码里,eax的值到底是多少?它是怎么来的呢?计时器怎么就会通过它实现了从1开始计数呢?
pushad
invokeGetDlgItemInt,hWinMain,IDC_COUNT,NULL,FALSE
inceax
invokeSetDlgItemInt,hWinMain,IDC_COUNT,eax,FALSE
popad
ret
_ProcTimerendp