标题:函数调用参数问题
只看楼主
马甲1号
Rank: 5Rank: 5
等 级:职业侠客
帖 子:68
专家分:312
注 册:2011-4-4
结帖率:100%
已结贴  问题点数:0 回复次数:3 
函数调用参数问题
.386
        .model flat, stdcall
        option casemap:none
;==========================================================

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

;==========================================================

        .data?
hInstance    dd    ?
g_hWnd        dd    ?

BALL    struct
    ball_x    dw    ?
    ball_y    dw    ?
    ball_cx    dw    ?
    ball_cy    dw    ?
BALL    ends

ball        BALL    <>
        
        .const
szClassName    db    'DrawBall', 0
szWindowTitle    db    'DrawBall-Demo', 0
szRegClassErr    db    'RegisterClassEx Error', 0
szCreateWndErr    db    'CreateWindowEx Error', 0
szCaptionErr    db    'Error!', 0

;==========================================================
        .code
_WndProc    proc    uses ebx edi esi hWnd, wMsg, wParam, lParam

        LOCAL    @hDc
        LOCAL    @stPaint:PAINTSTRUCT
        
        mov    eax, wMsg
        
        .if    eax ==    WM_PAINT
            invoke    BeginPaint, hWnd, addr @stPaint
            mov    @hDc, eax
        push    50
            push    50
            push    10
            push    10
            push    @hDc
            call    Ellipse
            
            ;invoke    Ellipse, @hDc, 10, 10, 50, 50
            
            invoke    EndPaint, hWnd, addr @stPaint
        .elseif    eax ==    WM_CREATE
            
            mov    ball.ball_x, 10
            mov    ball.ball_y, 10
            mov    ball.ball_cx, 50
            mov    ball.ball_cy, 50
        .elseif    eax ==    WM_CLOSE
            invoke    PostQuitMessage, 0
            invoke    DestroyWindow, hWnd
        .else
            invoke    DefWindowProc, hWnd, wMsg, wParam, lParam
            ret
        .endif
        
        mov    eax, 0
        ret
_WndProc     endp

_WinMain    proc
   
        LOCAL    @stWc:WNDCLASSEX
        LOCAL    @stMsg:MSG
        
        invoke    RtlZeroMemory, addr @stWc, sizeof WNDCLASSEX
        mov    @stWc.cbSize, sizeof WNDCLASSEX
        mov    @stWc.style, CS_HREDRAW or CS_VREDRAW
        mov    @stWc.lpfnWndProc, _WndProc
        push    hInstance
        pop    @stWc.hInstance
        invoke    LoadIcon, hInstance, IDI_APPLICATION
        mov    @stWc.hIcon, eax
        mov    @stWc.hIconSm, eax
        invoke    LoadCursor, hInstance, IDC_ARROW
        mov    @stWc.hCursor, eax
        invoke    GetStockObject, BLACK_BRUSH
        mov    @stWc.hbrBackground, eax
        mov    @stWc.lpszClassName, offset szClassName
        
        invoke    RegisterClassEx, addr @stWc
        .if    eax ==    0
            invoke    MessageBox, NULL, offset szRegClassErr, offset szCaptionErr, MB_OK or MB_ICONINFORMATION
            ret
        .endif
        
        invoke    CreateWindowEx, NULL, offset szClassName, offset szWindowTitle, WS_OVERLAPPEDWINDOW, 100, 100, 600, 400, NULL, NULL, hInstance, NULL
        mov    g_hWnd, eax
        .if    eax ==    NULL
            invoke    MessageBox, NULL, offset szCreateWndErr, offset szCaptionErr, MB_OK or MB_ICONINFORMATION
            ret
        .endif
        
        invoke    ShowWindow, g_hWnd, SW_SHOW
        invoke    UpdateWindow, g_hWnd
        
        .while TRUE
            invoke    GetMessage, addr @stMsg, NULL, NULL, NULL
            .break    .if eax == 0
            invoke    TranslateMessage, addr @stMsg
            invoke    DispatchMessage, addr @stMsg
        .endw
        
        ret
_WinMain     endp

start:
        invoke    GetModuleHandle, NULL
        mov    hInstance, eax
        
        invoke    _WinMain
        invoke    ExitProcess, NULL
        
        end    start
搜索更多相关主题的帖子: include option 
2011-05-11 16:43
马甲1号
Rank: 5Rank: 5
等 级:职业侠客
帖 子:68
专家分:312
注 册:2011-4-4
得分:0 
我想把Ellipse函数的参数用BALL结构体变量ball代进入, 但是程序没有画出椭圆

invoke Ellipse, @hDc, ball.ball_x, ball.ball_y, ball.ball_cx, ball.ball_cy

???????
2011-05-11 16:45
zaixuexi
Rank: 12Rank: 12Rank: 12
来 自:上海
等 级:火箭侠
威 望:8
帖 子:858
专家分:3233
注 册:2010-12-1
得分:20 
程序代码:
BALL    struct
    ball_x    dd    ?   ;自己想一想为什么用dd就可以了
    ball_y    dd    ?
    ball_cx   dd    ?
    ball_cy   dd    ?
BALL    ends
.if    eax ==    WM_PAINT
    invoke    BeginPaint, hWnd, addr @stPaint
    mov    @hDc, eax
    push    ball.ball_cy
    push    ball.ball_cx
    push    ball.ball_y
    push    ball.ball_x
    push    @hDc
    call    Ellipse 

技术问题,请不要以短消息方式提问
2011-05-11 22:57
马甲1号
Rank: 5Rank: 5
等 级:职业侠客
帖 子:68
专家分:312
注 册:2011-4-4
得分:0 
哦, 我明白了, 是操作位数不一样

???????
2011-05-12 11:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-339498-1-1.html




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

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