-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8086.asm
More file actions
2186 lines (2173 loc) · 40.4 KB
/
Copy path8086.asm
File metadata and controls
2186 lines (2173 loc) · 40.4 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
DSEG SEGMENT
DSEG ENDS
SSEG SEGMENT STACK
STK DB 8192 DUP(?)
SSEG ENDS
CSEG SEGMENT
ASSUME CS:CSEG,DS:DSEG,SS:SSEG
START:
MOV AX,DSEG
MOV DS,AX
SUB SP,2
CALL main
ADD SP,2
MOV AH,4CH
INT 21H
printlln PROC NEAR
MOV AH,02H
MOV DL,10
INT 21H
RET
printlln ENDP
scani PROC NEAR
MOV BX,0
PUSH BX
scanire1:
POP CX
MOV AH,01H
INT 21H
CMP AL,"-"
PUSHF
CMP AL,"0"
JB scanire1
CMP AL,"9"
JA scanire1
SUB AL,30H
MOV AH,0
ADD BX,AX
POPF
scanirld:
MOV AH,01H
INT 21H
CMP AL,"0"
JB scaniend
CMP AL,"9"
JA scaniend
PUSH AX
MOV AX,BX
MOV DX,10
MUL DX
MOV BX,AX
POP AX
SUB AL,30H
MOV AH,0
ADD BX,AX
JMP scanirld
scaniend:
PUSH CX
POPF
JNZ scaninng
NEG BX
scaninng:
MOV BP,SP
MOV [BP+2],BX
RET
scani ENDP
printc PROC NEAR
MOV BP,SP
MOV DL,[BP+2]
MOV AH,02H
INT 21H
RET
printc ENDP
printi PROC NEAR
MOV BP,SP
MOV AX,[BP+2]
CMP AX,0
JGE printinn
MOV DL,"-"
MOV AH,02H
INT 21H
MOV AX,[BP+2]
NEG AX
CMP AX,8000H
JNE printinn
MOV CX,8
PUSH CX
MOV AX,3276
MOV CX,10
JMP printidf
printinn:
MOV CX,10
CWD
DIV CX
PUSH DX
printidf:
CWD
DIV CX
PUSH DX
CWD
DIV CX
PUSH DX
CWD
DIV CX
PUSH DX
CWD
DIV CX
PUSH DX
MOV CX,5
printizr:
POP DX
CMP DL,0
JNZ printigo
CMP CL,1
JZ printigo
LOOP printizr
printiag:
POP DX
printigo:
ADD DL,30H
MOV AH,02H
INT 21H
LOOP printiag
MOV DL,20H
MOV AH,02H
INT 21H
RET
printi ENDP
;(func, promatrx, int, _) Qfunc
promatrx PROC NEAR
SUB SP,114
MOV BP,SP
;(array, una, 16, _) Qarray
;(declare, _, int, _) Qdeclare
;(arrayend, _, _, _) Qarrayend
;(declare, msize, int, _) Qdeclare
;(=, 4, _, msize) ASSIGNOP
MOV AX,4
MOV [BP+32],AX
;(declare, i, int, _) Qdeclare
;(=, 0, _, i) ASSIGNOP
MOV AX,0
MOV [BP+72],AX
;(declare, j, int, _) Qdeclare
;(=, 0, _, j) ASSIGNOP
MOV AX,0
MOV [BP+74],AX
;(declare, k, int, _) Qdeclare
;(=, 1, _, k) ASSIGNOP
MOV AX,1
MOV [BP+76],AX
;(declare, temp, int, _) Qdeclare
;(label, L1, _, _) Qlabel
L1:
;(tempDecl, t1, _, _) Qtemp_declare
;(<, i, msize, t1) RELOP
MOV AX,[BP+72]
CMP AX,[BP+32]
MOV AX,1
JL comp0
MOV AX,0
comp0:
MOV [BP+108],AX
;(if, t1, L2, L6) Qif
MOV AX,[BP+108]
CMP AX,0
JNE L2
JMP L6
;(label, L2, _, _) Qlabel
L2:
;(=, 0, _, j) ASSIGNOP
MOV AX,0
MOV [BP+74],AX
;(label, L3, _, _) Qlabel
L3:
;(tempDecl, t2, _, _) Qtemp_declare
;(<, j, msize, t2) RELOP
MOV AX,[BP+74]
CMP AX,[BP+32]
MOV AX,1
JL comp1
MOV AX,0
comp1:
MOV [BP+110],AX
;(if, t2, L4, L5) Qif
MOV AX,[BP+110]
CMP AX,0
JNE L4
JMP L5
;(label, L4, _, _) Qlabel
L4:
;(tempDecl, t3, _, _) Qtemp_declare
;(*, 4, i, t3) STAR
MOV AX,4
CWD
MOV BX,[BP+72]
IMUL BX
MOV [BP+112],AX
;(tempDecl, t4, _, _) Qtemp_declare
;(+, t3, j, t4) PLUS
MOV AX,[BP+112]
ADD AX,[BP+74]
MOV [BP+0],AX
;(tempDecl, t6, _, _) Qtemp_declare
;(call, scani, _, t6) Qcall
SUB SP,2
CALL scani
ADD SP,0
MOV BP,SP
MOV AX,[BP]
ADD BP,2
MOV [BP+4],AX
ADD SP,2
MOV BP,SP
;(tempDecl, t5, _, _) Qtemp_declare
;(=, t6, _, t5) ASSIGNOP
MOV AX,[BP+4]
MOV [BP+2],AX
;(arrayin, t5, t4, una) Qarrayin
MOV AX,[BP+0]
MOV CX,2
MUL CL
MOV SI,AX
MOV AX,[BP+2]
MOV SS:[BP+SI+40],AX
;(+, j, 1, j) PLUS
MOV AX,[BP+74]
ADD AX,1
MOV [BP+74],AX
;(+, k, 1, k) PLUS
MOV AX,[BP+76]
ADD AX,1
MOV [BP+76],AX
;(goto, L3, _, _) Qgoto
JMP L3
;(label, L5, _, _) Qlabel
L5:
;(+, i, 1, i) PLUS
MOV AX,[BP+72]
ADD AX,1
MOV [BP+72],AX
;(goto, L1, _, _) Qgoto
JMP L1
;(label, L6, _, _) Qlabel
L6:
;(=, 0, _, i) ASSIGNOP
MOV AX,0
MOV [BP+72],AX
;(label, L7, _, _) Qlabel
L7:
;(tempDecl, t10, _, _) Qtemp_declare
;(<, i, msize, t10) RELOP
MOV AX,[BP+72]
CMP AX,[BP+32]
MOV AX,1
JL comp2
MOV AX,0
comp2:
MOV [BP+8],AX
;(if, t10, L8, L12) Qif
MOV AX,[BP+8]
CMP AX,0
JNE L8
JMP L12
;(label, L8, _, _) Qlabel
L8:
;(=, 0, _, j) ASSIGNOP
MOV AX,0
MOV [BP+74],AX
;(label, L9, _, _) Qlabel
L9:
;(tempDecl, t11, _, _) Qtemp_declare
;(<, j, msize, t11) RELOP
MOV AX,[BP+74]
CMP AX,[BP+32]
MOV AX,1
JL comp3
MOV AX,0
comp3:
MOV [BP+16],AX
;(if, t11, L10, L11) Qif
MOV AX,[BP+16]
CMP AX,0
JNE L10
JMP L11
;(label, L10, _, _) Qlabel
L10:
;(tempDecl, t12, _, _) Qtemp_declare
;(*, 4, i, t12) STAR
MOV AX,4
CWD
MOV BX,[BP+72]
IMUL BX
MOV [BP+14],AX
;(tempDecl, t13, _, _) Qtemp_declare
;(+, t12, j, t13) PLUS
MOV AX,[BP+14]
ADD AX,[BP+74]
MOV [BP+24],AX
;(tempDecl, t14, _, _) Qtemp_declare
;(arrayout, una, t13, t14) Qarrayout
MOV AX,[BP+24]
MOV CX,2
MUL CL
MOV SI,AX
MOV AX,SS:[BP+SI+40]
MOV [BP+20],AX
;(putarg, t14, _, _) Qputarg
;(tempDecl, t15, _, _) Qtemp_declare
;(call, printi, _, t15) Qcall
SUB SP,2
MOV AX,[BP+20]
PUSH AX
CALL printi
ADD SP,2
MOV BP,SP
MOV AX,[BP]
ADD BP,2
MOV [BP+28],AX
ADD SP,2
MOV BP,SP
;(+, j, 1, j) PLUS
MOV AX,[BP+74]
ADD AX,1
MOV [BP+74],AX
;(goto, L9, _, _) Qgoto
JMP L9
;(label, L11, _, _) Qlabel
L11:
;(tempDecl, t17, _, _) Qtemp_declare
;(call, printlln, _, t17) Qcall
SUB SP,2
CALL printlln
ADD SP,0
MOV BP,SP
MOV AX,[BP]
ADD BP,2
MOV [BP+34],AX
ADD SP,2
MOV BP,SP
;(+, i, 1, i) PLUS
MOV AX,[BP+72]
ADD AX,1
MOV [BP+72],AX
;(goto, L7, _, _) Qgoto
JMP L7
;(label, L12, _, _) Qlabel
L12:
;(-, msize, 1, i) MINUS
MOV AX,[BP+32]
SUB AX,1
MOV [BP+72],AX
;(label, L13, _, _) Qlabel
L13:
;(tempDecl, t20, _, _) Qtemp_declare
;(>, i, 0, t20) RELOP
MOV AX,[BP+72]
CMP AX,0
MOV AX,1
JG comp4
MOV AX,0
comp4:
MOV [BP+84],AX
;(if, t20, L14, L18) Qif
MOV AX,[BP+84]
CMP AX,0
JNE L14
JMP L18
;(label, L14, _, _) Qlabel
L14:
;(=, 0, _, j) ASSIGNOP
MOV AX,0
MOV [BP+74],AX
;(label, L15, _, _) Qlabel
L15:
;(tempDecl, t21, _, _) Qtemp_declare
;(<, j, i, t21) RELOP
MOV AX,[BP+74]
CMP AX,[BP+72]
MOV AX,1
JL comp5
MOV AX,0
comp5:
MOV [BP+80],AX
;(if, t21, L16, L17) Qif
MOV AX,[BP+80]
CMP AX,0
JNE L16
JMP L17
;(label, L16, _, _) Qlabel
L16:
;(tempDecl, t22, _, _) Qtemp_declare
;(*, 4, i, t22) STAR
MOV AX,4
CWD
MOV BX,[BP+72]
IMUL BX
MOV [BP+92],AX
;(tempDecl, t23, _, _) Qtemp_declare
;(+, t22, j, t23) PLUS
MOV AX,[BP+92]
ADD AX,[BP+74]
MOV [BP+88],AX
;(arrayout, una, t23, temp) Qarrayout
MOV AX,[BP+88]
MOV CX,2
MUL CL
MOV SI,AX
MOV AX,SS:[BP+SI+40]
MOV [BP+38],AX
;(tempDecl, t25, _, _) Qtemp_declare
;(*, 4, i, t25) STAR
MOV AX,4
CWD
MOV BX,[BP+72]
IMUL BX
MOV [BP+96],AX
;(tempDecl, t26, _, _) Qtemp_declare
;(+, t25, j, t26) PLUS
MOV AX,[BP+96]
ADD AX,[BP+74]
MOV [BP+100],AX
;(tempDecl, t28, _, _) Qtemp_declare
;(*, 4, j, t28) STAR
MOV AX,4
CWD
MOV BX,[BP+74]
IMUL BX
MOV [BP+106],AX
;(tempDecl, t29, _, _) Qtemp_declare
;(+, t28, i, t29) PLUS
MOV AX,[BP+106]
ADD AX,[BP+72]
MOV [BP+104],AX
;(tempDecl, t30, _, _) Qtemp_declare
;(arrayout, una, t29, t30) Qarrayout
MOV AX,[BP+104]
MOV CX,2
MUL CL
MOV SI,AX
MOV AX,SS:[BP+SI+40]
MOV [BP+6],AX
;(tempDecl, t27, _, _) Qtemp_declare
;(=, t30, _, t27) ASSIGNOP
MOV AX,[BP+6]
MOV [BP+98],AX
;(arrayin, t27, t26, una) Qarrayin
MOV AX,[BP+100]
MOV CX,2
MUL CL
MOV SI,AX
MOV AX,[BP+98]
MOV SS:[BP+SI+40],AX
;(tempDecl, t31, _, _) Qtemp_declare
;(*, 4, j, t31) STAR
MOV AX,4
CWD
MOV BX,[BP+74]
IMUL BX
MOV [BP+12],AX
;(tempDecl, t32, _, _) Qtemp_declare
;(+, t31, i, t32) PLUS
MOV AX,[BP+12]
ADD AX,[BP+72]
MOV [BP+10],AX
;(tempDecl, t33, _, _) Qtemp_declare
;(=, temp, _, t33) ASSIGNOP
MOV AX,[BP+38]
MOV [BP+18],AX
;(arrayin, t33, t32, una) Qarrayin
MOV AX,[BP+10]
MOV CX,2
MUL CL
MOV SI,AX
MOV AX,[BP+18]
MOV SS:[BP+SI+40],AX
;(+, j, 1, j) PLUS
MOV AX,[BP+74]
ADD AX,1
MOV [BP+74],AX
;(goto, L15, _, _) Qgoto
JMP L15
;(label, L17, _, _) Qlabel
L17:
;(-, i, 1, i) MINUS
MOV AX,[BP+72]
SUB AX,1
MOV [BP+72],AX
;(goto, L13, _, _) Qgoto
JMP L13
;(label, L18, _, _) Qlabel
L18:
;(tempDecl, t36, _, _) Qtemp_declare
;(call, printlln, _, t36) Qcall
SUB SP,2
CALL printlln
ADD SP,0
MOV BP,SP
MOV AX,[BP]
ADD BP,2
MOV [BP+22],AX
ADD SP,2
MOV BP,SP
;(=, 0, _, i) ASSIGNOP
MOV AX,0
MOV [BP+72],AX
;(label, L19, _, _) Qlabel
L19:
;(tempDecl, t37, _, _) Qtemp_declare
;(<, i, msize, t37) RELOP
MOV AX,[BP+72]
CMP AX,[BP+32]
MOV AX,1
JL comp6
MOV AX,0
comp6:
MOV [BP+30],AX
;(if, t37, L20, L24) Qif
MOV AX,[BP+30]
CMP AX,0
JNE L20
JMP L24
;(label, L20, _, _) Qlabel
L20:
;(=, 0, _, j) ASSIGNOP
MOV AX,0
MOV [BP+74],AX
;(label, L21, _, _) Qlabel
L21:
;(tempDecl, t38, _, _) Qtemp_declare
;(<, j, msize, t38) RELOP
MOV AX,[BP+74]
CMP AX,[BP+32]
MOV AX,1
JL comp7
MOV AX,0
comp7:
MOV [BP+26],AX
;(if, t38, L22, L23) Qif
MOV AX,[BP+26]
CMP AX,0
JNE L22
JMP L23
;(label, L22, _, _) Qlabel
L22:
;(tempDecl, t39, _, _) Qtemp_declare
;(*, 4, i, t39) STAR
MOV AX,4
CWD
MOV BX,[BP+72]
IMUL BX
MOV [BP+36],AX
;(tempDecl, t40, _, _) Qtemp_declare
;(+, t39, j, t40) PLUS
MOV AX,[BP+36]
ADD AX,[BP+74]
MOV [BP+78],AX
;(arrayout, una, t40, temp) Qarrayout
MOV AX,[BP+78]
MOV CX,2
MUL CL
MOV SI,AX
MOV AX,SS:[BP+SI+40]
MOV [BP+38],AX
;(tempDecl, t42, _, _) Qtemp_declare
;(*, 4, i, t42) STAR
MOV AX,4
CWD
MOV BX,[BP+72]
IMUL BX
MOV [BP+86],AX
;(tempDecl, t43, _, _) Qtemp_declare
;(+, t42, j, t43) PLUS
MOV AX,[BP+86]
ADD AX,[BP+74]
MOV [BP+82],AX
;(tempDecl, t44, _, _) Qtemp_declare
;(arrayout, una, t43, t44) Qarrayout
MOV AX,[BP+82]
MOV CX,2
MUL CL
MOV SI,AX
MOV AX,SS:[BP+SI+40]
MOV [BP+94],AX
;(putarg, t44, _, _) Qputarg
;(tempDecl, t45, _, _) Qtemp_declare
;(call, printi, _, t45) Qcall
SUB SP,2
MOV AX,[BP+94]
PUSH AX
CALL printi
ADD SP,2
MOV BP,SP
MOV AX,[BP]
ADD BP,2
MOV [BP+90],AX
ADD SP,2
MOV BP,SP
;(+, j, 1, j) PLUS
MOV AX,[BP+74]
ADD AX,1
MOV [BP+74],AX
;(goto, L21, _, _) Qgoto
JMP L21
;(label, L23, _, _) Qlabel
L23:
;(+, i, 1, i) PLUS
MOV AX,[BP+72]
ADD AX,1
MOV [BP+72],AX
;(tempDecl, t48, _, _) Qtemp_declare
;(call, printlln, _, t48) Qcall
SUB SP,2
CALL printlln
ADD SP,0
MOV BP,SP
MOV AX,[BP]
ADD BP,2
MOV [BP+102],AX
ADD SP,2
MOV BP,SP
;(goto, L19, _, _) Qgoto
JMP L19
;(label, L24, _, _) Qlabel
L24:
;(return, 0, _, _) Qreturn
MOV AX,0
MOV [BP+116],AX
ADD SP,114
RET
;(endfunc, promatrx, _, _) Qendfunc
ADD SP,114
RET
promatrx ENDP
;(func, max, int, _) Qfunc
max PROC NEAR
SUB SP,2
MOV BP,SP
;(takearg, x, int, _) Qtakearg
;(takearg, y, int, _) Qtakearg
;(tempDecl, t49, _, _) Qtemp_declare
;(>=, x, y, t49) RELOP
MOV AX,[BP+4]
CMP AX,[BP+6]
MOV AX,1
JGE comp8
MOV AX,0
comp8:
MOV [BP+0],AX
;(if, t49, L25, L26) Qif
MOV AX,[BP+0]
CMP AX,0
JNE L25
JMP L26
;(label, L25, _, _) Qlabel
L25:
;(return, x, _, _) Qreturn
MOV AX,[BP+4]
MOV [BP+8],AX
ADD SP,2
RET
;(label, L26, _, _) Qlabel
L26:
;(return, y, _, _) Qreturn
MOV AX,[BP+6]
MOV [BP+8],AX
ADD SP,2
RET
;(endfunc, max, _, _) Qendfunc
ADD SP,2
RET
max ENDP
;(func, min, int, _) Qfunc
min PROC NEAR
SUB SP,2
MOV BP,SP
;(takearg, x, int, _) Qtakearg
;(takearg, y, int, _) Qtakearg
;(tempDecl, t50, _, _) Qtemp_declare
;(<=, x, y, t50) RELOP
MOV AX,[BP+4]
CMP AX,[BP+6]
MOV AX,1
JLE comp9
MOV AX,0
comp9:
MOV [BP+0],AX
;(if, t50, L27, L28) Qif
MOV AX,[BP+0]
CMP AX,0
JNE L27
JMP L28
;(label, L27, _, _) Qlabel
L27:
;(return, x, _, _) Qreturn
MOV AX,[BP+4]
MOV [BP+8],AX
ADD SP,2
RET
;(label, L28, _, _) Qlabel
L28:
;(return, y, _, _) Qreturn
MOV AX,[BP+6]
MOV [BP+8],AX
ADD SP,2
RET
;(endfunc, min, _, _) Qendfunc
ADD SP,2
RET
min ENDP
;(func, gcd, int, _) Qfunc
gcd PROC NEAR
SUB SP,14
MOV BP,SP
;(takearg, x, int, _) Qtakearg
;(takearg, y, int, _) Qtakearg
;(declare, ca, int, _) Qdeclare
;(tempDecl, t51, _, _) Qtemp_declare
;(<, x, 1, t51) RELOP
MOV AX,[BP+16]
CMP AX,1
MOV AX,1
JL comp10
MOV AX,0
comp10:
MOV [BP+2],AX
;(tempDecl, t52, _, _) Qtemp_declare
;(<, y, 1, t52) RELOP
MOV AX,[BP+18]
CMP AX,1
MOV AX,1
JL comp11
MOV AX,0
comp11:
MOV [BP+0],AX
;(tempDecl, t53, _, _) Qtemp_declare
;(||, t51, t52, t53) OR
MOV AX,[BP+2]
MOV BX,[BP+0]
CMP AX,0
MOV AX,1
JNZ comp12
MOV AX,0
comp12:
CMP BX,0
MOV BX,1
JNZ comp13
MOV BX,0
comp13:
OR AX,BX
MOV [BP+6],AX
;(if, t53, L29, L30) Qif
MOV AX,[BP+6]
CMP AX,0
JNE L29
JMP L30
;(label, L29, _, _) Qlabel
L29:
;(tempDecl, t54, _, _) Qtemp_declare
;(-, 0, 1, t54) MINUS
MOV AX,0
SUB AX,1
MOV [BP+4],AX
;(return, t54, _, _) Qreturn
MOV AX,[BP+4]
MOV [BP+20],AX
ADD SP,14
RET
;(label, L30, _, _) Qlabel
L30:
;(tempDecl, t55, _, _) Qtemp_declare
;(<, x, y, t55) RELOP
MOV AX,[BP+16]
CMP AX,[BP+18]
MOV AX,1
JL comp14
MOV AX,0
comp14:
MOV [BP+8],AX
;(if, t55, L31, L32) Qif
MOV AX,[BP+8]
CMP AX,0
JNE L31
JMP L32
;(label, L31, _, _) Qlabel
L31:
;(=, x, _, ca) ASSIGNOP
MOV AX,[BP+16]
MOV [BP+12],AX
;(=, y, _, x) ASSIGNOP
MOV AX,[BP+18]
MOV [BP+16],AX
;(=, ca, _, y) ASSIGNOP
MOV AX,[BP+12]
MOV [BP+18],AX
;(label, L32, _, _) Qlabel
L32:
;(label, L33, _, _) Qlabel
L33:
;(if, 1, L34, L37) Qif
MOV AX,1
CMP AX,0
JNE L34
JMP L37
;(label, L34, _, _) Qlabel
L34:
;(/, x, y, ca) DIV
MOV AX,[BP+16]
CWD
MOV BX,[BP+18]
IDIV BX
MOV [BP+12],AX
;(*, ca, y, ca) STAR
MOV AX,[BP+12]
CWD
MOV BX,[BP+18]
IMUL BX
MOV [BP+12],AX
;(-, x, ca, ca) MINUS
MOV AX,[BP+16]
SUB AX,[BP+12]
MOV [BP+12],AX
;(tempDecl, t59, _, _) Qtemp_declare
;(==, ca, 0, t59) RELOP
MOV AX,[BP+12]
CMP AX,0
MOV AX,1
JE comp15
MOV AX,0
comp15:
MOV [BP+10],AX
;(if, t59, L35, L36) Qif
MOV AX,[BP+10]
CMP AX,0
JNE L35
JMP L36
;(label, L35, _, _) Qlabel
L35:
;(return, y, _, _) Qreturn
MOV AX,[BP+18]
MOV [BP+20],AX
ADD SP,14
RET
;(label, L36, _, _) Qlabel
L36:
;(=, y, _, x) ASSIGNOP
MOV AX,[BP+18]
MOV [BP+16],AX
;(=, ca, _, y) ASSIGNOP
MOV AX,[BP+12]
MOV [BP+18],AX
;(goto, L33, _, _) Qgoto
JMP L33
;(label, L37, _, _) Qlabel
L37:
;(endfunc, gcd, _, _) Qendfunc
ADD SP,14
RET
gcd ENDP
;(func, lcm, int, _) Qfunc
lcm PROC NEAR
SUB SP,14
MOV BP,SP
;(takearg, x, int, _) Qtakearg
;(takearg, y, int, _) Qtakearg
;(tempDecl, t60, _, _) Qtemp_declare
;(<, x, 1, t60) RELOP
MOV AX,[BP+16]
CMP AX,1
MOV AX,1
JL comp16
MOV AX,0
comp16:
MOV [BP+12],AX
;(tempDecl, t61, _, _) Qtemp_declare
;(<, y, 1, t61) RELOP
MOV AX,[BP+18]
CMP AX,1
MOV AX,1
JL comp17
MOV AX,0
comp17:
MOV [BP+10],AX
;(tempDecl, t62, _, _) Qtemp_declare
;(||, t60, t61, t62) OR
MOV AX,[BP+12]
MOV BX,[BP+10]
CMP AX,0
MOV AX,1
JNZ comp18
MOV AX,0
comp18:
CMP BX,0
MOV BX,1
JNZ comp19
MOV BX,0
comp19:
OR AX,BX
MOV [BP+2],AX
;(if, t62, L38, L39) Qif
MOV AX,[BP+2]
CMP AX,0
JNE L38
JMP L39
;(label, L38, _, _) Qlabel
L38:
;(tempDecl, t63, _, _) Qtemp_declare
;(-, 0, 1, t63) MINUS
MOV AX,0
SUB AX,1
MOV [BP+0],AX
;(return, t63, _, _) Qreturn
MOV AX,[BP+0]
MOV [BP+20],AX
ADD SP,14
RET
;(label, L39, _, _) Qlabel
L39:
;(putarg, x, _, _) Qputarg
;(putarg, y, _, _) Qputarg
;(tempDecl, t64, _, _) Qtemp_declare
;(call, gcd, _, t64) Qcall
SUB SP,2
MOV AX,[BP+16]
PUSH AX
MOV AX,[BP+18]
PUSH AX
CALL gcd
ADD SP,4
MOV BP,SP
MOV AX,[BP]
ADD BP,2
MOV [BP+6],AX
ADD SP,2
MOV BP,SP
;(tempDecl, t65, _, _) Qtemp_declare
;(/, x, t64, t65) DIV
MOV AX,[BP+16]
CWD
MOV BX,[BP+6]
IDIV BX
MOV [BP+4],AX
;(tempDecl, t66, _, _) Qtemp_declare
;(*, t65, y, t66) STAR
MOV AX,[BP+4]
CWD
MOV BX,[BP+18]
IMUL BX
MOV [BP+8],AX
;(return, t66, _, _) Qreturn
MOV AX,[BP+8]
MOV [BP+20],AX
ADD SP,14
RET
;(endfunc, lcm, _, _) Qendfunc
ADD SP,14
RET
lcm ENDP
;(func, fbnic, int, _) Qfunc
fbnic PROC NEAR
SUB SP,12
MOV BP,SP
;(takearg, n, int, _) Qtakearg
;(tempDecl, t67, _, _) Qtemp_declare
;(>, n, 2, t67) RELOP
MOV AX,[BP+14]
CMP AX,2
MOV AX,1
JG comp20
MOV AX,0
comp20:
MOV [BP+0],AX
;(if, t67, L40, L41) Qif
MOV AX,[BP+0]
CMP AX,0
JNE L40
JMP L41
;(label, L40, _, _) Qlabel
L40:
;(tempDecl, t68, _, _) Qtemp_declare
;(-, n, 1, t68) MINUS
MOV AX,[BP+14]
SUB AX,1
MOV [BP+4],AX
;(putarg, t68, _, _) Qputarg
;(tempDecl, t69, _, _) Qtemp_declare
;(call, fbnic, _, t69) Qcall
SUB SP,2