-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXAMPLE.ASM
729 lines (705 loc) · 8.93 KB
/
EXAMPLE.ASM
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
use32
org 0x0
db 'MENUET01'
dd 0x01
dd _main
dd I_END
dd 0x100000
dd 0x7fff0
dd 0x0,0x0
include 'INTRINS.ASM'
_get_even:
PUSH EBP
MOV EBP,ESP
mov eax,10
int 0x40
POP EBP
RET
_get_key:
PUSH EBP
MOV EBP,ESP
mov eax,2
int 0x40
and eax,0x0000ff00
shr eax,8
POP EBP
RET
_get_butt:
PUSH EBP
MOV EBP,ESP
mov eax,17
int 0x40
shr eax,8
POP EBP
RET
_begin_dr:
PUSH EBP
MOV EBP,ESP
mov ebx,1
mov eax,12
int 0x40
POP EBP
RET
_end_draw:
PUSH EBP
MOV EBP,ESP
mov ebx,2
mov eax,12
int 0x40
POP EBP
RET
_window:
PUSH EBP
MOV EBP,ESP
; color of frames
mov edi,[esp+8]
; color of grab bar bit 8->color gl
mov esi,[esp+12]
; color of work area bit 8-> color gl
mov edx,[esp+16]
;left / width
mov ebx,[esp+32]
shl ebx,16
mov bx,[esp+24]
;top / height
mov ecx,[esp+28]
shl ecx,16
mov cx,[esp+20]
;execute
mov eax,0
int 0x40
POP EBP
RET
_label:
PUSH EBP
MOV EBP,ESP
mov ebx,[esp+20]
shl ebx,16
mov bx,[esp+16]
mov ecx,[esp+12]
mov edx,[esp+8]
;find text lenght
xor esi,esi
.next:
cmp byte [edx+esi],0
jz .good
inc esi
jmp .next
.good:
mov eax,4
int 0x40
POP EBP
RET
_buttonT:
PUSH EBP
MOV EBP,ESP
LEA EAX,[EBP+36]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+32]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+28]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+24]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+20]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+16]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
MOV CL,6
CALL _button
ADD ESP,24
LEA EAX,[EBP+36]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,4
ADD EAX,EBX
PUSH EAX
LEA EAX,[EBP+32]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,2
ADD EAX,EBX
PUSH EAX
LEA EAX,[EBP+8]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+12]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
MOV CL,4
CALL _label
ADD ESP,16
POP EBP
RET
_button:
PUSH EBP
MOV EBP,ESP
;left / width
mov ebx,[esp+28]
shl ebx,16
mov bx,[esp+20]
;top / height
mov ecx,[esp+24]
shl ecx,16
mov cx,[esp+16]
mov edx,[esp+8]
mov esi,[esp+12]
mov eax,8
int 0x40
POP EBP
RET
_cbt DB 32,0
_chkbox:
PUSH EBP
MOV EBP,ESP
LEA EAX,[EBP+8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,24
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,EAX
MOV EAX,1
CALL __eq
OR EAX,EAX
JNE _12
JMP _11
_12:
MOV EAX,_cbt
MOV EBX,EAX
MOV EAX,88
MOV [EBX],AL
JMP _13
_11:
MOV EAX,_cbt
MOV EBX,EAX
MOV EAX,32
MOV [EBX],AL
_13:
LEA EAX,[EBP+8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,8
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,12
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
MOV EAX,12
PUSH EAX
MOV EAX,10
PUSH EAX
LEA EAX,[EBP+8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,16
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,4
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
MOV EAX,_cbt
PUSH EAX
LEA EAX,[EBP+8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,20
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
MOV CL,8
CALL _buttonT
ADD ESP,32
POP EBP
RET
_eventCon:
PUSH EBP
MOV EBP,ESP
ADD ESP,-8
LEA EAX,[EBP-4]
MOV EBX,EAX
XOR EAX,EAX
MOV [EBX],EAX
_17:
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+12]
MOV EBX,EAX
MOV EAX, [EBX]
POP EBX
CALL __lt
OR EAX,EAX
JNE _19
JMP _16
_19:
JMP _18
_15:
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
INC EAX
MOV [EBX],EAX
DEC EAX
JMP _17
_18:
LEA EAX,[EBP-8]
PUSH EAX
LEA EAX,[EBP+16]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
POP EBX
SHL EAX,1
SHL EAX,1
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
POP EBX
MOV [EBX],EAX
LEA EAX,[EBP-8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,EAX
MOV EAX, [EBX]
JMP _22
_23:
LEA EAX,[EBP-8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,4
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+8]
MOV EBX,EAX
MOV EAX, [EBX]
POP EBX
CALL __eq
OR EAX,EAX
JNE _25
JMP _24
_25:
LEA EAX,[EBP-8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,24
ADD EAX,EBX
PUSH EAX
LEA EAX,[EBP-8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,24
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,1
XCHG EAX,EBX
SUB EAX,EBX
POP EBX
MOV [EBX],EAX
LEA EAX,[EBP+16]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+12]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
MOV CL,2
CALL _renderCo
ADD ESP,8
MOV EAX,1
MOV ESP,EBP
POP EBP
RET
_24:
JMP _21
JMP _21
_22:
CALL __switch
DD _23
DD 1
DD 0
_21:
JMP _15
_16:
XOR EAX,EAX
MOV ESP,EBP
POP EBP
RET
_renderCo:
PUSH EBP
MOV EBP,ESP
ADD ESP,-8
LEA EAX,[EBP-4]
MOV EBX,EAX
XOR EAX,EAX
MOV [EBX],EAX
_29:
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP+8]
MOV EBX,EAX
MOV EAX, [EBX]
POP EBX
CALL __lt
OR EAX,EAX
JNE _31
JMP _28
_31:
JMP _30
_27:
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
INC EAX
MOV [EBX],EAX
DEC EAX
JMP _29
_30:
LEA EAX,[EBP-8]
PUSH EAX
LEA EAX,[EBP+12]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
POP EBX
SHL EAX,1
SHL EAX,1
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
POP EBX
MOV [EBX],EAX
LEA EAX,[EBP-8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,EAX
MOV EAX, [EBX]
JMP _34
_35:
LEA EAX,[EBP-8]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
MOV CL,1
CALL _chkbox
ADD ESP,4
JMP _33
JMP _33
_34:
CALL __switch
DD _35
DD 1
DD 0
_33:
JMP _27
_28:
MOV ESP,EBP
POP EBP
RET
_s_quit:
PUSH EBP
MOV EBP,ESP
mov eax,-1
int 0x40
POP EBP
RET
_control: TIMES 2 DD 0
_cont1 DD 1,4,10,40,1118481,16777215,0
_cont2 DD 1,5,25,55,12303291,0,0
_main:
PUSH EBP
MOV EBP,ESP
ADD ESP,-8
MOV EAX,_control
PUSH EAX
MOV EAX,_cont1
POP EBX
MOV [EBX],EAX
MOV EAX,_control
MOV EBX,4
ADD EAX,EBX
PUSH EAX
MOV EAX,_cont2
POP EBX
MOV [EBX],EAX
XOR CL,CL
CALL _draw_win
_38:
LEA EAX,[EBP-4]
PUSH EAX
XOR CL,CL
CALL _get_even
POP EBX
MOV [EBX],EAX
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
JMP _42
_43:
XOR CL,CL
CALL _draw_win
JMP _41
_44:
XOR CL,CL
CALL _get_butt
JMP _41
_45:
LEA EAX,[EBP-8]
PUSH EAX
XOR CL,CL
CALL _get_butt
POP EBX
MOV [EBX],EAX
MOV EAX,_control
PUSH EAX
MOV EAX,2
PUSH EAX
LEA EAX,[EBP-8]
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
MOV CL,3
CALL _eventCon
ADD ESP,12
LEA EAX,[EBP-8]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,EAX
MOV EAX,1
CALL __eq
OR EAX,EAX
JNE _47
JMP _46
_47:
XOR CL,CL
CALL _s_quit
_46:
JMP _41
JMP _41
_42:
CALL __switch
DD _43
DD 1
DD _44
DD 2
DD _45
DD 3
DD 0
_41:
JMP _38
_39:
MOV ESP,EBP
POP EBP
RET
_text1 DB 84,72,73,83,32,73,83,32,65,78
DB 32,69,88,65,77,80,76,69,32,79
DB 70,32,67,0
TIMES 26 DB 0
_text2 DB 80,82,79,71,82,65,77,32,73,78
DB 32,75,79,76,73,66,82,73,79,83
DB 0
TIMES 29 DB 0
_text3 DB 0
TIMES 49 DB 0
_text4 DB 83,85,67,67,69,83,83,0
TIMES 42 DB 0
_p_text: TIMES 4 DD 0
_draw_win:
PUSH EBP
MOV EBP,ESP
ADD ESP,-8
LEA EAX,[EBP-8]
MOV EBX,EAX
MOV EAX,25
MOV [EBX],EAX
MOV EAX,_p_text
PUSH EAX
MOV EAX,_text1
POP EBX
MOV [EBX],EAX
MOV EAX,_p_text
MOV EBX,4
ADD EAX,EBX
PUSH EAX
MOV EAX,_text2
POP EBX
MOV [EBX],EAX
MOV EAX,_p_text
MOV EBX,8
ADD EAX,EBX
PUSH EAX
MOV EAX,_text3
POP EBX
MOV [EBX],EAX
MOV EAX,_p_text
MOV EBX,12
ADD EAX,EBX
PUSH EAX
MOV EAX,_text4
POP EBX
MOV [EBX],EAX
XOR CL,CL
CALL _begin_dr
MOV EAX,100
PUSH EAX
MOV EAX,100
PUSH EAX
MOV EAX,320
PUSH EAX
MOV EAX,150
PUSH EAX
MOV EAX,67108863
PUSH EAX
MOV EAX,-2142207792
PUSH EAX
MOV EAX,5275856
PUSH EAX
MOV CL,7
CALL _window
ADD ESP,28
MOV EAX,8
PUSH EAX
MOV EAX,8
PUSH EAX
MOV EAX,282980095
PUSH EAX
MOV EAX,_48+0
PUSH EAX
MOV CL,4
CALL _label
ADD ESP,16
MOV EAX,50
PUSH EAX
MOV EAX,35
PUSH EAX
MOV EAX,60
PUSH EAX
MOV EAX,12
PUSH EAX
MOV EAX,1118481
PUSH EAX
MOV EAX,1
PUSH EAX
MOV EAX,_48+20
PUSH EAX
MOV EAX,16777215
PUSH EAX
MOV CL,8
CALL _buttonT
ADD ESP,32
MOV EAX,_control
PUSH EAX
MOV EAX,2
PUSH EAX
MOV CL,2
CALL _renderCo
ADD ESP,8
LEA EAX,[EBP-4]
MOV EBX,EAX
XOR EAX,EAX
MOV [EBX],EAX
_51:
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,EAX
MOV EAX,4
CALL __lt
OR EAX,EAX
JNE _53
JMP _50
_53:
JMP _52
_49:
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
INC EAX
MOV [EBX],EAX
DEC EAX
JMP _51
_52:
MOV EAX,20
PUSH EAX
LEA EAX,[EBP-8]
PUSH EAX
MOV EBX,EAX
MOV EAX, [EBX]
MOV EBX,10
ADD EAX,EBX
POP EBX
MOV [EBX],EAX
MOV EBX,40
ADD EAX,EBX
PUSH EAX
XOR EAX,EAX
PUSH EAX
MOV EAX,_p_text
PUSH EAX
LEA EAX,[EBP-4]
MOV EBX,EAX
MOV EAX, [EBX]
POP EBX
SHL EAX,1
SHL EAX,1
ADD EAX,EBX
MOV EBX,EAX
MOV EAX, [EBX]
PUSH EAX
MOV CL,4
CALL _label
ADD ESP,16
JMP _49
_50:
XOR CL,CL
CALL _end_draw
MOV ESP,EBP
POP EBP
RET
_48 DB 69,120,97,109,112,108,101,32,97,112
DB 112,108,105,99,97,116,105,111,110,0
DB 67,108,105,99,107,32,77,101,33,0
I_END: