| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2445 人关注过本帖
标题:斑竹请进
只看楼主 加入收藏
sajiyu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-10-3
收藏
 问题点数:0 回复次数:11 
斑竹请进
下面是一个时钟问题  我是初学者  能帮我解释一下各语句的意思吗  还有大致的设计思路  很是感谢  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
搜索更多相关主题的帖子: 斑竹 
2008-11-09 13:55
ONEPROBLEM
Rank: 6Rank: 6
来 自:广西 南宁
等 级:贵宾
威 望:21
帖 子:1569
专家分:349
注 册:2008-7-11
收藏
得分:0 
建议楼主从最基础的学起~~
2008-11-09 14:01
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:0 
这个偶也没看懂~~

等ONEPLOBLEM他们给你解释吧
2008-11-09 14:02
sajiyu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-10-3
收藏
得分:0 
回复 2# 的帖子
我~~
能告诉我GETLOCALTIME  怎么使用吗   以及实现这个函数的整个程序  相信这样会简单很多  程序效率也会高很多
2008-11-09 16:12
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:0 
[bo][un]sajiyu[/un] 在 2008-11-9 16:12 的发言:[/bo]

我~~
能告诉我GETLOCALTIME  怎么使用吗   以及实现这个函数的整个程序  相信这样会简单很多  程序效率也会高很多


上百度上找比问我快 而且权威!
2008-11-09 16:16
ONEPROBLEM
Rank: 6Rank: 6
来 自:广西 南宁
等 级:贵宾
威 望:21
帖 子:1569
专家分:349
注 册:2008-7-11
收藏
得分:0 
[bo][un]sajiyu[/un] 在 2008-11-9 16:12 的发言:[/bo]

我~~
能告诉我GETLOCALTIME  怎么使用吗   以及实现这个函数的整个程序  相信这样会简单很多  程序效率也会高很多

这是我以前学编程的时候 写的,虽然粗陋,但将就一下吧:
;===================================================
        .386
        .model flat,stdcall
        option casemap:none

include        windows.inc
include        user32.inc
includelib    user32.lib
include        kernel32.inc
includelib    kernel32.lib

ID_DIALOG    equ    1
ICO_MAIN    equ    1
IDC_YEAR    equ    100
IDC_MONTH    equ    101
IDC_DAY        equ    102
IDC_HOUR    equ    103
IDC_MINUTE    equ    104
IDC_SECOND    equ    105

        .data?
        
hInstance    dd    ?
hWinMain    dd    ?
idTimer        dd    ?

        .code
        
_Getlocaltime    proc    _hWnd,uMsg,_idEvent,_dwTime
        local    @stTime:SYSTEMTIME
        pushad
        invoke    GetLocalTime,addr @stTime
        movzx    eax,@stTime.wYear
        invoke    SetDlgItemInt,hWinMain,IDC_YEAR,eax,FALSE
        movzx    eax,@stTime.wMonth
        invoke    SetDlgItemInt,hWinMain,IDC_MONTH,eax,FALSE
        movzx    eax,@stTime.wDay
        invoke    SetDlgItemInt,hWinMain,IDC_DAY,eax,FALSE
        movzx    eax,@stTime.wHour
        invoke    SetDlgItemInt,hWinMain,IDC_HOUR,eax,FALSE
        movzx    eax,@stTime.wMinute
        invoke    SetDlgItemInt,hWinMain,IDC_MINUTE,eax,FALSE
        movzx    eax,@stTime.wSecond
        invoke    SetDlgItemInt,hWinMain,IDC_SECOND,eax,FALSE
        popad
        ret
_Getlocaltime    endp

_ProcDlgMain    proc    uses ebx edi esi,hWnd,uMsg,wParam,LParam
        mov    eax,uMsg
        
        .if    eax == WM_INITDIALOG
            push    hWnd
            pop    hWinMain
            invoke    LoadIcon,hInstance,ICO_MAIN
            invoke    SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
            invoke    SetTimer,NULL,NULL,1000,addr _Getlocaltime
            mov    idTimer,eax
            
        .elseif    eax == WM_COMMAND
            mov    eax,wParam
            .if    ax == IDCANCEL
                invoke    KillTimer,NULL,idTimer
                invoke    EndDialog,hWnd,NULL
            .endif
                
        .elseif    eax == WM_CLOSE
            invoke    KillTimer,NULL,idTimer
            invoke    EndDialog,hWnd,NULL
            
        .else
            mov    eax,FALSE
            ret
        .endif
        mov    eax,TRUE
        ret
            
_ProcDlgMain    endp

start:
        invoke    GetModuleHandle,NULL
        mov    hInstance,eax
        invoke    DialogBoxParam,hInstance,ID_DIALOG,NULL,offset _ProcDlgMain,NULL
        invoke    ExitProcess,NULL
        
        end    start
;=======================================================

ONEPROBLEM.jpg (17.08 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
收到的鲜花
  • zklhp2008-11-09 16:36 送鲜花  50朵   附言:我很赞同
2008-11-09 16:26
sajiyu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-10-3
收藏
得分:0 
回复 6# 的帖子
出现错误。。
link.exe /SUBSYSTEM:WINDOWS /nologo /OUT:"无题1.exe" "无题1.obj"
LINK : fatal error LNK1181: cannot open input file "无题1.obj"
不知道  怎么解决   
我用的是MASMPLUS
2008-11-09 22:23
ONEPROBLEM
Rank: 6Rank: 6
来 自:广西 南宁
等 级:贵宾
威 望:21
帖 子:1569
专家分:349
注 册:2008-7-11
收藏
得分:0 
[bo][un]sajiyu[/un] 在 2008-11-9 22:23 的发言:[/bo]

出现错误。。
link.exe /SUBSYSTEM:WINDOWS /nologo /OUT:"无题1.exe" "无题1.obj"
LINK : fatal error LNK1181: cannot open input file "无题1.obj"
不知道  怎么解决   
我用的是MASMPLUS

当然会出错了~~因为,我只给了源代码.
2008-11-09 22:33
ONEPROBLEM
Rank: 6Rank: 6
来 自:广西 南宁
等 级:贵宾
威 望:21
帖 子:1569
专家分:349
注 册:2008-7-11
收藏
得分:0 
打了个包~~LZ自己学习一下吧.

ONEPROBLEM.rar (3.68 KB)
2008-11-09 22:35
hokers
Rank: 1
等 级:新手上路
威 望:1
帖 子:102
专家分:0
注 册:2008-11-9
收藏
得分:0 
虽然API还不懂,不过看程序是通过API调用时间,通过SetDlgItemInt显示.
2008-11-10 00:45
快速回复:斑竹请进
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036119 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved