麻烦高人帮我看看这个程序在哪里出错了?怎么一直编译不过去啊!!

SteveYoung 2004-05-06 02:11:21
.386
.model flat, stdcall
option casemap:none

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

.data

hInstance dd ?
hWinMain dd ?
szBuffer db 512 dup(?)

.const

szClassName db 'MyClass', 0
szCaptionMain db 'Recive Message', 0
szRecive db 'Recive Message', 0dh, 0ah
db 'param: %08x', 0dh, 0ah
db 'text : %s', 0dh, 0ah, 0

.code

_ProcWinMain proc uses ebx edi esi, hWnd, uMsg, wParam, lParam
mov eax, uMsg
.if eax == WM_CLOSE
invoke DestroyWindow, hWinMain
invoke PostQuitMessage, NULL
.elseif eax == WM_SETTEXT
invoke wsprintf, addr szBuffer, addr szRecive, wParam, lParam
invoke MessageBox, hWinMain, offset szBuffer, addr szCaptionMain, MB_OK
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam

ret
.endif
xor eax, eax
ret
_ProcWinMain endp

_WinMain proc
local @stWndClass:WNDCLASSEX
local @stMsg:MSG

invoke GetModuleHandle, NULL
mov hInstance, eax
invoke RtlZeroMemory, addr @stWndClass, sizeof @stWndClass
invoke LoadCursor, 0, IDC_ARROW
mov @stWndClass.hCursor, eax
mov eax,hInstance
mov @stWndClass.hInstance, eax
mov @stWndClass.cbSize, sizeof WNDCLASSEX
mov @stWndClass.style, CS_HREDRAW or CS_VERDRAW
mov @stWndClass.hbrBackgroud, COLOR_WINDOW + 1
mov @stWndClass.lpszClassName, offset szClassName
invoke RegisterClassEx, addr @stWndClass
invoke CreateWindowEx, WS_EX_CLIENTEDGE, offset szClassName, offset szCaptionMain,\
WS_OVERLAPPEDWINDOW, 50, 50, 200, 150, NULL, NULL, hInstance, NULL
mov hWinMain, eax
invoke ShowWindow, hWinMain, SW_SHOWNORMAL
invoke UpdateWindow,hWinMain

.while TRUE
invoke GetMessage, addr @stMsg, NULL, 0, 0
.break
.if eax == 0
invoke TranslateMessage, addr @stMsg
invoke DispatchMessage, addr @stMsg
.endw
ret
_WinMain endp

start:
call _WinMain
invoke ExitProcess, NULL
end start
...全文
61 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
SteveYoung 2004-05-07
  • 打赏
  • 举报
回复
太谢谢楼上三位大虾了!!!!!!!!!!!非常感谢!!!!!!!
vicallee 2004-05-06
  • 打赏
  • 举报
回复
有四个地方有问题
1。mov @stWndClass.style, CS_HREDRAW or CS_VERDRAW
^^^^^^^^^^
改为CS_VREDRAW
2.mov @stWndClass.hbrBackgroud, COLOR_WINDOW + 1
^^^^^^^^^^^^^
改为hbrBackground
3. .break
.if eax == 0
这里要改为一行:
.break .if eax==0
4.mov @stWndClass.lpfnWndProc,offset _ProcWinMain
这一句不写的话,就是致命的了。
csdsjkk 2004-05-06
  • 打赏
  • 举报
回复
.386
.model flat, stdcall
option casemap:none

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

.data

hInstance dd ?
hWinMain dd ?
szBuffer db 512 dup(?)

.const

szClassName db 'MyClass', 0
szCaptionMain db 'Recive Message', 0
szRecive db 'Recive Message', 0dh, 0ah
db 'param: %08x', 0dh, 0ah
db 'text : %s', 0dh, 0ah, 0

.code

_ProcWinMain proc uses ebx edi esi, hWnd, uMsg, wParam, lParam
mov eax, uMsg
.if eax == WM_CLOSE
invoke DestroyWindow, hWinMain
invoke PostQuitMessage, NULL
.elseif eax == WM_SETTEXT
invoke wsprintf, addr szBuffer, addr szRecive, wParam, lParam
invoke MessageBox, hWinMain, offset szBuffer, addr szCaptionMain, MB_OK
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam

ret
.endif
xor eax, eax
ret
_ProcWinMain endp

_WinMain proc
local @stWndClass: WNDCLASSEX
local @stMsg: MSG

invoke GetModuleHandle, NULL
mov hInstance, eax
invoke RtlZeroMemory, addr @stWndClass, sizeof @stWndClass
invoke LoadCursor, 0, IDC_ARROW
mov @stWndClass.hCursor, eax
mov eax,hInstance
mov @stWndClass.hInstance, eax
mov @stWndClass.cbSize, sizeof WNDCLASSEX
mov @stWndClass.lpfnWndProc,offset _ProcWinMain
mov @stWndClass.style, CS_HREDRAW or CS_VREDRAW
mov @stWndClass.hbrBackground, COLOR_WINDOW + 1
mov @stWndClass.lpszClassName, offset szClassName
invoke RegisterClassEx, addr @stWndClass
invoke CreateWindowEx , WS_EX_CLIENTEDGE, addr szClassName, addr szCaptionMain, WS_OVERLAPPEDWINDOW, 50, 50, 200, 150, NULL, NULL, hInstance, NULL
mov hWinMain, eax
invoke ShowWindow, hWinMain, SW_SHOWNORMAL
invoke UpdateWindow,hWinMain

.while TRUE
invoke GetMessage, addr @stMsg, NULL, 0, 0
.if eax == 0
.break
.endif
invoke TranslateMessage, addr @stMsg
invoke DispatchMessage, addr @stMsg
.endw
ret
_WinMain endp

start:
call _WinMain
invoke ExitProcess, NULL
end start

dunkel 2004-05-06
  • 打赏
  • 举报
回复
...
mov @stWndClass.style, CS_HREDRAW or CS_VERDRAW ;** CS_VREDRAW
mov @stWndClass.hbrBackgroud, COLOR_WINDOW + 1 ;** .hbrBackground
...
.while TRUE
invoke GetMessage, addr @stMsg, NULL, 0, 0
.break
.if eax == 0 ;** 对应的 .endif 在哪里?
invoke TranslateMessage, addr @stMsg
invoke DispatchMessage, addr @stMsg
.endw
...


; ';**' 后面的内容是有问题的, 但之后生成的 .exe 仍有执行时的问题
; 应该是 .while 的消息循环处理的流程不对
SteveYoung 2004-05-06
  • 打赏
  • 举报
回复
晕了,没想到发到上边这么乱,大家复制一下到记事本里边看吧,源程序的格式还是很整齐的

21,458

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧