来看看,这段程序错在哪!!

linjichao128 2009-01-12 11:04:31
.386
.model flat, stdcall
option casemap:none
;/////////////////////////////////////////////////

;包含文件
include windows.inc
include kernel32.inc
include gdi32.inc
include user32.inc
includelib kernel32.lib
includelib gdi32.lib
includelib user32.lib
;/////////////////////////////////////////////////

;定义资源
DLG_MAIN equ 1h
ICO_MAIN equ 1h
IDC_SHOWCOORDINATE equ 1001h
IDC_ALLOW equ 1002h
IDC_TOP equ 1003h
IDC_EXIT equ 1004h

;/////////////////////////////////////////////////
.data?
hInstance dd ?
hWindowDc dd ?
.const
szFormat db "pos:%d,%d ", 0
;/////////////////////////////////////////////////
.code
_ProcMain proc uses bx esi ebx hWnd, uMsg, wParam, lParam
local @szContent[1024]:byte
.if uMsg == WM_CLOSE
invoke EndDialog, hWnd, NULL
.elseif uMsg == WM_INITDIALOG
invoke LoadIcon, hInstance, ICO_MAIN
invoke SendMessage, hWnd, WM_SETICON, ICON_BIG, eax
.elseif uMsg == WM_COMMAND
mov eax, wParam
.if ax == IDC_ALLOW
;//未补充


.elseif ax == IDC_TOP
invoke IsDlgButtonChecked, hWnd, IDC_TOP
.if eax == BST_CHECKED
invoke SetWindowPos, hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE
.else
invoke SetWindowPos, hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE
.endif
.elseif ax == IDC_EXIT
invoke EndDialog, hWnd, NULL
.endif
.elseif uMsg == WM_MOUSEMOVE
mov eax, lParam
mov bx, ax
shr eax, 16
invoke wsprintf, addr @szContent, addr szFormat, ax, eax
invoke MessageBox, NULL, addr @szContent, addr @szContent, MB_OK

; invoke GetDC, NULL
; mov hWindowDc, eax
; invoke TextOut, hWindowDc, ax, bx,

.else
mov eax, FALSE
ret
.endif
mov eax, TRUE
ret
_ProcMain endp

start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke DialogBoxParam, hInstance, DLG_MAIN, NULL, offset _ProcMain, NULL
invoke ExitProcess, NULL
;/////////////////////////////////////////////////
end start
这段程序目的是要输出地址,但是X可行,而Y却异常,好像是是地址。
如果我这样写
invoke wsprintf, addr @szContent, offset szFormat, ax
invoke MessageBox, NULL, addr @szContent, addr @szContent, MB_OK
invoke wsprintf, addr @szContent, offset szFormat, eax
invoke MessageBox, NULL, addr @szContent, addr @szContent, MB_OK
此时eax 又好像输出正常,真搞不懂这是为什么。!
...全文
90 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnzdgs 2009-01-14
  • 打赏
  • 举报
回复
szFormat db "pos:%d,%d ", 0
这表示需要两个整型(32位)数据,bx只有16位,高16位无法确定。
cnzdgs 2009-01-13
  • 打赏
  • 举报
回复
mov bx, ax
shr eax, 16
invoke wsprintf, addr @szContent, addr szFormat, ax, eax
改成:
mov ebx, eax
and ebx, 0FFFFH
shr eax, 16
invoke wsprintf, addr @szContent, addr szFormat, ebx, eax
linjichao128 2009-01-13
  • 打赏
  • 举报
回复
请问为什么要这样写呢?
mov bx, ax
shr eax, 16
invoke wsprintf, addr @szContent, addr szFormat, bx, eax
这样为什么不行呢?

21,500

社区成员

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

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