;=========================================
.386
.model flat, stdcall
;32 bit memory model
option casemap :none
;case sensitive
include text1.inc
.code
start:
invoke GetModuleHandle,NULL
mov
hInstance,eax
invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,
addr DlgProc,NULL
;addr 只能向前引用,不能向后引用,应改为offset
invoke ExitProcess,0
mm proc s1:DWORD,s2:DWORD,s3:DWORD
cmp bz,0 ;cmp指令的使用,必须有寄存器的参与
je jiami
jmp jiemi
jiami:
mov esi,offset s
lea edi,s1
;把s1的有效地址装入edi
mov al,[esi] ;如果进行字节操作,注意用al
mov [edi],al
shl s1,1 ;错误,shl只能处理寄存器或内存单元中的数据,S1是个数据区
add s1,3
inc byte ptr [esi]
mov al,[esi] ;进行字操作的话就用ax,类推
cmp al,0
je L2
jmp jiami
jiemi:
mov esi,offset s1
lea edi,s2
;把s1的有效地址装入edi
mov al,[esi] ;如果进行字节操作,注意用al
mov [edi],al
sub s2,3
shr s2,1
inc byte ptr [esi]
mov al,[esi]
cmp al,0
je L2
jmp jiemi
L2:ret
mm endp
;########################################################################
DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
mov
eax,uMsg
.if eax==WM_INITDIALOG
.elseif eax==WM_COMMAND
mov
eax,wParam
.if eax==1001
mov
eax,wParam
.if eax==1001
mov bz,0
.if eax==1002
mov bz,1
invoke mm,addr s1,addr s2,bz
invoke MessageBox,hWin,addr mess1, addr mtl,MB_OK
.endif
.endif
.endif
.elseif eax==WM_CLOSE
invoke EndDialog,hWin,0
.else
mov
eax,FALSE
ret
.endif
mov
eax,TRUE
ret
DlgProc endp
end start
这是.inc文件
include windows.inc
include kernel32.inc
include user32.inc
include Comctl32.inc
include shell32.inc
include D:\masm32\新建文件夹\RadASM\masm\inc\radbg.inc
includelib kernel32.lib
includelib user32.lib
includelib Comctl32.lib
includelib shell32.lib
DlgProc
PROTO
:HWND,:UINT,:WPARAM,:LPARAM
.const
IDD_DIALOG1
equ 101
;#########################################################################
.data?
hInstance
dd ?
;#########################################################################
.data
mtl
db
"test my titles",0
mmsg db
"hello world!",0
s DB "hello",0
s1 dd 20 dup(0)
s2 dd 20 dup(0)
bz db ?
mess1 db "finished(XxY+Z-V)/P!",0