电话本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
.386					;汇编语言的伪指令,再80386及以后的处理器中使用该指令集
.model flat,stdcall ;模式定义“model 内存模式【调用模式】”
option casemap:none ;选项设定(设定为对大小写敏感)


include windows.inc
include msvcrt.inc ;包含c语言的库
includelib msvcrt.lib ;包含c语言库对应的lib文件


.data

;定义结构体
CONTACTSSTRUCT struct
szName BYTE 25 dup(0)
szPhNumber BYTE 12 dup(0)
CONTACTSSTRUCT ends

PCONTACTSSTRUCT TYPEDEF PTR CONTACTSSTRUCT ;取别名(指针类型)

;声明全局变量
g_stConstacts CONTACTSSTRUCT 100 dup(<'0'>) ;定义结构体数组
g_nCount DWORD 0 ;元素个数
g_nCountMax DWORD 100 ;最大存放元素个数
g_strTemContacts CONTACTSSTRUCT <'0','0'> ;接收输入的信息

;定义格式控制字符
g_szScanfFormat BYTE '%s %s',0
g_szScanName BYTE '%s',0
Line db " ",0Ah,0

;菜单数据
MenuStaly db " ======================================",0Ah,0h
MenuPage db "《 根据序号选择你要进行的操作 》",0Ah,0h
MenuReadAll db "《 --1---- 查看所有联系人 ----1- 》",0Ah,0h
MenuAdd db "《 --2---- 添加联系人 ----2- 》",0Ah,0h
Menudel db "《 --3---- 删除联系人 ----3- 》",0Ah,0h
Menuchage db "《 --4---- 修改联系人 ----4- 》",0Ah,0h
MenuSeach db "《 --5---- 搜索联系人 ----5- 》",0Ah,0h
MenuSave db "《 --6---- 保存改变 ----6- 》",0Ah,0h
MenuExit db "《 --7---- 退出 ----7- 》",0Ah,0h
MenuNull db "《 》",0Ah,0h
clean db "cls",0h

;菜单选择数据
printPlease db "请输入: ",0h
intFormat db "%d",0h
case byte 0
printError db "你的输入有误: ",0Ah,0h

;添加用户数据所用字符串
g_szAddStr db "请输入你所要保存的联系人",0Ah,0h
g_szAddTpn db "请输入你所要保存的电话号码",0Ah,0h
g_szAddSuse db "添加成功",0Ah,0h
strPause db "pause",0h

;查询联系人所用数据
g_szFindstr db "请输入你所要查询的联系人",0Ah,0h

;删除联系人所用数据
g_szRemovepri db "请输入你要删除的数据",0Ah,0h
g_szRemovestr db "请再次确认是否删除",0Ah,0h

;修改数据所用
g_szModifypri db "请输入你要修改的数据",0Ah,0h


;文件操作所用数据
filep db "2L",0h

wb db "w+",0h

rb db "r+",0h

FilePath db ".\INFO.txt",0h

;file dword ?

Save db "保存成功",0Ah,0h


;菜单界面
MenuShell proc
push offset clean
call crt_system
add esp,04h
push offset MenuStaly
call crt_printf
push offset MenuPage
call crt_printf
add esp,8h
push offset MenuNull
call crt_printf
push offset MenuNull
call crt_printf
add esp,8h

push offset MenuReadAll
call crt_printf
push offset MenuAdd
call crt_printf
add esp,8h

push offset Menudel
call crt_printf
push offset Menuchage
call crt_printf
add esp,8h


push offset MenuSeach
call crt_printf
push offset MenuSave
call crt_printf
add esp,8h

push offset MenuExit
call crt_printf
push offset MenuNull
call crt_printf
add esp,8h
push offset MenuNull
call crt_printf
push offset MenuStaly
call crt_printf
add esp,08h

ret

MenuShell endp

.code
;选择操作
SwitchCase proc


start:

push offset printPlease
call crt_printf
add esp,04h

push offset case ;把接收的缓冲区压入栈
push offset intFormat ;把接收字符的变量压入栈
call crt_scanf ;调用接收字符的函数
add esp,8h ;弹出接收字符的变量

push offset case
mov al,[case]
add esp,4
cmp al,1h ;1查看所有联系人
jnz next2
call LookAllData
next2:
cmp al,2h ;2添加一个联系人
jnz next3
call ADD_USER

next3:

cmp al,3
jnz next4
call RemoveData ;3删除一个联系人
next4:
cmp al,4
jnz next5 ;4修改一个联系人
call ModifyData


next5:

cmp al,5 ;5搜索一个联系人
jnz next6
call FindData
next6:
cmp al,6
jnz next7 ;保存
call SaveData


next7:
cmp al,7 ;7退出
jz exit
defaul:
push offset printError ;1-6的范围,其余报错,且返回主菜单
call crt_printf
add esp,04h
call MenuShell
jmp start
exit:
ret
SwitchCase endp


;查看所有
LookAllData proc
pop ebp
mov ebp,esp
sub esp,050h


mov ecx,0h ;初始化循环次数

NEXT:
push ecx
cmp ecx,g_nCount ;比较元素个数和0是否相等(循环完后即相等)
jg EXIT


lea esi,[g_stConstacts] ;把保存信息的结构体的地址赋值给esi
mov eax,sizeof(CONTACTSSTRUCT) ;计算结构体大小
imul eax,ecx ;把结构体大小乘以结构体个数(得到总大小,就是结构体尾部插入数据的偏移量)
add esi,eax ;把这个偏移量给esi


push offset Line
call crt_printf
add esp,4
lea ebx,[esi+CONTACTSSTRUCT.szName]
push ebx ;
push offset g_szScanName ;
call crt_printf ;
add esp,08h

push offset Line
call crt_printf
add esp,4
lea ebx,[esi+CONTACTSSTRUCT.szPhNumber] ;
push ebx ;
push offset g_szScanName ;
call crt_printf ;
add esp,08h ;

pop ecx
inc ecx ;外循环次数加1
jmp NEXT ;继续外循环



EXIT:
push offset Line
call crt_printf
push offset strPause
call crt_system
add esp,8
mov esp,ebp
pop ebp
call main ;返回主菜单






ret

LookAllData endp


;添加用户信息
ADD_USER proc
push eax
push ebx ;先保存原来寄存器的值


;根据ecx的值找到下一个结构体名字数组的地址
lea esi,[g_stConstacts] ;保存结构体数组
mov ecx,g_nCount ;保存元素个数
mov eax,sizeof(CONTACTSSTRUCT) ;计算结构体大小
imul eax,ecx ;当前个数乘与结构体大小,把结果放到eax中
add esi,eax ;之前的结构体数组的地址加上偏移量,等于下一个结构体的地址


;调用crt_scanf函数接收输入的数据
lea eax,g_szAddStr ;lea表示取第二个操作数的地址放到第一个操作数中
push eax
call crt_printf ;打印提示(字符串地址再eax中,使用lea保存到eax)
;call crt_printf
add esp,4h ;平栈




lea eax,[esi+CONTACTSSTRUCT.szName] ;把接收联系人的地址放到eax中
push eax ;把eax中存储的地址压到栈中
push offset g_szScanName ;压入一个输出控制符
call crt_scanf ;调用接收字符的c语言函数
add esp,08h ;平栈


lea eax,g_szAddTpn ;lea表示取第二个操作数的地址放到第一个操作数中
push eax
call crt_printf ;打印提示(字符串地址再eax中,使用lea保存到eax)
add esp,4h ;平栈
lea edx,[esi+CONTACTSSTRUCT.szPhNumber] ;把接收电话号码的地址放到ebx中
push edx ;把eax中存储的地址压到栈中
push offset g_szScanName ;压入一个输出控制符
call crt_scanf ;调用接收字符的c语言函数
add esp,08h ;平栈





push offset g_szAddSuse ;添加成功字符串压入栈
call crt_printf ;再控制台打印
add esp,04h ;平栈

inc g_nCount ;元素个数自增1

push offset strPause
call crt_system
add esp,04h



pop eax ;把之前保存的寄存器弹出
pop ebx ;
call SwitchCase

ret

ADD_USER endp


;查询用户信息
FindData proc
pop ebp
mov ebp,esp
sub esp,050h

;输入要查询的数据
lea eax,g_szFindstr
push eax
call crt_printf
add esp,04h


lea edi,[g_strTemContacts.szName] ;把结构体中名字的地址赋值给edi
push edi ;把名字的地址压入栈
push offset g_szScanName ;格式控制符
call crt_scanf ;调用接收字符的c语言函数
add esp,08h ;平栈
push edi
call crt_strlen
pop edi
mov [ebp-8],eax

;根据输入的名字查询
mov ecx,0h ;初始化循环次数
NEXT:
cmp ecx,g_nCount ;比较元素个数和0是否相等(循环完后即相等)
jge EXIT

lea edi,[g_strTemContacts.szName] ;把结构体名字的地址赋值给edi

lea esi,[g_stConstacts.szName] ;把保存信息的结构体的地址赋值给esi
mov eax,sizeof(CONTACTSSTRUCT) ;计算结构体大小
imul eax,ecx ;把结构体大小乘以结构体个数(得到总大小,就是结构体尾部插入数据的偏移量)
add esi,eax ;把这个偏移量给esi


;比较字符串
mov eax,ecx ;把循环次数给eax(元素个数)
mov ecx,[ebp-8] ;初始化
repe cmpsb BYTE ptr [esi], BYTE ptr[edi];esi存储的是结构体里的用户信息,edi是输入的信息,将这两个信息循环比较
jz PRINTFINFO ;如果相等就跳转(找到了)
mov ecx,eax ;把外循环次数还给ecx
inc ecx ;外循环次数加1
jmp NEXT ;继续外循环


;--------------------------------------------------------------------------------------------
;push esi
;push edi ;
;call crt_strcmp
;jz PRINTFINFO
;add esp,8h
;mov ecx,eax
;inc ecx
;jmp NEXT

PRINTFINFO:
;输出查询结果
;add esp,8h
mov ecx,eax ;循环
lea esi,[g_stConstacts]
mov ebx,sizeof(CONTACTSSTRUCT) ;计算结构体大小
imul ebx,ecx ;把结构体大小乘以结构体个数(得到总大小,就是结构体尾部插入数据的偏移量)
add esi,ebx ;把这个偏移量给esi(eax保存的是循环到底几次后找到的)
;mov [ebp-12],esi
lea ebx,[esi+CONTACTSSTRUCT.szName] ;


push ebx ;
push offset g_szScanName ;
call crt_printf ;
add esp,08h ;


lea eax,[esi+CONTACTSSTRUCT.szPhNumber] ;
push eax ;
push offset g_szScanName ;
call crt_printf ;
add esp,08h ;


push offset strPause
call crt_system
add esp,04h
;call crt_getchar ;
;call crt_getchar ;
EXIT:

mov esp,ebp
pop ebp
call main ;返回主菜单


ret
FindData endp

;修改数据
ModifyData proc
pop ebp
mov ebp,esp
sub esp,050h

;输入要查询的数据
lea eax,g_szModifypri
push eax
call crt_printf
add esp,04h


lea edi,[g_strTemContacts.szName] ;把结构体中名字的地址赋值给edi
push edi ;把名字的地址压入栈
push offset g_szScanName ;格式控制符
call crt_scanf ;调用接收字符的c语言函数
add esp,08h ;平栈
push edi
call crt_strlen
pop edi
mov [ebp-8],eax

;根据输入的名字查询
mov ecx,0h ;初始化循环次数
NEXT:
cmp ecx,g_nCount ;比较元素个数和0是否相等(循环完后即相等)
jge EXIT

lea edi,[g_strTemContacts.szName] ;把结构体名字的地址赋值给edi

lea esi,[g_stConstacts.szName] ;把保存信息的结构体的地址赋值给esi
mov eax,sizeof(CONTACTSSTRUCT) ;计算结构体大小
imul eax,ecx ;把结构体大小乘以结构体个数(得到总大小,就是结构体尾部插入数据的偏移量)
add esi,eax ;把这个偏移量给esi


;比较字符串
mov eax,ecx ;把循环次数给eax(元素个数)
mov ecx,[ebp-8] ;初始化
repe cmpsb BYTE ptr [esi], BYTE ptr[edi];esi存储的是结构体里的用户信息,edi是输入的信息,将这两个信息循环比较
jz PRINTFINFO ;如果相等就跳转(找到了)
mov ecx,eax ;把外循环次数还给ecx
inc ecx ;外循环次数加1
jmp NEXT ;继续外循环


PRINTFINFO:
;输出查询结果
;add esp,8h
mov ecx,eax ;循环
lea esi,[g_stConstacts]
mov ebx,sizeof(CONTACTSSTRUCT) ;计算结构体大小
imul ebx,ecx ;把结构体大小乘以结构体个数(得到总大小,就是结构体尾部插入数据的偏移量)
add esi,ebx ;把这个偏移量给esi(eax保存的是循环到底几次后找到的)

lea ebx,[esi+CONTACTSSTRUCT.szName] ;


push ebx ;
push offset g_szScanName ;
call crt_printf ;
add esp,08h ;


lea eax,[esi+CONTACTSSTRUCT.szPhNumber] ;
push eax ;
push offset g_szScanName ;
call crt_printf ;
add esp,08h ;



lea ebx,[esi+CONTACTSSTRUCT.szName]
push ebx
push offset g_szScanName
call crt_scanf


lea ebx,[esi+CONTACTSSTRUCT.szPhNumber]
push ebx
push offset g_szScanName
call crt_scanf

push offset strPause
call crt_system
add esp,04h

EXIT:

mov esp,ebp
pop ebp
call main ;返回主菜单







ModifyData endp


;删除数据
RemoveData proc
pop ebp
mov ebp,esp
sub esp,050h

;输入要查询的数据
lea eax,g_szRemovepri
push eax
call crt_printf
add esp,04h


lea edi,[g_strTemContacts.szName] ;把结构体中名字的地址赋值给edi
push edi ;把名字的地址压入栈
push offset g_szScanName ;格式控制符
call crt_scanf ;调用接收字符的c语言函数
add esp,08h ;平栈
push edi
call crt_strlen
pop edi
mov [ebp-8],eax

;根据输入的名字查询
mov ecx,0h ;初始化循环次数
NEXT:
cmp ecx,g_nCount ;比较元素个数和0是否相等(循环完后即相等)
jge EXIT

lea edi,[g_strTemContacts.szName] ;把结构体名字的地址赋值给edi

lea esi,[g_stConstacts.szName] ;把保存信息的结构体的地址赋值给esi
mov eax,sizeof(CONTACTSSTRUCT) ;计算结构体大小
imul eax,ecx ;把结构体大小乘以结构体个数(得到总大小,就是结构体尾部插入数据的偏移量)
add esi,eax ;把这个偏移量给esi


;比较字符串
mov eax,ecx ;把循环次数给eax(元素个数)
mov ecx,[ebp-8] ;初始化
repe cmpsb BYTE ptr [esi], BYTE ptr[edi];esi存储的是结构体里的用户信息,edi是输入的信息,将这两个信息循环比较
jz PRINTFINFO ;如果相等就跳转(找到了)
mov ecx,eax ;把外循环次数还给ecx
inc ecx ;外循环次数加1
jmp NEXT ;继续外循环


PRINTFINFO:
;输出查询结果
;add esp,8h
mov ecx,eax ;循环
lea esi,[g_stConstacts]
mov ebx,sizeof(CONTACTSSTRUCT) ;计算结构体大小
imul ebx,ecx ;把结构体大小乘以结构体个数(得到总大小,就是结构体尾部插入数据的偏移量)
add esi,ebx ;把这个偏移量给esi(eax保存的是循环到底几次后找到的)

lea ebx,[esi+CONTACTSSTRUCT.szName] ;


push ebx ;
push offset g_szScanName ;
call crt_printf ;
add esp,08h ;


lea eax,[esi+CONTACTSSTRUCT.szPhNumber] ;
push eax ;
push offset g_szScanName ;
call crt_printf ;
add esp,08h ;


push offset g_szRemovestr
call crt_printf
add esp,04h

mov [esi+CONTACTSSTRUCT.szPhNumber],0
mov [esi+CONTACTSSTRUCT.szName],0




EXIT:

mov esp,ebp
pop ebp
call main ;返回主菜单


ret

RemoveData endp


;保存数据
SaveData proc
push ebp
mov ebp,esp
sub esp,30h

push offset wb
push offset FilePath
call crt_fopen
mov [ebp-8],eax
add esp,8h



push [ebp-8] ;文件指针
push 1
push 4
lea ecx,g_nCount
push ecx
call crt_fwrite ;文件写入函数
add esp,16


push [ebp-8] ;结构体指针
mov eax,sizeof(CONTACTSSTRUCT) ;计算结构体大小
push g_nCount ;单个大小
push eax ;元素个数
push offset g_stConstacts ;文件指针
call crt_fwrite ;文件写入函数

add esp,10h

push [ebp-8]
call crt_fclose
add esp,4

push offset Save
call crt_printf
add esp,4

mov esp,ebp
pop ebp


call SwitchCase
ret

SaveData endp


;读取数据
ReadData proc

push ebp
mov ebp,esp
sub esp,30h

push offset rb
push offset FilePath
call crt_fopen
mov [ebp-8],eax
add esp,8h
cmp eax,0
jz tiao


push [ebp-8] ;文件指针
push 1
push 4
push offset g_nCount
call crt_fread ;文件写入函数
add esp,16

;call crt_fread ;文件写入函数
;add esp,16


push [ebp-8] ;结构体指针
mov eax,sizeof(CONTACTSSTRUCT) ;计算结构体大小
push offset g_nCount ;单个大小
push eax ;元素个数
push offset g_stConstacts ;文件指针
call crt_fread ;文件写入函数

add esp,16

push [ebp-8]
call crt_fclose
add esp,4



tiao:

mov esp,ebp
pop ebp
call MenuShell
ret

ReadData endp


;入口函数main
.code
main:
call ReadData
call MenuShell
call SwitchCase


end main

end

简单的窗口程序,带个按钮

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
.386 
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
includelib user32.lib ; calls to functions in user32.lib and kernel32.lib
include kernel32.inc
includelib kernel32.lib

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

.DATA ; initialized data
ClassName db "SimpleWinClass",0 ; the name of our window class
AppName db "Our First Window",0 ; the name of our window
szButton db 'button',0

szButtonText db '点我',0
StringShow db '被点击了',0
.DATA? ; Uninitialized data
hInstance HINSTANCE ? ; Instance handle of our program
CommandLine LPSTR ?
.CODE ; Here begins our code
start:
invoke GetModuleHandle, NULL ; get the instance handle of our program.
; Under Win32, hmodule==hinstance mov hInstance,eax
mov hInstance,eax
invoke GetCommandLine ; get the command line. You don't have to call this function IF
; your program doesn't process the command line.
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT ; call the main function
invoke ExitProcess, eax ; quit our program. The exit code is returned in eax from WinMain.

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX ; create local variables on stack
LOCAL msg:MSG
LOCAL hwnd:HWND

mov wc.cbSize,SIZEOF WNDCLASSEX ; fill values in members of wc
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc ; register our window class
invoke CreateWindowEx,NULL,\
ADDR ClassName,\
ADDR AppName,\
WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
NULL,\
NULL,\
hInst,\
NULL
mov hwnd,eax
invoke CreateWindowEx,NULL,\

offset szButton,offset szButtonText,\

WS_CHILD or WS_VISIBLE,\

500,500,100,40,\

hwnd,1,hInst,NULL



invoke ShowWindow, hwnd,CmdShow ; display our window on desktop
invoke UpdateWindow, hwnd ; refresh the client area

.WHILE TRUE ; Enter message loop
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW
mov eax,msg.wParam ; return exit code in eax
ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.IF uMsg==WM_DESTROY ; if the user closes our window
invoke PostQuitMessage,NULL ; quit our application

.ELSEIF uMsg==WM_COMMAND

invoke MessageBox,hWnd,offset StringShow,0,0
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam ; Default message processing
ret
.ENDIF
xor eax,eax
ret
WndProc endp

end start