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
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
| .model tiny
.data
tabl db 90h,'imul ',0f7h,0ebh,90h
db 'idiv ',0f7h,0fbh,90h
db 'div ',0F7h,0F3h,90h,90h
db 'mul ',0F7h,0E3h,90h,90h
db 'add ',01,0D8h,90h,90h
db 'and ',21h,0D8h,90h,90h
db 'cmp ',39h,0D8h,90h,90h
db 'dec ',48h,90h,90h,90h
db 'inc ',40h,90h,90h,90h
db 'neg ',0F7h,0D8h,90h,90h
db 'or ',09h,0D8h,90h,90h
db 'sub ',29h,0D8h,90h,90h
db 'xor ',31h,0D8h,90h,90h
db 'shl ',0d3h,0e0h,90h,90h
db 'shr ',0d3h,0e8h,90h,90h
db 'ror ',0d3h,0c8h,90h,90h
db 'rol ',0d3h,0c0h,90h,90h
db 'sal ',0d3h,0f0h,90h,90h
db 'sar ',0d3h,0f8h,90h,90h
db 'rcr ',0d3h,0d8h,90h,90h
db 'rcl ',0d3h,0d0h,90h,90h
komand db 'imul bx$'
db 'idiv bx$'
db 'div bx$$'
db 'mul bx$$'
db 'add ax,bx$'
db 'and ax,bx$'
db 'cmp ax,bx$'
db 'dec ax$$'
db 'inc ax$$'
db 'neg ax$$'
db 'or ax,bx$';!!!
db 'sub ax,bx$'
db 'xor ax,bx$'
db 'shl ax,cl$';!!!
db 'shr ax,cl$';!!!
db 'ror ax,cl$'
db 'rol ax,cl$'
db 'sal ax,cl$'
db 'sar ax,cl$'
db 'rcr ax,cl$'
db 'rcl ax,cl$'
op1 db '‚ўҐ¤ЁвҐ 1л© ®ЇҐа**¤:','$';введите 1 операнд
op2 db '‚ўҐ¤ЁвҐ 2®© ®ЇҐа**¤:','$';введите 2 операнд
entm db '‚ўҐ¤ЁвҐ Є®¬**¤г:','$';введите команду
error db 'ЌҐЄ®аҐЄв*л© бЁ¬ў®«!!!'; Не коректный символ
eror db '‚ўҐ¤Ґ**л© ®ЇҐа**¤ Ў®«миҐ,',0Ah,21d dup (08h),' 祬 16 ЎЁв!!!'; Операнд больше 16 бит.
erorm db 'Џа®Ја*¬¬* *Ґ Ї®¤¤Ґа¦Ёў*Ґв ',0ah,19d dup (08h),'нвг Є®¬**¤г!'; Программа не поддерживает эту команду
erors db '2-®© ®ЇҐа**¤ Ў®«миҐ Ў*©в*',0Ah,0ah,18d dup (08h),'б¬.Readme'; 2-ой операнд больше 1 байта см. Readme
flags db 'CF = 0',0ah,08h,08h,08h,08h,08h,08h
db 'ZF = 0',0ah,08h,08h,08h,08h,08h,08h
db 'SF = 0',0ah,08h,08h,08h,08h,08h,08h
db 'OF = 0',0ah,08h,08h,08h,08h,08h,08h
db 'PF = 0',0ah,08h,08h,08h,08h,08h,08h
db 'AF = 0',0ah,08h,08h,08h,08h,08h,08h
db 'IF = 0',0ah,08h,08h,08h,08h,08h,08h
db 'DF = 0'
flag db '1'
oper db 7,0, 7 DUP(0)
mnem db 7,0, 7 DUP(0)
AAX db 'AX=0000'
BBX db 'BX=0000'
CCL db 'CL=00 '
DDX db 'DX=0000'
flagi db 'CF - ',19 dup (' '),'OF - ',19 dup (' '),'IF - ',0ah,53 dup (08h)
db 'ZF - ',19 dup (' '),'PF - ',19 dup (' '),'DF - ',0ah,53 dup (08h)
db 'SF - ',19 dup (' '),'AF - ',19 dup (' ')
Opfl1 db 'д«*Ј ЇҐаҐ*®б*',0ah,13 dup (08h)
db 'д«*Ј *г«п',0ah,9 dup (08h)
db 'д«*Ј §**Є*'
Opfl2 db 'д«*Ј ЇҐаҐЇ®«*Ґ*Ёп',0ah,17 dup (08h)
db 'д«*Ј зҐв*®бвЁ',0ah,13 dup (08h)
db 'д«*Ј Ї®«гЇҐаҐ*®б*'
Opfl3 db 'д«*Ј ЇаҐалў**Ё©',0ah,15 dup (08h)
db 'д«*Ј **Їа*ў«Ґ*Ёп',0ah,16 dup (08h)
Optf db 'TF - д«*Ј «®ўгиЄЁ'
spravka db '‘Їа*ўЄ*: Alt+д«*Ј (**ЇаЁ¬Ґа Alt+C)'
nazad db 'Ќ*§*¤ Alt+R'
CF db ' CF- д«*Ј ЇҐаҐ*®б*. “бв***ў«Ёў*Ґвбп ў 1, Ґб«Ё १г«мв*⠯।л¤г饩 ®ЇҐа*жЁЁ',0ah,75d dup (08h)
db '*Ґ 㬥бвЁ«бп ў ЇаЁҐ¬*ЁЄҐ Ё Їа®Ё§®иҐ« ЇҐаҐ*®б Ё§ бв*а襣® ЎЁв* Ё«Ё вॡгҐвбп',0ah,75d dup (08h)
db '§*Ґ¬ (ЇаЁ ўлзЁв**ЁЁ), Ё**зҐ гбв***ў«Ёў*Ґвбп ў 0.'
ZF db 'ZF - д«*Ј *г«п. “бв***ў«Ёў*Ґвбп ў 1, Ґб«Ё १г«мв*⠯।л¤г饩 Є®¬**¤л *®«м'
SF db 'SFя- д«*Ј §**Є*. ќв®в д«*Ј ўбҐЈ¤* а*ўҐ* бв*а襬㠡Ёвг १г«мв*в*.'
OF db 'OFя- д«*Ј ЇҐаҐЇ®«*Ґ*Ёп. ќв®в д«*Ј гбв***ў«Ёў*Ґвбп ў 1, Ґб«Ё १г«мв*⠯।л',0ah,75d dup (08h)
db '¤г饩 *аЁд¬ҐвЁзҐбЄ®© ®ЇҐа*жЁЁ **¤ зЁб«*¬Ё б® §**Є®¬ ўл室Ёв §* ¤®ЇгбвЁ¬лҐ',0ah,73d dup (08h)
db '¤«п *Ёе ЇаҐ¤Ґ«л. '
PF db 'PFя- д«*Ј зҐв*®бвЁ. “бв***ў«Ёў*Ґвбп ў 1, Ґб«Ё ¬«*¤иЁ© Ў*©в १г«мв*в* ЇаҐ¤л',0ah,75d dup (08h)
db '¤г饩 Є®¬**¤л ᮤҐа¦Ёв зҐв*®Ґ зЁб«® ЎЁв.'
AF db 'AFя- д«*Ј Ї®«гЇҐаҐ*®б* Ё«Ё ўбЇ®¬®Ј*⥫м*®Ј® ЇҐаҐ*®б*. “бв***ў«Ёў*Ґвбп ў 1, ',0ah,75d dup (08h)
db 'Ґб«Ё ў १г«мв*⥠ЇаҐ¤л¤г饩 ®ЇҐа*жЁЁ Їа®Ё§®иҐ« ЇҐаҐ*®б (Ё«Ё §*Ґ¬) Ё§ ваҐвм',0ah,75d dup (08h)
db 'ҐЈ® ЎЁв* ў зҐвўҐавл©'
IFl db 'IFя- д«*Ј ЇаҐалў**Ё©. “бв**®ўЄ* нв®Ј® д«*Ј* ў 1 ЇаЁў®¤Ёв Є ⮬г, зв® Їа®жҐ',0ah,74d dup (08h)
db 'бб®а ЇҐаҐбв*Ґв ®Ўа*Ў*влў*вм ЇаҐалў**Ёп ®в ў*Ґи*Ёе гбва®©бвў.'
DFl db 'DFя- д«*Ј **Їа*ў«Ґ*Ёп. ќв®в д«*Ј Є®*ва®««ЁагҐв Ї®ўҐ¤Ґ*ЁҐ Є®¬**¤ ®Ўа*Ў®вЄЁ ',0ah,74d dup (08h)
db 'бва®Є, Є®Ј¤* ®* гбв**®ў«Ґ* ў 1, бва®ЄЁ ®Ўа*Ў*влў*овбп ў бв®а®*г 㬥*миҐ*Ёп',0ah,75d dup (08h)
db ' *¤аҐб®ў, * Є®Ј¤* DFя= 0я **®Ў®а®в.'
TF db 'TFя- д«*Ј «®ўгиЄЁ. ќв®в д«*Ј Ўл« ЇаҐ¤гᬮваҐ* ¤«п а*Ў®вл ®в«*¤зЁЄ®ў, *Ґ ',0ah,73d dup (08h)
db 'ЁбЇ®«м§гойЁе §*йЁйҐ**л© аҐ¦Ё¬. “бв**®ўЄ* ҐЈ® ў 1 ЇаЁў®¤Ёв Є ⮬г, зв® Ї®б«Ґ ',0ah,76d dup (08h)
db 'ўлЇ®«*Ґ*Ёп Є*¦¤®© Є®¬**¤л Їа®Ја*¬¬л гЇа*ў«Ґ*ЁҐ ўаҐ¬Ґ**® ЇҐаҐ¤*Ґвбп ®в«*¤зЁ',0ah,74d dup (08h)
db 'Єг (ўл§лў*Ґвбп ЇаҐалў**ЁҐ 1я(б¬. ®ЇЁб**ЁҐ Є®¬**¤л INT).'
Press db 'Press ESC to exit'
X1 db 0C9h,78d dup (0CDh),0BBh
X2 db 0bah
X3 db 0C8h,78d dup (0CDh),0BCh
X4 db 0C9h,17d dup (0CDh),0BBh
X5 db 0C9h,59d dup (0CDh),0BBh
X6 db 0C8h,59d dup (0CDh),0BCh
X7 db 0C8h,17d dup (0CDh),0BCh
X8 db 17d dup (0CDh)
qer db 0C9h,27 dup (0CDh),0BBh,3 dup (0Ah,08h,0BAh)
qer1 db 3 dup (0BAh,0Ah,08h),0C8h,27 dup (0CDh),0BCh
oldint9 dd ? ; здесь будет храниться аддрес старого обработчика
exmsg db '„«п Ї®ўв®а* **¦¬ЁвҐ "R", ¤«п ўл室* "ESC"'
exmsg1 db '‚л зв®-в® **¦*«Ё?'
exmsg2 db 'ЃгЄў* "R" **室Ёвбп ¬Ґ¦¤г "E" Ё "T"'
exmsg3 db '’*¬ Ј¤Ґ агббЄ*п "Љ"'
exmsg4 db '€бвЁ** Ј¤Ґ-в® а冷¬'
exmsg5 db '„* ЇаЁЎг¤Ґв б в®Ў®© бЁ«*!'
exmsg6 db 'ЃҐиҐ«м¬Ґ 襫쬥йм?'
exmsg7 db 'ЏаЁЄ®«м*® ** Є«*ўЁиЁ ¦*вм?'
exmsg8 db 'ЌҐ ўлЄагзЁў*© ¬*Ґ п©ж*'
exmsg9 db '„®бўЁ¤**Ёп!'
.code
org 100h
spr macro
mov ah,06h
mov al,0
mov ch,17d
mov cl,1
mov dh,22d
mov dl,78d
mov bh,10h
int 10h
endm
naz macro
mov ax,1300h
lea bp,nazad
mov cx,11
mov dh,22d
mov dl,32d
mov bx,001bh
int 10h
endm
main:
init: push es
push ds
mov ax,3509h ; принимаем аддрес обработчика int 9
int 21h
mov word ptr [oldint9+2],es ; сохраняем аддрес
mov word ptr [oldint9],bx
mov ax,2509h
mov dx,offset int9
int 21h ; устанавливаем свой обработчик
pop ds
pop es
jmp start
int9: push ax
push es
xor ax,ax
mov es,ax
mov al,es:0417h ; берем байт статуса клавиатуры
test al,08h ; проверяем не нажат ли Alt
jnz Zal
in al,60h
cmp al,01h ;сравниваем со скан кодом ESC
je yes
jmp no
yes: mov ax,20h ; разблокируем клавиатуру
out 20h,al
mov ax,4c00h
int 21h
jmp dword ptr cs:[oldint9]
Zal: in al,60h ; принимаем скан-код с клавиатуры
cmp al,2Eh ; сравниваем со скан кодом C
jne Zkl
call Cflag ;
jmp Ras
Zkl: cmp al,2Ch ; сравниваем со скан кодом Z
jne Skl
call Zflag
jmp Ras
Skl: cmp al,1Fh ;сравниваем со скан кодом S
jne Okl
call Sflag
jmp Ras
Okl: cmp al,18h ;сравниваем со скан кодом O
jne Pkl
call Oflag
jmp Ras
Pkl: cmp al,19h ;сравниваем со скан кодом P
jne Akl
call Pflag
jmp Ras
Akl: cmp al,1Eh ;сравниваем со скан кодом A
jne Ikl
call Aflag
jmp Ras
Ikl: cmp al,17h ;сравниваем со скан кодом I
jne Dkl
call Iflag
jmp Ras
Dkl: cmp al,20h ;сравниваем со скан кодом D
jne Rkl
call Dflag
jmp Ras
Rkl: cmp al,13h
jne Tkl
call fl
jmp Ras
Tkl: cmp al,14h
jne Ras
call Tflag
Ras: mov ax,20h ; разблокируем клавиатуру
out 20h,al
pop es ; восстанавливаем регистры
pop ax
jmp dword ptr cs:[oldint9] ; передаем управление старому обработчику
no: pop es ; восстанавливаем регистры
pop ax
jmp dword ptr cs:[oldint9] ; передаем управление старому обработчику
;--------------------------------------------------------------------------------
start: mov ax,0202h
push ax
popf
pushf
mov ax,3
int 10h
mov cx,0
mov dl,79d
mov dh,24d
mov ax,0600h
mov bh,10h
int 10h
mov cx,0
mov dl,60d
mov dh,16d
mov ax,0600h
mov bh,30h
int 10h
mov ah,13h
lea bp,X1
mov cx,80d
mov dh,17d
mov dl,0
xor bh,bh
mov al,0
mov bl,17h
int 10h
;-------------
mov ah,13h
lea bp,X4
mov cx,19d
mov dh,1
mov dl,61d
mov bx,0017h
mov al,0
int 10h
;-----vert polosa-------
mov si,14d
mov dh,2
@1:mov ah,13h
xor bh,bh
mov al,0
mov bl,17h
lea bp,X2
mov cx,1
mov dl,61d
push dx
int 10h
pop dx
dec si
inc dh
cmp si,0
jne @1
;---------------------
mov si,14d
mov dh,2
@4:mov ah,13h
xor bh,bh
mov al,0
mov bl,17h
lea bp,X2
mov cx,1
mov dl,79d
push dx
int 10h
pop dx
dec si
inc dh
cmp si,0
jne @4
;----------------------
mov si,6d
mov dh,18d
@2:mov ah,13h
xor bh,bh
mov al,0
mov bl,17h
lea bp,X2
mov cx,1
mov dl,0
push dx
int 10h
pop dx
dec si
inc dh
cmp si,0
jne @2
;---------------------
mov si,6d
mov dh,18d
@3:mov ah,13h
xor bh,bh
mov al,0
mov bl,17h
lea bp,X2
mov cx,1
mov dl,79d
push dx
int 10h
pop dx
dec si
inc dh
cmp si,0
jne @3
;---------------------
mov ax,1300h
mov bx,0017h
lea bp,X3
mov cx,80d
mov dh,24d
mov dl,0
int 10h
;-------------------------
mov si,15d
mov dh,1
@5:mov ah,13h
xor bh,bh
mov al,0
mov bl,37h
lea bp,X2
mov cx,1
mov dl,0
push dx
int 10h
pop dx
dec si
inc dh
cmp si,0
jne @5
;-------------------------
mov ax,1300h
lea bp,X5
mov cx,61d
mov dx,00h
xor bh,bh
mov bl,37h
int 10h
;------------------------
mov si,14d
mov dh,1
@6:mov ah,13h
xor bh,bh
mov al,0
mov bl,37h
lea bp,X2
mov cx,1
mov dl,60d
push dx
int 10h
pop dx
dec si
inc dh
cmp si,0
jne @6
;-------------------------
mov ax,1300h
lea bp,X6
mov cx,61d
mov dh,15d
mov dl,0
xor bh,bh
mov bl,37h
int 10h
;-------------------------
mov ax,1300h
lea bp,X7
mov cx,19d
mov dh,15d
mov dl,61d
xor bh,bh
mov bl,17h
int 10h
;-------------------------------
mov ax,1300h
lea bp,X8
mov cx,17d
mov dh,9
mov dl,62d
xor bh,bh
mov bl,17h
int 10h
;-------narisoval---------------
;-------------------------------
mov ah,13h
lea bp,flags
mov al,0
mov dh,1
mov dl,64d
mov bh,0
mov bl,1Eh
mov cx,97d
int 10h
mov ax,1300h
mov cx,7
lea bp,AAX
mov dh,10d
mov dl,63d
mov bx,001Eh
int 10h
mov ax,1300h
mov cx,7
lea bp,BBX
mov dh,12d
mov dl,63d
mov bx,001eh
int 10h
;-----------FLAGI-------------------
call fl
;-----------END FLAGI-----------
;-----------1 operand--------------------
A1: mov ah,06h
mov ch,1
mov cl,2
mov dh,1
mov dl,58d
mov al,1
mov bh,30h
int 10h ; Очистка строки
mov ah,2
xor bh,bh
mov dh,1
mov dl,2
int 10h
lea dx, op1
mov ah,9
int 21h
lea dx,oper
mov ah,0ah
int 21h
lea si,oper+2
call operand
cmp cx,1
je A1
push ax
lea si,AAX
call hex2ascii
mov ax,1300h
mov cx,7
lea bp,AAX
mov dh,10d
mov dl,63d
mov bx,001Eh
int 10h
;----------2 operand----
A2:mov ah,06h
mov ch,2
mov cl,2
mov dh,2
mov dl,58d
mov al,1
mov bh,30h
int 10h ; Очистка строки
mov ah,2
xor bh,bh
mov dh,2
mov dl,2
int 10h
lea dx,op2
mov ah,9
int 21h
lea dx,oper
mov ah,0ah
int 21h
lea si,oper+2
call operand
cmp cx,1
je A2
push ax
lea si,BBX
call hex2ascii
mov ax,1300h
mov cx,7
lea bp,BBX
mov dh,12d
mov dl,63d
mov bx,001eh
int 10h
;---------mnemonika---------
B0: mov ah,06h
mov ch,3
mov cl,2
mov dh,3
mov dl,58d
mov al,1
mov bh,30h
int 10h ; Очистка строки
mov ah,2
xor bh,bh
mov dh,3
mov dl,2
int 10h
lea dx,entm
mov ah,9
int 21h
lea dx,mnem
mov ah,0ah
int 21h
lea si,mnem+1 ; адресс введенного операнда
lea di,tabl
push di
B1: inc si
inc di
cmp di,offset [tabl+169d]
ja B3
mov al,byte ptr [si]
cmp al,0Dh
je B2
cmp al,[di]
je B1
lea si,mnem+1
pop di
add di,8
push di
jmp B1
B2:pop ax
cmp byte ptr [di],' '
je exitmn
B3:call erorp
mov ax,1300h
lea bp,erorm
mov cx,58d
mov dh,6
mov dl,20d
mov bh,0
mov bl,0cfh
int 10h
mov ah,0
int 16h
mov ah,06
mov ch,5
mov cl,18d
mov dh,9
mov dl,46d
mov al,0
mov bh,30h
int 10h
jmp B0
exitmn: inc di
cmp byte ptr [di],' '
je exitmn
cmp di,offset [tabl+105d]
jbe vseok
pop bx
push bx
cmp bh,0
je vseokcl
call erorp
mov ax,1300h
lea bp,erors
mov cx,54d
mov dh,6
mov dl,20d
mov bh,0
mov bl,0cfh
int 10h
mov ah,0
int 16h
mov ah,06
mov ch,5
mov cl,18d
mov dh,9
mov dl,46d
mov al,0
mov bh,30h
int 10h
pop bx
jmp A2
; DI = адрес начала опкода
vseokcl:lea si,CCl
pop ax
push ax
mov bx,ax
shr al,4
cmp al,9
jbe cif10
add al,7
cif10:add al,'0'
mov byte ptr [si+3],al
mov ax,bx
and al,0Fh
cmp al,9
jbe cif20
add al,7
cif20:add al,'0'
mov byte ptr [si+4],al
mov ax,1300h
mov cx,7
lea bp,CCl
mov dh,12d
mov dl,63d
mov bx,001Eh
int 10h
vseok: mov dx,word ptr [di]
mov word ptr[opcod],dx
; Сдесь можно вствить вывод команды
sub di,5
cmp byte ptr [di],90h
jne V
inc di
V:mov ax,word ptr [di]
mov si,di
add si,2
lea di,komand
XY:mov cx,0ffffh
repne scasw
push ax
mov ax,word ptr [si]
cmp ax,word ptr [di]
je vivod
pop ax
jmp XY
vivod:
pop ax
sub di,2
push di
cm:cmp byte ptr [di],'$'
je mc
inc di
jmp cm
mc:pop si
sub di,si
mov cx,di
mov ax,1300h
mov bp,si
mov dh,14d
mov dl,63d
mov bx,001Eh
int 10h
xor dx,dx
pop bx
pop ax
mov cx,bx
popf
opcod:nop
nop
nop
pushf
push ax
cmp dx,0
je VA
mov ax,dx
lea si,DDX
call hex2ascii
mov ax,1300h
mov cx,7
lea bp,DDX
mov dh,10d
mov dl,71d
mov bx,001Eh
int 10h
VA:pop ax
lea si,AAX
call hex2ascii
mov ax,1300h
mov cx,7
lea bp,AAX
mov dh,10d
mov dl,63d
mov bx,001Eh
int 10h
popf ; сдесь начинается работа с флагами
pushf
jnc Zfl
mov ax,1300h
mov cx,1
lea bp,flag
mov dh,1
mov dl,69d
mov bx,001Fh
int 10h
Zfl:popf
pushf
jnz Sfl
mov ax,1300h
mov cx,1
lea bp,flag
mov dh,2
mov dl,69d
mov bx,001Fh
int 10h
Sfl:popf
pushf
jns Ofl
mov ax,1300h
mov cx,1
lea bp,flag
mov dh,3
mov dl,69d
mov bx,001Fh
int 10h
Ofl:popf
pushf
jno Pfl
mov ax,1300h
mov cx,1
lea bp,flag
mov dh,4
mov dl,69d
mov bx,001Fh
int 10h
Pfl:popf
pushf
jnp Afl
mov ax,1300h
mov cx,1
lea bp,flag
mov dh,5
mov dl,69d
mov bx,001Fh
int 10h
Afl:popf
pushf
lahf
test ah,10h
jz vihod
mov ax,1300h
mov cx,1
lea bp,flag
mov dh,6
mov dl,69d
mov bx,001Fh
int 10h
;--------THE END-------------------
vihod: mov ax,1301h
mov cx,41d
lea bp,exmsg
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,08h
int 21h
cmp al,'r'
jne msg1
jmp start
msg1:vi macro
mov ch,14d
mov cl,3
mov dl,50d
mov dh,14d
mov ax,0600h
mov bh,30h
int 10h
endm
vi
mov ax,1301h
mov cx,17d
lea bp,exmsg1
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,08h
int 21h
cmp al,'r'
jne msg2
jmp start
msg2:vi
mov ax,1301h
mov cx,35d
lea bp,exmsg2
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,08h
int 21h
cmp al,'r'
jne msg3
jmp start
msg3: vi
mov ax,1301h
mov cx,19d
lea bp,exmsg3
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,08h
int 21h
cmp al,'r'
jne msg4
jmp start
msg4:vi
mov ax,1301h
mov cx,19d
lea bp,exmsg4
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,08h
int 21h
cmp al,'r'
jne msg5
jmp start
msg5: vi
mov ax,1301h
mov cx,25d
lea bp,exmsg5
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,08h
int 21h
cmp al,'r'
jne msg6
jmp start
msg6: vi
mov ax,1301h
mov cx,18d
lea bp,exmsg6
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,08h
int 21h
cmp al,'r'
jne msg7
jmp start
msg7: vi
mov ax,1301h
mov cx,26d
lea bp,exmsg7
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,08h
int 21h
cmp al,'r'
jne msg8
jmp start
msg8: vi
mov ax,1301h
mov cx,22
lea bp,exmsg8
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,08h
int 21h
cmp al,'r'
jne msg9
jmp start
msg9:vi
mov ax,1301h
mov cx,11d
lea bp,exmsg9
mov dh,14d
mov dl,3d
mov bx,003Fh
int 10h
mov ah,00h
int 16h
mov ax,4c00h
int 21h
;-----------operand proc---------
operand proc
;вход SI=адрес операнда
;выход AX=operand
xor ax,ax
xor bx,bx
mov cx,10d
@@:mov bl,byte ptr [si]
cmp bl,0dh
je ex
cmp bl,'-'
jne @a
xor di,di
mov di,1
inc si
mov bl,byte ptr [si]
@a:cmp bl,'0'
jb er
cmp bl,'9'
ja er
sub bl,'0'
mul cx
cmp dx,0
jne er1
add ax,bx
jc er1
inc si
jmp @@
ex: cmp di,1
jne re
test ah,80h
jnz er1
neg ax
re: ret
er: call erorp
;------------------
mov ah,13h
lea bp,error
mov cx,21d
mov dh,7
mov dl,22
mov bh,0
mov bl,0cFh
mov al,0
int 10h
mov ah,0
int 16h
mov ah,06
mov ch,5
mov cl,18d
mov dh,9
mov dl,46d
mov al,0
mov bh,30h
int 10h
mov cx,1
ret
er1:call erorp
mov ax,1300h
lea bp,eror
mov cx,61d
mov dh,6
mov dl,20d
mov bh,0
mov bl,0cfh
int 10h
mov ah,0
int 16h
mov ah,06
mov ch,5
mov cl,18d
mov dh,9
mov dl,46d
mov al,0
mov bh,30h
int 10h
mov cx,1
ret
operand endp
erorp proc
mov ah,06
mov ch,5
mov cl,18d
mov dh,9
mov dl,46d
mov al,0
mov bh,0c0h
int 10h
mov ax,1300h
lea bp,qer
mov cx,38d
mov dh,5
mov dl,18d
mov bh,0
mov bl,0CFh
int 10h
mov ax,1300h
lea bp,qer1
mov cx,38d
mov dh,6
mov dl,18d
mov bh,0
mov bl,0CFh
int 10h
ret
erorp endp
hex2ascii proc
mov bx,ax
shr ah,4
cmp ah,9
jbe cif1
add ah,7
cif1:add ah,'0'
mov byte ptr [si+3],ah
mov ax,bx
and ah,0Fh
cmp ah,9
jbe cif2
add ah,7
cif2:add ah,'0'
mov byte ptr [si+4],ah
shr al,4
cmp al,9
jbe cif3
add al,7
cif3:add al,'0'
mov byte ptr [si+5],al
mov ax,bx
and al,0Fh
cmp al,9
jbe cif4
add al,7
cif4:add al,'0'
mov byte ptr [si+6],al
ret
hex2ascii endp
Cflag proc
push ax
push es
mov ax,cs
mov es,ax
spr
mov ax,1300h
mov cx,350d
lea bp,CF
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
naz
pop es
pop ax
ret
Cflag endp
Zflag proc
push ax
push es
mov ax,cs
mov es,ax
spr
mov ax,1300h
lea cx,SF
sub cx,offset ZF
lea bp,ZF
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
naz
pop es
pop ax
ret
Zflag endp
Sflag proc
push ax
push es
mov ax,cs
mov es,ax
spr
mov ax,1300h
lea cx,OF
sub cx,offset SF
lea bp,SF
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
naz
pop es
pop ax
ret
Sflag endp
Oflag proc
push ax
push es
mov ax,cs
mov es,ax
spr
mov ax,1300h
lea cx,PF
sub cx,offset OF
lea bp,OF
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
naz
pop es
pop ax
ret
Oflag endp
Pflag proc
push ax
push es
mov ax,cs
mov es,ax
spr
mov ax,1300h
lea cx,AF
sub cx,offset PF
lea bp,PF
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
naz
pop es
pop ax
ret
Pflag endp
Aflag proc
push ax
push es
mov ax,cs
mov es,ax
spr
mov ax,1300h
lea cx,IFl
sub cx,offset AF
lea bp,AF
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
naz
pop es
pop ax
ret
Aflag endp
Iflag proc
push ax
push es
mov ax,cs
mov es,ax
spr
mov ax,1300h
lea cx,DFl
sub cx,offset IFl
lea bp,IFl
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
naz
pop es
pop ax
ret
Iflag endp
Dflag proc
push ds
push ax
push es
mov ax,cs
mov es,ax
spr
mov ax,1300h
lea cx,TF
sub cx,offset DFl
lea bp,DFl
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
naz
pop es
pop ax
pop ds
ret
Dflag endp
Tflag proc
push ds
push ax
push es
mov ax,cs
mov es,ax
spr
mov ax,1300h
lea cx,Press
sub cx,offset TF
lea bp,TF
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
naz
pop es
pop ax
pop ds
ret
endp
fl proc
push ds
push es
push ax
mov ax,cs
mov es,ax
mov ds,ax
spr
mov ax,1300h
mov cx,262d
lea bp,flagi
mov dh,18d
mov dl,3d
mov bx,001eh
int 10h
mov ax,1300h
mov cx,56d
lea bp,Opfl1
mov dh,18d
mov dl,8d
mov bx,001Fh
int 10h
mov ax,1300h
mov cx,79d
lea bp,Opfl2
mov dh,18d
mov dl,32d
mov bx,001Fh
int 10h
mov ax,1300h
mov cx,64d
lea bp,Opfl3
mov dh,18d
mov dl,56d
mov bx,001Fh
int 10h
mov ax,1300h
mov cx,17d
lea bp,Optf
mov dh,20d
mov dl,51d
mov bx,001Ch
int 10h
mov ax,1300h
mov cx,34d
lea bp,spravka
mov dh,22d
mov dl,22d
mov bx,001bh
int 10h
mov ax,1300h
lea bp,Press
mov dh,24d
mov dl,30d
mov bx,001ch
mov cx,17d
int 10h
pop ax
pop es
pop ds
ret
endp
end main |