-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcuba1.asm
More file actions
1229 lines (904 loc) · 29.3 KB
/
cuba1.asm
File metadata and controls
1229 lines (904 loc) · 29.3 KB
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
; Program Description: Individual Assignment
; Author: hanifah hadirah bt abd manan (1180480)
; Creation Date: august 2020
; Revisions: final
; Date: august 2020 Modified by: hanhan
INCLUDE irvine32.inc
.data
num1 BYTE ?
num2 BYTE 0
num3 BYTE ?
wrd1 BYTE " ** Welcome to Assembly Language Program ** ", 0dh, 0ah, 0ah
wrd2 BYTE "1. Chapter 6", 0dh, 0ah
wrd3 BYTE "2. Chapter 7", 0dh, 0ah
wrd4 BYTE "3. Exit ", 0dh, 0ah, 0ah
wrd5 BYTE " Choose the chapter: ", 0
;mychapter6
wrd6 BYTE " ** CHAPTER 6 : Conditional Processing ** " ,0dh, 0ah, 0ah
wrd7 BYTE "1. Boolean and Comparison Instructions ", 0dh, 0ah
wrd8 BYTE "2. Conditional Jumps ", 0dh, 0ah
wrd9 BYTE "3. Conditional Loop Instructions" ,0dh, 0ah
wrd10 BYTE "4. Conditional Structures", 0dh, 0ah
wrd11 BYTE "5. Conditional Flow Directives", 0dh, 0ah
wrd12 BYTE "6. Main Menu", 0dh, 0ah, 0ah
wrd13 BYTE " Enter number from menu: ", 0
;mychapter7
wrd14 BYTE 13, 0ah, " ** CHAPTER 7 : Integer Arithmetic ** ",0dh, 0ah, 0ah
wrd15 BYTE "1. Shift and Rotate Instruction", 0dh, 0ah
wrd16 BYTE "2. Shift and Rotate Applications", 0dh, 0ah
wrd17 BYTE "3. Multiplication and Division Instruction", 0dh, 0ah
wrd18 BYTE "4. Main Menu", 0dh, 0ah, 0ah
wrd19 BYTE " Enter a number from menu: ", 0
wrd20 BYTE " Exit system ", 0
;mychapter6.1
wrd21 BYTE " ** 6.1 Boolean and Comparison Instructions **" ,0dh, 0ah, 0ah
wrd23 BYTE "1. AND Instruction ", 0dh, 0ah
wrd24 BYTE "2. OR Instruction" ,0dh, 0ah
wrd25 BYTE "3. XOR Instruction", 0dh, 0ah
wrd26 BYTE "4. NOT Instruction", 0dh, 0ah
wrd27 BYTE "5. TEST Instruction ", 0dh, 0ah
wrd28 BYTE "6. CMP Instruction ", 0dh, 0ah
wrd29 BYTE "7. Main Menu ", 0dh, 0ah,0ah
wrd30 BYTE " Enter number from menu: ", 0
;mychapter6.2
wrd31 BYTE " ** 6.2 Conditional Jumps **" ,0dh, 0ah, 0ah
wrd32 BYTE "1. Specific flag ", 0dh, 0ah
wrd33 BYTE "2. Equality ", 0dh, 0ah
wrd34 BYTE "3. Unsigned comparisons" ,0dh, 0ah
wrd35 BYTE "4. Signed comparisons", 0dh, 0ah
wrd36 BYTE "5. Main Menu", 0dh, 0ah, 0ah
wrd37 BYTE " Enter number from menu: ", 0
;mychapter6.3
wrd38 BYTE " ** 6.3 Conditional Loop Instructions **" ,0dh, 0ah, 0ah
wrd39 BYTE "1. LOOPZ ", 0dh, 0ah
wrd40 BYTE "2. LOOPNZ ", 0dh, 0ah
wrd41 BYTE "3. Main Menu" ,0dh, 0ah, 0ah
wrd42 BYTE " Enter number from menu: ", 0ah, 0
;mychapter6.4
wrd43 BYTE " ** 6.4 Conditional Structures **" ,0dh, 0ah, 0ah
wrd44 BYTE "1. Block-Structured IF Statements ", 0dh, 0ah
wrd45 BYTE "2. Compound Expressions with AND ", 0dh, 0ah
wrd46 BYTE "3. Compound Expressions with OR" ,0dh, 0ah
wrd47 BYTE "4. WHILE Loops" ,0dh, 0ah
wrd48 BYTE "5. Main Menu" ,0dh, 0ah, 0ah
wrd49 BYTE " Enter number from menu: ", 0ah, 0
;mychapter6.5
wrd50 BYTE " ** 6.5 Conditional Flow Directives // Creating IF statements **" ,0dh, 0ah
wrd51 BYTE "1. Runtime Expressions ", 0dh, 0ah
wrd52 BYTE "2. Relational and Logical" ,0dh, 0ah
wrd54 BYTE "3. .REPEAT Directive" ,0dh, 0ah
wrd55 BYTE "4. .WHILE Directive" ,0dh, 0ah
wrd56 BYTE "5. Main Menu" ,0dh, 0ah, 0ah
wrd57 BYTE " Enter number from menu: ", 0
;mychapter7.1
wrd58 BYTE " ** 7.1 Shift and Rotate Instruction **" ,0dh, 0ah, 0ah
wrd59 BYTE "1. SHL Instruction ", 0dh, 0ah
wrd60 BYTE "2. SHR Instruction ", 0dh, 0ah
wrd61 BYTE "3. SAL and SAR Instruction " ,0dh, 0ah
wrd62 BYTE "4. ROL Instruction " ,0dh, 0ah
wrd63 BYTE "5. ROR Instruction " ,0dh, 0ah
wrd64 BYTE "6. RCL and RCR Instruction " ,0dh, 0ah
wr1 BYTE "7. SHLD/SHRD Instruction " ,0dh, 0ah
wrd65 BYTE "8. Main Menu" ,0dh, 0ah, 0ah
wrd66 BYTE " Enter number from menu: ", 0ah, 0
;mychapter7.2
wrd67 BYTE " ** 7.2 Shift and Rotate Applications **" ,0dh, 0ah, 0ah
wrd68 BYTE "1. Binary Mutiplication ", 0dh, 0ah
wrd69 BYTE "2. Isolating a bit string ", 0dh, 0ah
wrd70 BYTE "3. Main Menu" ,0dh, 0ah
wrd80 BYTE " Enter number from menu: ", 0, 0ah
;mychapter7.3
wrd71 BYTE " ** 7.3 Multiplication and Division Instruction **" ,0dh, 0ah, 0ah
wrd72 BYTE "1. MUL Instruction ", 0dh, 0ah
wrd73 BYTE "2. IMUL Instruction ", 0dh, 0ah
wrd74 BYTE "3. DIV Instruction ", 0dh, 0ah
wrd75 BYTE "4. Signed Integer Division ", 0dh, 0ah
wrd76 BYTE "5. CBW, CWD, CDQ Instruction ", 0dh, 0ah
wrd77 BYTE "6. IDIV Instruction ", 0dh, 0ah
str77 BYTE "7. Implement arithmetic expression ", 0dh, 0ah
wrd78 BYTE "8. Main Menu ", 0dh, 0ah, 0ah
wrd79 BYTE " Enter number from menu: ", 0ah, 0
;mychapter6.1.1 dan anak
val1 DWORD 00000011b
val2 DWORD 00000001b
val3 DWORD 0000b
val5 DWORD 01100011b
finalVal DWORD ?
disp1 BYTE " AND insruction : val1 = 0000 0011 val2 = 0000 0001 " ,0dh, 0ah, 0ah, 0
wrd81 BYTE " ** 6.1.1 AND Instruction **" ,0dh, 0ah, 0ah
wrd82 BYTE " Press 2 to Main Menu " ,0dh, 0ah
wrd84 BYTE " Press 3 to Chapter 6" ,0dh, 0ah
wrd90 BYTE " Press 4 to go Back" ,0dh, 0ah
wrd83 BYTE " Enter a number",0dh, 0ah, 0ah, 0
wrd85 BYTE " ** 6.1.2 OR Instruction **" ,0dh, 0ah, 0ah
wrd86 BYTE " Press 2 to Main Menu " ,0dh, 0ah
wrd87 BYTE " Press 3 to Main Chapter " ,0dh, 0ah
wrd89 BYTE " Press 4 to go Back" ,0dh, 0ah
wrd88 BYTE " Enter a number",0dh, 0ah, 0
wrd91 BYTE " Bit 1 in val=01100011b is set " ,0dh, 0ah, 0
disp2 BYTE " XOR insruction : val1 = 0000 0011 val3 = 0 " ,0dh, 0ah, 0
disp3 BYTE " CMP AL = 4, AL, 5 (CF,ZF) " ,0dh, 0ah, 0
; mychapter 6.2 dan anak
wrd92 BYTE "Specific flag (JP) ax = 5, cmp = 5" ,0dh, 0ah, 0ah, 0
wrd93 BYTE " Parity flag is " ,0dh, 0ah, 0ah, 0
wrd94 BYTE " Equality and al,00001011b cmp al,00001010b jne menu" ,0dh, 0ah, 0
wrd95 BYTE " Unsigned Comparison and al,00001011b cmp al,00001010b jae menu" ,0dh, 0ah, 0
wrd96 BYTE " Signed Comparison and al,+45 cmp al,-2 jge menu" ,0dh, 0ah, 0
wrd97 BYTE " LOOPZ al, 5 sub bx, 5 " ,0dh, 0ah, 0ah, 0
wrd130 BYTE " LOOPZ al, 5 sub bx, 7 " ,0dh, 0ah, 0ah, 0
; mychapter 6.4 dan anak
wrd98 BYTE " DL = 5, BL =5 Result : Both are same" ,0dh, 0ah, 0ah, 0
wrd99 BYTE " DL = 5, BL =5 Result : Both are not same" ,0dh, 0ah, 0ah, 0
wrd100 BYTE " Compare bl < cl && cl < dl jump to menu" ,0dh, 0ah, 0ah, 0
wrd101 BYTE " Compare bl < cl OR cl < dl jump to menu" ,0dh, 0ah, 0ah, 0
kata22 BYTE " loopz zero" ,0dh, 0ah, 0ah, 0
kata23 BYTE " loopz not zero" ,0dh, 0ah, 0ah, 0
disp7 BYTE " eax=5, ebx=2 while(eax > ebx) eax = eax - 1 jb go to menu; " ,0dh, 0ah,0ah, 0
; mychapter 6.5 dan anak
input BYTE "Enter a value :", 0
larger BYTE " The input value is greater than 50",0dh, 0ah, 0ah, 0
smaller BYTE " The input value is less than or equal to 50",0dh, 0ah, 0ah, 0
wrd127 BYTE "Relational : exp 1 != exp2 al=12, bl=9 jnbe go to menu ZF and CF ", 0
; mychapter 7.1 dan anak
wrd103 BYTE " Multiplication of Binary : EAX, 50 * (2^6 -2^1) = 3100" ,0dh, 0ah, 0ah, 0
wrd106 BYTE " AL = 2h, BL = 6h equals to ______ (*check CF) " ,0dh, 0ah, 0ah, 0
wrd107 BYTE " IMUL -16 * 2 * 2 equals to -64 (*always check Overflow flag) " ,0dh, 0ah, 0ah, 0
wrd108 BYTE " 6 divide by 3 equals to ___ (EAX) " ,0dh, 0ah, 0ah, 0
wordVal22 SWORD 155
wrd109 BYTE " -101 / 2 = " ,0dh, 0ah, 0ah, 0
wrd110 BYTE " IDIV 5000/-256 = EAX,-19 EDX, +136 " ,0dh, 0ah, 0ah, 0
cdqVal SDWORD 5000
cdqVal1 SDWORD -202
wrd120 BYTE " CDQ result stored in EAX of -202 + 2 " ,0dh, 0ah, 0ah, 0
out1 DWORD 10
out2 DWORD -17
out4 DWORD ?
out3 DWORD 3
wrd112 BYTE " ? = (var1 * -4) / (-var2 % var3); " ,0dh, 0ah, 0ah
wrd113 BYTE " ? = (10 * -4) / (-17 % 3); " ,0dh, 0ah, 0ah,0
; Isolating binary : Day info is in bit 8-4; Month info is in bit 5-8; year info is in bit 9-15
yearMessage byte "The year is:", 0dh, 0ah, 0
monthMessage byte "The month is:", 0dh, 0ah, 0
dayMessage byte "The day is:", 0dh, 0ah, 0
;Coding section
.code
main proc
Looop:
; Main
mov edx,OFFSET wrd1
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je Chapter6
mov bl, 2
cmp bl, al
je Chapter7
mov bl, 3
cmp bl, al
je Eexit
;;--------------------------------------------------------------------;;
;; ;;
;; CHAPTER 6 ;;
;; --------- ;;
;; ;;
;;____________________________________________________________________;;
Chapter6: mov edx,OFFSET wrd6
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C6N1
mov bl, 2
cmp bl, al
je C6N2
mov bl, 3
cmp bl, al
je C6N3
mov bl, 4
cmp bl, al
je C6N4
mov bl, 5
cmp bl, al
je C6N5
mov bl, 6
cmp bl, al
je Looop
C6N1:
mov edx,OFFSET wrd21
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C6N1A
mov bl, 2
cmp bl, al
je C6N1B
mov bl, 3
cmp bl, al
je C6N1C
mov bl, 4
cmp bl, al
je C6N1D
mov bl, 5
cmp bl, al
je C6N1E
mov bl, 6
cmp bl, al
je C6N1F
mov bl, 7
cmp bl, al
je Looop
;
C6N2:
mov edx,OFFSET wrd31
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C6N2A
mov bl, 2
cmp bl, al
je C6N2B
mov bl, 3
cmp bl, al
je C6N2C
mov bl, 4
cmp bl, al
je C6N2D
mov bl, 5
cmp bl, al
je Looop
C6N3:
mov edx,OFFSET wrd38
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C6N3A
mov bl, 2
cmp bl, al
je C6N3B
mov bl, 3
cmp bl, al
je Looop
C6N4:
mov edx,OFFSET wrd43
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C6N4A
mov bl, 2
cmp bl, al
je C6N4B
mov bl, 3
cmp bl, al
je C6N4C
mov bl, 4
cmp bl, al
je C6N4D
mov bl, 5
cmp bl, al
je Looop
C6N5:
mov edx,OFFSET wrd50
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C6N5A
mov bl, 2
cmp bl, al
je C6N5B
mov bl, 3
cmp bl, al
je C6N5C
mov bl, 4
cmp bl, al
je C6N5D
mov bl, 5
cmp bl, al
je Looop
;;--------------------------------------------------------------------;;
;; ;;
;; CHAPTER 7 ;;
;; --------- ;;
;; ;;
;;____________________________________________________________________;;
Chapter7: mov edx,OFFSET wrd14
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C7N1
mov bl, 2
cmp bl, al
je C7N2
mov bl, 3
cmp bl, al
je C7N3
mov bl, 4
cmp bl, al
je Looop
C7N1: mov edx,OFFSET wrd58
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C7N1A
mov bl, 2
cmp bl, al
je C7N1B
mov bl, 3
cmp bl, al
je C7N1C
mov bl, 4
cmp bl, al
je C7N1D
mov bl, 5
cmp bl, al
je C7N1E
mov bl, 6
cmp bl, al
je C7N1F
mov bl, 7
cmp bl, al
je C7N1G
mov bl, 8
cmp bl, al
je Looop
C7N2:
mov edx,OFFSET wrd67
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C7N2A
mov bl, 2
cmp bl, al
je C7N2B
mov bl, 3
cmp bl, al
je Looop
C7N3:
mov edx,OFFSET wrd71
call WriteString
call ReadInt
mov bl, 1
cmp bl, al
je C7N3A
mov bl, 2
cmp bl, al
je C7N3B
mov bl, 3
cmp bl, al
je C7N3C
mov bl, 4
cmp bl, al
je C7N3D
mov bl, 5
cmp bl, al
je C7N3E
mov bl, 6
cmp bl, al
je C7N3F
mov bl, 7
cmp bl, al
je C7N3G
mov bl, 8
cmp bl, al
je Looop
; -------------------- CHAPTER 6 CONDITIONAL PROCESSING ---------------------
C6N1A : mov edx,OFFSET disp1 ; AND instruction
call WriteString
mov edx,OFFSET wrd81 ; AND instruction
mov eax,val1
and eax, val2
mov finalVal, eax ; store the result
call DumpRegs ; display the registers
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N1
C6N1B :
mov eax,val1
or eax, val2
mov finalVal, eax ; store the result
call DumpRegs ; display the registers
mov edx,OFFSET wrd86 ; OR instruction
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N1
C6N1C :
mov edx,OFFSET disp2 ; XOR instruction
call WriteString
mov eax,val1
xor eax,val3
mov finalVal, eax ; store the result
call DumpRegs ; display the registers
mov edx,OFFSET wrd86 ; XOR instruction
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N1
C6N1D :
mov eax,val1 ; NOT instruction
not eax
call DumpRegs ; display the registers
mov edx,OFFSET wrd86
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N1
C6N1E :
; TEST instruction
test val5, 01100011b
jnz ThereIsValue
mov val1, eax ; store the result
call DumpRegs ; display the registers
mov edx,OFFSET wrd86
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N1
ThereIsValue:
mov edx,OFFSET wrd91
call WriteString
C6N1F :
mov edx,OFFSET disp3 ;
call WriteString
mov al,4
cmp al,5 ; CMP instruction
mov finalVal, eax ; store the result
call DumpRegs ; display the registers
mov edx,OFFSET wrd86 ;
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N1
C6N2A : mov edx,OFFSET wrd92 ; JP instruction
call WriteString
mov ax,5
cmp ax,5
mov finalVal, eax ; store the result
call DumpRegs ; display the registers
jp L1 ; jump if parity (even)
menumenu :
mov edx,OFFSET wrd86 ; OR instruction
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N2
C6N2B :
mov edx,OFFSET wrd94 ; Equality
call WriteString
and al,00001011b ; clear unwanted bits
cmp al,00001010b ; check remaining bits
mov finalVal, eax ; store the result
call DumpRegs ; display the registers
jne menumenu ; jump if NOT EQUAL leftOp with RightOp
C6N2C :
mov edx,OFFSET wrd95 ; Unsigned Comparison
call WriteString
mov al,00001011b ; clear unwanted bits
cmp al,00001010b ; check remaining bits
mov finalVal, eax ; store the result
call DumpRegs ; display the registers
jae menumenu ; Jump if above or equal (if leftOp >= rightOp)
C6N2D :
mov edx,OFFSET wrd96 ; Signed Comparison
call WriteString
mov ax,+45
cmp ax,-2
mov finalVal, eax ; store the result
call DumpRegs ; display the registers
jge menumenu ; Jump if greater
L1 : je menumenu
C6N3A : mov edx,OFFSET wrd97 ; LOOPZ
call WriteString
mov ax, 5
sub bx, 5
loopz sini
sini : mov edx,OFFSET kata22 ; loopz
call WriteString
mov edx,OFFSET wrd86 ; LOOPZ instruction
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N3
C6N3B :
mov edx,OFFSET wrd130 ; LOOPNZ
call WriteString
mov ax, 5
sub bx, 7
loopnz kesini
kesini : mov edx,OFFSET kata23 ; loopnz
call WriteString
mov edx,OFFSET wrd86 ; LOOPNZ instruction
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N3
C6N4A :
mov dl, 5
mov bl, 5
cmp dl,bl
je show
jne unshow
show :
mov edx,OFFSET wrd98 ; same
call WriteString
mov edx,OFFSET wrd86 ;
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N4
unshow :
mov edx,OFFSET wrd99 ; not same
call WriteString
mov ah, 04h
int 21h
C6N4B :
mov bl, 3 ; Compound expression AND
mov cl, 4
cmp bl,cl
jnae and1 ; Jump if Not Above or Equal
and1 :
mov edx,OFFSET wrd100 ; jump succeed menu appeared
call WriteString
mov cl, 3
mov dl, 5
cmp cl,dl
jb menuc6n4
menuc6n4 :
mov edx,OFFSET wrd86 ; OR instruction
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N4
C6N4C : mov bl, 3 ; Compound expression OR
mov cl, 4
cmp bl,cl
jnae or1 ; Jump if Not Above or Equal
or1 :
mov edx,OFFSET wrd101 ; jump succeed menu appeared
call WriteString
mov cl, 3
mov dl, 5
cmp cl,dl
jna menuc6n4 ; Jump if not above
jb menuc6n4 ;
C6N4D :
mov edx,OFFSET disp7 ; OR instruction
call WriteString
mov eax, 5
mov ebx, 2
je whileloop
whileloop: cmp eax,ebx ; check loop condition
jb menuc6n4 ; false? exit loop
dec eax ; body of loop
jmp whileloop ; repeat the loop
C6N5A :
mov edx, OFFSET input ; Runtime Expression
call WriteString
call ReadInt
cmp eax, 50
jg large
mov edx, OFFSET smaller
call WriteString
jmp menuc6n5
large :
mov edx, OFFSET larger
call WriteString
jmp menuc6n5
menuc6n5 :
mov edx,OFFSET wrd86 ; back to menu
call WriteString
call ReadInt
mov bl, 2
cmp bl, al
je Looop
mov bl, 3
cmp bl, al
je Chapter6
mov bl, 4
cmp bl, al
je C6N5
C6N5B :
mov edx,OFFSET wrd127 ; back to menu
call WriteString
mov al, 12 ; relational exp 1 != exp2
mov bl, 9
cmp al, bl
call DumpRegs
jnbe menuc6n5
C6N5C :
mov ax,5 ; .REPEAT Directive (Display integers 6-12)
.REPEAT
inc ax
call WriteDec
call Crlf
.UNTIL ax == 12
call menuc6n5
C6N5D :
mov eax, 0 ;.WHILE Directive (Display integers 1-4)
.WHILE eax < 4
inc eax
call WriteDec
call Crlf
.ENDW
call menuc6n5
;-------------------- CHAPTER 7 SHIFT AND ROTATE INSTRUCTION ---------------------
C7N1A :
mov al, 10000000b ;SHL
shl al, 2
call DumpRegs
call menuc7n1
C7N1B :
mov dl,20 ; SHR
shr dl,2
call DumpRegs
call menuc7n1
C7N1C :
mov ax, -128 ; SAR
shl eax, 16
sar eax, 16
call DumpRegs
call menuc7n1
C7N1D :
mov al,40h ; AL = 01000000b ; ROL
rol al,1 ; AL = 10000000b, CF = 0
rol al,1 ; AL = 00000001b, CF = 1
call DumpRegs
call menuc7n1
menuc7n1 :
mov edx,OFFSET wrd86 ; back to menu
call WriteString
call ReadInt