-
Notifications
You must be signed in to change notification settings - Fork 1
/
CommMenu.asm
4491 lines (3811 loc) · 123 KB
/
CommMenu.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
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
; Macros
DstOpReg MACRO p1_Reg, p2_Reg
LOCAL p1_DstValReg, p2_DstValReg
CMP p1_CpuEnabled, 1
JZ p1_DstValReg
CMP p2_CpuEnabled, 1
JZ p2_DstValReg
JMP RETURN_DstSrc
p1_DstValReg:
LEA DI, p1_Reg
JMP RETURN_DstSrc
p2_DstValReg:
LEA DI, p2_Reg
JMP RETURN_DstSrc
ENDM
SrcOpReg MACRO p1_Reg, p2_Reg
LOCAL p1_SrcValReg, p2_SrcValReg
CMP p1_CpuEnabled, 1
JZ p1_SrcValReg
CMP p2_CpuEnabled, 1
JZ p2_SrcValReg
JMP RETURN_GetSrcOp
p1_SrcValReg:
mov AX, p1_Reg
JMP RETURN_GetSrcOp
p2_SrcValReg:
MOV AX, p2_Reg
JMP RETURN_GetSrcOp
ENDM
SrcOpReg_8bit MACRO p1_Reg, p2_Reg
LOCAL p1_SrcValReg, p2_SrcValReg
CMP p1_CpuEnabled, 1
JZ p1_SrcValReg
CMP p2_CpuEnabled, 1
JZ p2_SrcValReg
JMP RETURN_GetSrcOp_8Bit
p1_SrcValReg:
mov AL, BYTE PTR p1_Reg
JMP RETURN_GetSrcOp_8Bit
p2_SrcValReg:
mov AL, BYTE PTR p2_Reg
JMP RETURN_GetSrcOp_8Bit
ENDM
DstOpAddReg MACRO p1_Reg, p2_Reg
LOCAL p1_DstValAddReg, p2_DstValAddReg, p1_ValidAddress, p2_ValidAddress
CMP p1_CpuEnabled, 1
JZ p1_DstValAddReg
CMP p2_CpuEnabled, 1
JZ p2_DstValAddReg
JMP RETURN_DstSrc
p1_DstValAddReg:
MOV DX, p1_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p1_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_DstSrc
p1_ValidAddress:
MOV BX, p1_Reg
LEA DI, p1_ValMem[BX]
JMP RETURN_DstSrc
p2_DstValAddReg:
MOV DX, p2_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p2_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_DstSrc
p2_ValidAddress:
MOV BX, p2_Reg
LEA DI, p2_ValMem[BX]
JMP RETURN_DstSrc
ENDM
SrcOpAddReg MACRO p1_Reg, p2_Reg
LOCAL p1_SrcOpAddReg, p2_SrcOpAddReg, p1_ValidAddress, p2_ValidAddress
CMP p1_CpuEnabled, 1
JZ p1_SrcOpAddReg
CMP p2_CpuEnabled, 1
JZ p2_SrcOpAddReg
JMP RETURN_GetSrcOp
p1_SrcOpAddReg:
MOV DX, p1_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p1_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_GetSrcOp
p1_ValidAddress:
MOV SI, p1_Reg
MOV AX, WORD PTR p1_ValMem[SI]
JMP RETURN_GetSrcOp
p2_SrcOpAddReg:
MOV DX, p2_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p2_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_GetSrcOp
p2_ValidAddress:
MOV SI, p2_Reg
MOV AX, WORD PTR p2_ValMem[SI]
JMP RETURN_GetSrcOp
ENDM
SrcOpAddReg_8bit MACRO p1_Reg, p2_Reg
LOCAL p1_SrcOpAddReg, p2_SrcOpAddReg, p1_ValidAddress, p2_ValidAddress
CMP p1_CpuEnabled, 1
JZ p1_SrcOpAddReg
CMP p2_CpuEnabled, 1
JZ p2_SrcOpAddReg
JMP RETURN_GetSrcOp_8Bit
p1_SrcOpAddReg:
MOV DX, p1_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p1_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_GetSrcOp_8Bit
p1_ValidAddress:
MOV SI, p1_Reg
MOV AL, p1_ValMem[SI]
JMP RETURN_GetSrcOp_8Bit
p2_SrcOpAddReg:
MOV DX, p2_Reg
CALL CheckAddress
CMP BL, 1 ; Check Invalid address
JNZ p2_ValidAddress
MOV isInValidCommand, 1
JMP RETURN_GetSrcOp_8Bit
p2_ValidAddress:
MOV SI, p2_Reg
MOV AL, p2_ValMem[SI]
JMP RETURN_GetSrcOp_8Bit
ENDM
ExecPush MACRO Op
mov bh, 0
mov bl,p2_ValStackPointer
mov ax, Op
lea di,p2_ValStack
mov [di][bx], ax
ADD p2_ValStackPointer,2
ENDM
ourExecPush MACRO Op
mov bh, 0
mov bl, p1_ValStackPointer
mov ax, Op
lea di, p1_ValStack
mov [di][bx], ax
ADD p1_ValStackPointer,2
ENDM
ExecPushMem MACRO Op
mov bh, 0
mov bl,p2_ValStackPointer
mov ax, word ptr Op
lea di,p2_ValStack
mov [di][bx], ax
ADD p2_ValStackPointer,2
ENDM
ourExecPushMem MACRO Op
mov bh, 0
mov bl, p1_ValStackPointer
mov ax, word ptr Op
lea di,p2_ValStack
mov [di][bx], ax
ADD p1_ValStackPointer,2
ENDM
ExecPop MACRO Op
mov bh, 0
mov bl,p2_ValStackPointer
lea di,p2_ValStack
mov ax, [di][bx]
mov Op, ax
SUB p2_ValStackPointer,2
ENDM
ourExecPop MACRO Op
mov bh, 0
mov bl, p1_ValStackPointer
lea di, p1_ValStack
mov ax, [di][bx]
mov Op, ax
SUB p1_ValStackPointer,2
ENDM
ExecPopMem MACRO Op
mov bh, 0
mov bl,p2_ValStackPointer
lea di,p2_ValStack
mov ax, [di][bx]
mov word ptr Op, ax
SUB p2_ValStackPointer,2
ENDM
ourExecPopMem MACRO Op
mov bh, 0
mov bl, p1_ValStackPointer
lea di, p1_ValStack
mov ax, [di][bx]
mov word ptr Op, ax
SUB p1_ValStackPointer,2
ENDM
ExecINC MACRO Op
INC Op
ENDM
ExecDEC MACRO Op
DEC Op
ENDM
ExecAndReg MACRO p2_ValReg, CF
CALL GetSrcOp
AND p2_ValReg, AX
MOV CF, 0
CALL ExitPROC
ENDM
ExecAndReg_8Bit MACRO p2_ValReg, CF
CALL GetSrcOp_8Bit
And BYTE PTR p2_ValReg, AL
MOV CF, 0
JMP Exit
ENDM
ExecAndMem MACRO Op, CF
Local AndOp1Mem_Op2_8Bit
CMP selectedOp2Size, 8
JZ AndOp1Mem_Op2_8Bit
CALL GetSrcOp
And WORD PTR Op, AX
MOV CF, 0
JMP Exit
AndOp1Mem_Op2_8Bit:
CALL GetSrcOp_8Bit
And Op, AL
MOV CF, 0
JMP Exit
ENDM
ExecMovMem MACRO Mem
Local MOVOp1Mem_Op2_8Bit
CMP selectedOp2Size, 8
JZ MOVOp1Mem_Op2_8Bit
CALL GetSrcOp
MOV WORD PTR Mem, AX
JMP Exit
MOVOp1Mem_Op2_8Bit:
CALL GetSrcOp_8Bit
MOV Mem, AL
JMP Exit
ENDM
ExecAddMem MACRO Mem
LOCAL AddOp1Mem_Op2_8Bit
CMP selectedOp2Size, 8
JZ AddOp1Mem_Op2_8Bit
CALL GetSrcOp
CLC
ADD WORD PTR Mem, AX
CALL SetCF
JMP Exit
AddOp1Mem_Op2_8Bit:
CALL GetSrcOp_8Bit
CLC
ADD Mem, AL
CALL SetCF
JMP Exit
ENDM
ExecAdcMem MACRO Mem
LOCAL AdcOp1Mem_Op2_8Bit
CMP selectedOp2Size, 8
JZ AdcOp1Mem_Op2_8Bit
CALL GetSrcOp
CLC
CALL GetCF
ADC WORD PTR Mem, AX
CALL SetCF
JMP Exit
AdcOp1Mem_Op2_8Bit:
CALL GetSrcOp_8Bit
CLC
CALL GetCF
ADC Mem, AL
CALL SetCF
JMP Exit
ENDM
ExecAndAddReg MACRO p2_ValReg, Mem, CF
Local AndOp1AddReg_Op2_8Bit
MOV dx,p2_ValReg
CALL CheckAddress
cmp bl, 1 ;p2_Value is greater than 16
JZ InValidCommand
CMP selectedOp2Size, 8
jz AndOp1AddReg_Op2_8Bit
CALL GetSrcOp
MOV SI,p2_ValReg
And WORD PTR Mem[SI], AX
MOV CF, 0
CALL ExitPROC
AndOp1AddReg_Op2_8Bit:
CALL GetSrcOp_8Bit
MOV SI,p2_ValReg
And Mem[SI], AL
MOV CF, 0
CALL ExitPROC
ENDM
ExecMovAddReg MACRO p2_ValReg, Mem
Local MOVOp1AddReg_Op2_8Bit
MOV dx,p2_ValReg
CALL CheckAddress
cmp bl, 1 ;p2_Value is greater than 16
JZ InValidCommand
CMP selectedOp2Size, 8
jz MOVOp1AddReg_Op2_8Bit
CALL GetSrcOp
MOV SI,p2_ValReg
MOV WORD PTR Mem[SI], AX
JMP Exit
MOVOp1AddReg_Op2_8Bit:
CALL GetSrcOp_8Bit
MOV SI,p2_ValReg
MOV Mem[SI], AL
JMP Exit
ENDM
ExecAddAddReg MACRO p2_ValReg, Mem
LOCAL AddOp1AddReg_Op2_8Bit
MOV dx,p2_ValReg
CALL CheckAddress
cmp bl, 1 ;p2_Value is greater than 16
JZ InValidCommand
CMP selectedOp2Size, 8
jz AddOp1AddReg_Op2_8Bit
CALL GetSrcOp
MOV SI,p2_ValReg
CLC
ADD WORD PTR Mem[SI], AX
CALL SetCF
JMP Exit
AddOp1AddReg_Op2_8Bit:
CALL GetSrcOp_8Bit
MOV SI,p2_ValReg
CLC
ADD Mem[SI], AL
CALL SetCF
JMP Exit
ENDM
EexecAdcAddReg MACRO p2_ValReg, Mem
LOCAL AdcOp1Addreg_Op2_8Bit
MOV dx,p2_ValReg
CALL CheckAddress
cmp bl, 1 ;p2_Value is greater than 16
JZ InValidCommand
CMP selectedOp2Size, 8
jz AdcOp1Addreg_Op2_8Bit
CALL GetSrcOp
MOV SI,p2_ValReg
CLC
CALL GetCF
ADC WORD PTR Mem[SI], AX
CALL SetCF
JMP Exit
AdcOp1Addreg_Op2_8Bit:
CALL GetSrcOp_8Bit
MOV SI,p2_ValReg
CLC
CALL GetCF
ADC Mem[SI], AL
CALL SetCF
JMP Exit
ENDM
CheckForbidCharMacro MACRO comm
Local ValidCommand
mov di, comm
Call CheckForbidChar
CMP bl, 1
jnz ValidCommand
MOV isInvalidCommand, 1
ValidCommand:
ENDM
;================================================================================================================
.Model Huge
.386
.Stack 64
;================================================================================================================
.Data
;; ---------------------------------- Menus Strings ----------------------------------- ;;
NOPcom db 'NOP ','$'
CLCcom db 'CLC ','$'
MOVcom db 'MOV ','$'
ADDcom db 'ADD ','$'
ADCcom db 'ADC ','$'
ANDcom db 'AND ','$'
PUSHcom db 'PUSH ','$'
POPcom db 'POP ','$'
INCcom db 'INC ','$'
DECcom db 'DEC ','$'
MULcom db 'MUL ','$'
DIVcom db 'DIV ','$'
IMULcom db 'IMUL ','$'
IDIVcom db 'IDIV ','$'
RORcom db 'ROR ','$'
ROLcom db 'ROL ','$'
RCRcom db 'RCR ','$'
RCLcom db 'RCL ','$'
SHLcom db 'SHL ','$'
SHRcom db 'SHR ','$'
Reg db 'REG ','$'
AddReg db '[REG]', '$'
Memory db 'MEM ','$'
Value db 'VAL ','$'
RegIndex EQU 0
AddRegIndex EQU 1
MemIndex EQU 2
ValIndex EQU 3
RegAX db 'AX ','$' ;0
RegAL db 'AL ','$' ;1
RegAH db 'AH ','$' ;2
RegBX db 'BX ','$' ;3
RegBL db 'BL ','$' ;4
RegBH db 'BH ','$' ;5
RegCX db 'CX ','$' ;6
RegCL db 'CL ','$' ;7
RegCH db 'CH ','$' ;8
RegDX db 'DX ','$' ;9
RegDL db 'DL ','$' ;10
RegDH db 'DH ','$' ;11
RegSX db 'SX ','$' ;12
RegSL db 'SL ','$' ;13
RegSH db 'SH ','$' ;14
RegBP db 'BP ','$' ;15
RegSP db 'SP ','$' ;16
RegSI db 'SI ','$' ;17
RegDI db 'DI ','$' ;18
AddRegAX db '[AX] ','$' ;0
AddRegAL db '[AL] ','$' ;1
AddRegAH db '[AH] ','$' ;2
AddRegBX db '[BX] ','$' ;3
AddRegBL db '[BL] ','$' ;4
AddRegBH db '[BH] ','$' ;5
AddRegCX db '[CX] ','$' ;6
AddRegCL db '[CL] ','$' ;7
AddRegCH db '[CH] ','$' ;8
AddRegDX db '[DX] ','$' ;9
AddRegDL db '[DL] ','$' ;10
AddRegDH db '[DH] ','$' ;11
AddRegSX db '[SX] ','$' ;12
AddRegSL db '[SL] ','$' ;13
AddRegSH db '[SH] ','$' ;14
AddRegBP db '[BP] ','$' ;15
AddRegSP db '[SP] ','$'
AddRegSI db '[SI] ','$'
AddRegDI db '[DI] ','$'
Mem0 db '[0] ','$'
Mem1 db '[1] ','$'
Mem2 db '[2] ','$'
Mem3 db '[3] ','$'
Mem4 db '[4] ','$'
Mem5 db '[5] ','$'
Mem6 db '[6] ','$'
Mem7 db '[7] ','$'
Mem8 db '[8] ','$'
Mem9 db '[9] ','$'
Mem10 db '[A] ','$'
Mem11 db '[B] ','$'
Mem12 db '[C] ','$'
Mem13 db '[D] ','$'
Mem14 db '[E] ','$'
Mem15 db '[F] ','$'
NOPUP db 'NoPo ','$'
PUP1 db 'PUp1 ','$'
PUP2 db 'PUp2 ','$'
PUP3 db 'PUp3 ','$'
PUP4 db 'PUp4 ','$'
PUP5 db 'PUp5 ','$'
DataIndex0 db 'Data Line 0 ','$'
DataIndex1 db 'Data Line 1 ','$'
DataIndex2 db 'Data Line 2 ','$'
DataIndex3 db 'Data Line 3 ','$'
DataIndex4 db 'Data Line 4 ','$'
DataIndex5 db 'Data Line 5 ','$'
DataIndex6 db 'Data Line 6 ','$'
DataIndex7 db 'Data Line 7 ','$'
DataIndex8 db 'Data Line 8 ','$'
DataIndex9 db 'Data Line 9 ','$'
DataIndex10 db 'Data Line 10','$'
DataIndex11 db 'Data Line 11','$'
DataIndex12 db 'Data Line 12','$'
DataIndex13 db 'Data Line 13','$'
DataIndex14 db 'Data Line 14','$'
DataIndex15 db 'Data Line 15','$'
StuckVal0 db 'Stuck Val: 0', '$'
StuckVal1 db 'Stuck Val: 1', '$'
;; -------------------------------------- Player's Data ------------------------------ ;;
p2_ValRegAX dw 'AX'
p2_ValRegBX dw 'BX'
p2_ValRegCX dw 'CX'
p2_ValRegDX dw 'DX'
p2_ValRegBP dw 0
p2_ValRegSP dw 1
p2_ValRegSI dw 'SI'
p2_ValRegDI dw 'DI'
p2_ValMem db 16 dup('M'), '$'
p2_ValStack DW 8 dup('Ss'), '$'
;p2_ValStackPointer db 0
p2_ValCF db 1
;OUR Regisesters
p1_ValRegAX dw 'AX'
p1_ValRegBX dw 'BX'
p1_ValRegCX dw 'CX'
p1_ValRegDX dw 'DX'
p1_ValRegBP dw 0
p1_ValRegSP dw 1
p1_ValRegSI dw 'SI'
p1_ValRegDI dw 'DI'
p1_ValCF db 0
p1_ValMem db 16 dup('M'), '$'
p1_ValStack DW 8 dup('S'), '$'
;p1_ValStackPointer db 0
; Operandp2_Value Needed Variables
ClearSpace db ' ', '$'
num db 30,?,30 DUP(?)
StrSize db ?
num2 db 30,?,30 DUP(?)
StrSize2 db ?
a EQU 1000H
B EQU 100H
C EQU 10H
; Variables Memory Locations and data
CommStringSize EQU 6
SubPwrUpSize EQU 13
; Test Messages
mesCom db 10,'You have selected Command #', '$'
mesOp1Type db 10,'You have selected Operand 1 of Type #', '$'
mesReg db 10, 'You have selected Reg #', '$'
;mesMem db 10, 'You have selected Mem #', '$'
mesVal db 10, 'You Enteredp2_Value: ', '$'
mesMem db 10, 'Values in memory as Ascii: ', 10, '$'
mesStack db 10, 'Values in stack as Ascii: ', 10, '$'
mesStackPointer db 10, 'Value of stack pointer: ', 10 , '$'
mesRegAX db 10, 'Value of AX: ', '$'
mesRegBX db 10, 'Value of BX: ', '$'
mesRegCX db 10, 'Value of CX: ', '$'
mesRegDX db 10, 'Value of DX: ', '$'
mesRegSI db 10, 'Value of SI: ', '$'
mesRegDI db 10, 'Value of DI: ', '$'
mesRegBP db 10, 'Value of BP: ', '$'
mesRegSP db 10, 'Value of SP: ', '$'
mesRegCF db 10, 'Value of CF: ', '$'
error db 13,10,"Error Input",'$'
tstmsg db 13, 10, "Test ", '$'
ChangeForbidMsg db 10, 'Press the new forbidden char: ', '$'
LineStuckIndexMsg db 10, 'Enter the number of the stuck data line (0-15): ', '$'
LineStuckValMsg db 10, 'Enter the value to be stuck at (0/1): ', '$'
NoAvailablePointsMsg db 10, 'No Available points.', '$'
selectedComm db -1, '$'
selectedOp1Type db -1, '$'
selectedOp1Reg db -1, '$'
selectedOp1AddReg db -1, '$'
selectedOp1Mem db -1, '$'
selectedOp1Size db 8, '$'
selectedPUPType db -1, '$'
Op1Val dw 0
Op1Valid db 1 ; 0 if Invalid
selectedOp2Type db -1, '$'
selectedOp2Reg db -1, '$'
selectedOp2AddReg db -1, '$'
selectedOp2Mem db -1, '$'
selectedOp2Size db 8, '$'
Op2Val dw 0
Op2Valid db 1 ; 0 if Invalid
; Game Variables
Player1Points dw 0
ForbidChar db 'l'
isInvalidCommand db 0 ; 1 if Invalid
p1_CpuEnabled db 0 ; 1 if command will run on it
p2_CpuEnabled db 1 ; ..
; Power Up Variables
isPwrUp3Used db 0 ;Chance to use forbiden power up
isPwrUp5Used db 0
ourPwrUpDataLineIndex db 1
ourPwrUpStuckVal db 1
ourPwrUpStuckEnabled db 0
opponentPwrUpDataLineIndex db 0
opponentPwrUpStuckVal db 0
opponentPwrUpStuckEnabled db 0
; Keys Scan Codes
UpArrowScanCode EQU 72
DownArrowScanCode EQU 80
EnterScanCode EQU 28
; Cursor Locations
MenmonicCursorLoc EQU 0000H
Op1CursorLoc EQU 0006H
CommaCursorLoc EQU 000BH
Op2CursorLoc EQU 000CH
PUPCursorLoc EQU 0011H
ForbidPUPCursor EQU 0016H
;================================================================================================================
.Code
CommMenu proc far
mov ax, @Data
mov ds, ax
mov es, ax
CALL ClearScreenTxtMode
Start:
CALL PowrUpMenu
CALL ExecPwrUp
CALL MnemonicMenu
; SelectedMenmonic index is saved, Call operands according to each operation (Menmonic)
CMP selectedComm, 0
JZ NOP_Comm
CMP selectedComm, 1
JZ CLC_Comm
CMP selectedComm, 2
JZ MOV_Comm
CMP selectedComm, 3
JZ ADD_Comm
CMP selectedComm, 4
JZ ADC_Comm
CMP selectedComm, 5
JZ AND_Comm
CMP selectedComm, 6
JZ PUSH_Comm
CMP selectedComm, 7
JZ POP_Comm
CMP selectedComm, 8
JZ INC_Comm
CMP selectedComm, 9
JZ DEC_Comm
CMP selectedComm, 10
JZ MUL_Comm
CMP selectedComm, 11
JZ DIV_Comm
CMP selectedComm, 12
JZ IMul_Comm
CMP selectedComm, 13
JZ IDiv_Comm
CMP selectedComm, 14
JZ ROR_Comm
cmp selectedComm, 15
JZ ROL_Comm
cmp selectedComm, 16
JZ RCR_Comm
cmp selectedComm, 17
JZ RCL_Comm
cmp selectedComm, 18
JZ SHL_Comm
cmp selectedComm, 19
JZ SHR_Comm
;JMP TODO_Comm
; Continue comparing for all operations
; Commands (operations) Labels
NOP_Comm:
CALL CheckForbidCharProc
JMP Exit
CLC_Comm:
CALL CheckForbidCharProc
CMP p1_CpuEnabled, 1
JZ CLC_p1
JMP CLC_p2
CLC_p1:
CLC
CALL SetCf
CLC_p2:
MOV p1_CpuEnabled, 0
CMP p2_CpuEnabled, 1
JNZ Exit
CLC
CALL SetCF
JMP Exit
AND_Comm:
CALL AND_Comm_PROC
JMP Exit
MOV_Comm:
CALL MOV_Comm_PROC
JMP Exit
ADD_Comm:
CALL ADD_Comm_PROC
JMP Exit
ADC_Comm:
CALL ADC_Comm_PROC
JMP Exit
PUSH_Comm:
CALL PUSH_Comm_PROC
JMP Exit
POP_Comm:
CALL POP_Comm_PROC
JMP Exit
INC_Comm:
CALL INC_Comm_PROC
JMP Exit
DEC_Comm:
CALL DEC_Comm_PROC
JMP Exit
MUL_Comm:
CALL MUL_Comm_PROC
jmp Exit
DIV_Comm:
CALL DIV_Comm_PROC
jmp Exit
IMul_Comm:
CALL IMUL_Comm_PROC
jmp Exit
IDiv_Comm:
CALL IDIV_Comm_PROC
jmp Exit
ROR_Comm:
CALL ROR_Comm_PROC
JMP Exit
ROL_Comm:
CALL ROL_Comm_PROC
JMP Exit
RCR_Comm:
CALL RCR_Comm_PROC
JMP Exit
RCL_Comm:
CALL RCL_Comm_PROC
JMP Exit
SHL_Comm:
CALL SHL_Comm_PROC
JMP Exit
SHR_Comm:
CALL SHR_Comm_PROC
JMP Exit
Exit:
CMP isInvalidCommand, 0
JZ ValidCommand
mov dx, offset error
CALL DisplayString
ValidCommand:
; Test Messages
lea dx, mesMem
CAll DisplayString
lea dx,p2_ValMem
CALL DisplayString
lea dx, mesStack
CAll DisplayString
lea dx,p2_ValStack
Call DisplayString
lea dx, mesVal
CALL DisplayString
mov dx, Op1Val
Call DisplayChar
LEA DX, mesRegAX
CALL DisplayString
mov dl,Byte ptr p2_ValRegAX
CALL DisplayChar
mov dl, byte ptr p2_ValRegAX+1
CALL DisplayChar
LEA DX, mesRegBX
CALL DisplayString
mov dl,Byte ptr p2_ValRegBX
CALL DisplayChar
mov dl, byte ptr p2_ValRegBX+1
CALL DisplayChar
LEA DX, mesRegCX
CALL DisplayString
mov dl,Byte ptr p2_ValRegCX
CALL DisplayChar
mov dl, byte ptr p2_ValRegCX+1
CALL DisplayChar
LEA DX, mesRegDX
CALL DisplayString
mov dl,Byte ptr p2_ValRegDX
CALL DisplayChar
mov dl, byte ptr p2_ValRegDX+1
CALL DisplayChar
LEA DX, mesRegSI
CALL DisplayString
mov dl,Byte ptr p2_ValRegSI
CALL DisplayChar
mov dl, byte ptr p2_ValRegSI+1
CALL DisplayChar
LEA DX, mesRegDI
CALL DisplayString
mov dl,Byte ptr p2_ValRegDI
CALL DisplayChar
mov dl, byte ptr p2_ValRegDI+1
CALL DisplayChar
LEA DX, mesRegBP
CALL DisplayString
mov dl,Byte ptr p2_ValRegBP
CALL DisplayChar
mov dl, byte ptr p2_ValRegBP+1
CALL DisplayChar
LEA DX, mesRegSP
CALL DisplayString
mov dl,Byte ptr p2_ValRegSP
CALL DisplayChar
mov dl, byte ptr p2_ValRegSP+1
CALL DisplayChar
LEA DX, mesRegCF
CALL DisplayString
mov dl, p2_ValCF
add dl, '0'
CALL DisplayChar
CALL ExitPROC
ret
CommMenu ENDP
;================================================================================================================
;; ---------------------------------- Commands Procedures ----------------------------------- ;;
AND_Comm_PROC PROC FAR
CALL Op1Menu
mov DX, CommaCursorLoc
CALL SetCursor
mov dl, ','
CALL DisplayChar
CALL Op2Menu
;call PowrUpMenu ; to choose power up
CALL CheckMemToMem
CALL CheckForbidCharProc
CALL CheckSizeMismatch
CMP isInvalidCommand, 1
JZ Return_AndCom
CMP p1_CpuEnabled, 1
JZ And_p1
JMP And_p2
And_p1:
CALL GetDst
CMP selectedOp1Size, 16
JZ p1_AndDst_16BIT
CMP selectedOp1Size, 8
JZ p1_AndDst_8BIT
JMP And_p2
p1_AndDst_16BIT:
CMP selectedOp2Size, 16
JZ p1_AndSrc_16_16BIT
CMP selectedOp2Size, 8
JZ p1_AndSrc_16_8BIT
MOV isInValidCommand, 1
RET
p1_AndSrc_16_16BIT:
CALL GetSrcOp
CMP isInvalidCommand, 1
JZ Return_AndCom
AND [DI], AX
CALL SetCF
JMP And_p2
p1_AndSrc_16_8BIT:
CALL GetSrcOp_8Bit
CMP isInvalidCommand, 1
JZ Return_AndCom
AND [DI], AL
CALL SetCF
JMP And_p2
p1_AndDst_8BIT:
CALL GetSrcOp_8Bit
CMP isInvalidCommand, 1
JZ Return_AndCom
AND BYTE PTR [DI], AL
CALL SetCF
JMP And_p2
And_p2:
MOV p1_CpuEnabled, 0
CMP p2_CpuEnabled, 1
jnz Return_AndCom
CALL GetDst
CMP selectedOp1Size, 16
JZ p2_AndDst_16BIT
CMP selectedOp1Size, 8
JZ p2_AndDst_8BIT
JMP And_p2
p2_AndDst_16BIT:
CMP selectedOp2Size, 16
JZ p2_AndSrc_16_16BIT
CMP selectedOp2Size, 8
JZ p2_AndSrc_16_8BIT
MOV isInValidCommand, 1
RET
p2_AndSrc_16_16BIT:
CALL GetSrcOp
CMP isInvalidCommand, 1
JZ Return_AndCom
AND [DI], AX
CALL SetCF
JMP Return_AndCom
p2_AndSrc_16_8BIT:
CALL GetSrcOp_8Bit
CMP isInvalidCommand, 1