斑竹请进
下面是一个时钟问题 我是初学者 能帮我解释一下各语句的意思吗 还有大致的设计思路 很是感谢 THANK YOU.386
.Model Flat, StdCall
Option Casemap :None
Include windows.inc
Include user32.inc
Include kernel32.inc
Include gdi32.inc
includelib gdi32.lib
IncludeLib user32.lib
IncludeLib kernel32.lib
include macro.asm
LOWORD MACRO bigword;; Retrieves the low word from double word argument
mov eax,bigword
and eax,0FFFFh ;; Get low word
ENDM
HIWORD MACRO bigword ;; Retrieves the high word from double word
mov ebx,bigword
shr ebx,16;; Shift 16 for high word to set to high word
ENDM
RGB MACRO red, green, blue ;; Get composite number from red green and blue bytes
mov al,blue ;; ,,,blue
shl eax,8 ;; ,,blue,
add al,green;; ,,blue,green
shl eax,8 ;; ,blue,green,
add al,red ;; ,blue,green,red
and eax,0FFFFFFh;; Mask out top byte to complete COLORREF dword
ENDM
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
ID_TIMER equ 1
.DATA
szAppName db "DigClock",0
fSevenSegment BYTE 1, 1, 1, 0, 1, 1, 1,\
0, 0, 1, 0, 0, 1, 0,\
1, 0, 1, 1, 1, 0, 1,\
1, 0, 1, 1, 0, 1, 1,\
0, 1, 1, 1, 0, 1, 0,\
1, 1, 0, 1, 0, 1, 1
dummy0 BYTE 1, 1, 0, 1, 1, 1, 1,\
1, 0, 1, 0, 0, 1, 0,\
1, 1, 1, 1, 1, 1, 1,\
1, 1, 1, 1, 0, 1, 1
ptSegment POINT {7, 6}, {11, 2}, {31, 2}, {35, 6}, {31, 10}, {11, 10},\
{ 6, 7}, {10, 11}, {10, 31}, {6, 35}, {2, 31}, {2, 11},\
{ 36, 7}, {40, 11}, {40, 31}, {36, 35}, {32, 31}, {32, 11},\
{ 7 , 36}, {11, 32}, {31, 32}, {35, 36}, {31, 40}, {11, 40},\
{ 6 , 37}, {10, 41}, {10, 61}, {6, 65}, {2, 61}, {2, 41},\
{ 36, 37}, {40, 41}, {40, 61}, {36, 65}, {32, 61}, {32, 41}
dummy1 POINT { 7 , 66}, {11, 62}, {31, 62}, {35, 66}, {31, 70}, {11, 70}
ptColon POINT {2,21},{6,17},{10,21},{6,25},{2,51},{6,47},{10,51},{6,55 }
.DATA?
hInstance dd ?
cxClient dd ?
cyClient dd ?
f24Hour BOOL ?
fSuppress BOOL ?
hBrushRed HBRUSH ?
.CODE
START: ;从这里开始执行
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke WinMain,hInstance,NULL,NULL,SW_SHOWDEFAULT
invoke ExitProcess,0
WinMain proc hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,iCmdShow:DWORD
LOCAL wndclass :WNDCLASSEX
LOCAL msg :MSG
LOCAL hWnd :HWND
mov wndclass.cbSize,sizeof WNDCLASSEX
mov wndclass.style,CS_HREDRAW or CS_VREDRAW
mov wndclass.lpfnWndProc,offset WndProc
mov wndclass.cbClsExtra,0
mov wndclass.cbWndExtra,0
push hInst
pop wndclass.hInstance
invoke LoadIcon,NULL,IDI_APPLICATION
mov wndclass.hIcon,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wndclass.hCursor,eax
invoke GetStockObject,WHITE_BRUSH
mov wndclass.hbrBackground,EAX
mov wndclass.lpszMenuName,NULL
mov wndclass.lpszClassName,offset szAppName
mov wndclass.hIconSm,0
invoke RegisterClassEx, ADDR wndclass
.if (EAX==0)
invoke MessageBox,NULL,CTXT("This program requires Windows NT!"),addr szAppName,MB_ICONERROR
ret
.endif
invoke CreateWindowEx,
NULL,
ADDR szAppName, ;window class name
CTXT("Digital Clock"), ;window caption
WS_OVERLAPPEDWINDOW, ;window style
CW_USEDEFAULT, ;initial x position
CW_USEDEFAULT, ;initial y position
CW_USEDEFAULT, ;initial x size
CW_USEDEFAULT,;initial y size
NULL,;parent window handle
NULL,;window menu handle
hInstance,;program instance handle
NULL;creation parameters
mov hWnd,eax
invoke ShowWindow,hWnd,iCmdShow
invoke UpdateWindow,hWnd
StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:
mov eax,msg.wParam
ret
WinMain endp
DisplayDigit proc hdc:HDC,iNumber:DWORD ;显示一个数字
LOCAL iSeg:DWORD
mov eax,iNumber
shl eax,3
sub eax,iNumber ;iNumber*8-iNumber
lea edi,fSevenSegment
add edi,eax
lea esi,ptSegment;取数字对应的数码管是否显示
mov iSeg,0
.while (iSeg<7)
mov al,[edi]
.if (al!=0)
invoke Polygon,hdc,esi,6
.endif
inc iSeg
add esi,48
add edi,1
.endw
ret
DisplayDigit Endp
DisplayTwoDigits proc hdc:HDC,iNumber:DWORD,fSuppressDT:BOOL ;显示2位数字
xor edx,edx
mov eax,iNumber
mov ecx,10
div ecx
push edx
.if (fSuppressDT==0)||(edx!=0)
invoke DisplayDigit,hdc,eax
.endif
invoke OffsetWindowOrgEx,hdc,-42,0,NULL
pop edx
invoke DisplayDigit,hdc,edx
invoke OffsetWindowOrgEx,hdc,-42,0,NULL
ret
DisplayTwoDigits Endp
DisplayColon proc hdc:HDC ;显示冒号
lea esi,ptColon
invoke Polygon,hdc,esi,4
add esi,32
invoke Polygon,hdc,esi,4
invoke OffsetWindowOrgEx,hdc,-12,0,NULL
ret
DisplayColon Endp
DisplayTime proc hdc:HDC,f24HourDispT:BOOL,fSuppressDispT:BOOL
LOCAL stCurrent:SYSTEMTIME
invoke GetLocalTime,addr stCurrent
.if (f24HourDispT)
invoke DisplayTwoDigits,hdc,stCurrent.wHour,fSuppressDispT
.else
xor edx,edx
xor eax,eax
mov ax,stCurrent.wHour
mov ecx,12
div ecx
.if (edx==0)
mov eax,12
.else
xor eax,eax
mov ax,stCurrent.wHour
.endif
invoke DisplayTwoDigits,hdc,eax,fSuppressDispT
.endif
invoke DisplayColon,hdc
invoke DisplayTwoDigits,hdc,stCurrent.wMinute,FALSE
invoke DisplayColon,hdc
invoke DisplayTwoDigits,hdc,stCurrent.wSecond,FALSE
ret
DisplayTime Endp
WndProc proc uses ebx esi edi ,hwnd:DWORD,message:DWORD,wParam :DWORD,lParam :DWORD
LOCAL hdc:HDC
LOCAL ps :PAINTSTRUCT
LOCAL szBuffer[2] :TCHAR
.if message == WM_CREATE
RGB 255,0,0
invoke CreateSolidBrush,eax
mov hBrushRed,eax
invoke SetTimer,hwnd,ID_TIMER,500,NULL
jmp @f
.elseif message == WM_SETTINGCHANGE
@@:
invoke GetLocaleInfo,LOCALE_USER_DEFAULT,LOCALE_ITIME,addr szBuffer,2
.if (szBuffer[0]=='1')
mov f24Hour,TRUE
.else
mov f24Hour,FALSE
.endif
invoke GetLocaleInfo,LOCALE_USER_DEFAULT,LOCALE_ITLZERO,addr szBuffer,2
.if (szBuffer[0]=='0')
mov f24Hour,TRUE
.else
mov f24Hour,FALSE
.endif
invoke InvalidateRect,hwnd,NULL,TRUE
xor eax,eax
ret
.elseif message == WM_SIZE
LOWORD lParam
mov cxClient,eax
HIWORD lParam
mov cyClient,ebx
xor eax,eax
ret
.elseif message == WM_TIMER
invoke InvalidateRect,hwnd,NULL,TRUE
xor eax,eax
ret
.elseif message == WM_PAINT
invoke BeginPaint, hwnd, ADDR ps
mov hdc,eax ; Get handle to device context
invoke SetMapMode,hdc,MM_ISOTROPIC
invoke SetWindowExtEx,hdc,276,72,NULL
invoke SetViewportExtEx,hdc,cxClient,cyClient,NULL
invoke SetWindowOrgEx,hdc,138,36,NULL
push NULL
mov eax,cyClient
shr eax,1
push eax
mov eax,cxClient
shr eax,1
push eax
push hdc
call SetViewportOrgEx
invoke GetStockObject,NULL_PEN
invoke SelectObject,hdc,eax
invoke SelectObject,hdc,hBrushRed
invoke DisplayTime,hdc,f24Hour,fSuppress
invoke EndPaint, hwnd, ADDR ps
xor eax,eax
ret
.elseif message == WM_DESTROY
invoke KillTimer,hwnd,ID_TIMER
invoke DeleteObject,hBrushRed
invoke PostQuitMessage,NULL
ret
.endif
invoke DefWindowProc,hwnd, message, wParam, lParam
ret
WndProc endp
END START