-
Notifications
You must be signed in to change notification settings - Fork 0
/
JMP.mac
1748 lines (1747 loc) · 26.8 KB
/
JMP.mac
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
; .ENABLE LC
.GLOBL BREAK,BREAKW,IRPS2
.GLOBL TXEND,LYGIS,STRREG,STRSIZ,CURON,CUROFF,$DADD$,STACK
.GLOBL CISLO,ID,SD,IS,SI,SEPAP,TRFLAG,TRIN,LIMIT,SAVJMP
.GLOBL ADRHLT,STAR,ISV,ENDCOD,LENT,CIKL,ISVEIL,IVEIL,DCMP
.GLOBL ISVTO,ISVETO,FCB,EGO,DGO,ISGUNP,HIMEM,BLOCK0,BLOCKN,ISVARD
.GLOBL BUF,PACK,TABTOP,BUFOUT,INK,FREBEG,FRELEN,MONERR,NUMBER
.GLOBL USRTAB,DATINP,DATPTR,IODEV,MAG,CASCII,DAT,CAS,LASTBL ;MAXFIL
.GLOBL CLRBUF,CLRCOD,LPTPOS,PFACT,WSTOP,TTANAL,SETST ;SIGNAL
;
;MTONV:: MOV #1,MAG
;MONV1: CALL CAS
; JMP @(4)+
;MTOFFV::CLR MAG
; BR MONV1
;
TRUN:: TST TRFLAG
BNE TEND
INC TRFLAG
TSTB LYGIS
BEQ TEND
TST NUMBER
BEQ 1$
NEG TRFLAG
BR TEND
1$: CMP @R4,#ENDPRG
BEQ TEND
JMP TRIN
;
TREND:: TST TRFLAG
BLE 1$
TSTB LYGIS
BEQ 1$
JSR R2,SEPAP
1$: CLR TRFLAG
TEND: JMP @(4)+
;
ENDPRG::CALL CLOALL
INC LYGIS
BNE END1
JSR R2,SEPAP
CLR ADRHLT
CALL TRTOPL
END1: JMP STAR
;
HALT:: MOV R4,SAVJMP
MOV #WSTOP,R1
MOV #5,R2
CALL ISVEIL
CMP R4,STRREG
BHI 3$
MOV R4,ADRHLT
2$: JSR R2,SEPAP
CALL TRTOPL
CALL LNUM
CMP -(R4),-(R4)
JSR R0,SETST
BR 1$
CLR ADRHLT
1$: CLR SAVJMP
BR END1
3$: CLR SAVJMP
JMP MONERR
;
TRTOPL: TST TRFLAG
BPL 1$
NEG TRFLAG
1$: RETURN
;
LNUM:: CALL AGAUD
MOV 2(0),R5
ATLIN1::MOV #ATLINE,R1
MOV #12,R2
CALL ISVEIL
MOV R5,R2
TRAP 114
MOV #12,R0
CALL ISV
RETURN
;
AGAUD:: MOV TABTOP,R0
3$: CMP (R0)+,R4
BLO 4$
CMP (R0)+,(R0)+
CMP R0,FCB
BLO 3$
TST (R0)+
4$: MOV R0,R4
RETURN
;
ATLINE: .BYTE 40,367,40,363,364,362,357,353,345,40 ; В СТРОКЕ
.EVEN
;
ICMP:: SUB (SP)+,(SP)+
JMP @(R4)+
;
NEXCMP::MOV CIKL,R1
MOV (R1)+,R0
MOV SP,R2
MOV (R2)+,(R0)+
BIT #20000,-4(R0)
BEQ NDCMP
MOV (R2)+,(R0)
MOV @R2,R2
ROL R2
ADC @R0
ADC -(R0)
BVS 1$
BCC NCMP
1$: TRAP 6
;
NDCMP: MOV (R2)+,(R0)+
MOV (R2),(R0)+
MOV (R2),(R0)+
NCMP: TST (R1)+
MOV (R1)+,-(SP)
MOV (R1)+,-(SP)
MOV (R1)+,-(SP)
MOV @R1,-(SP)
JMP DCMP
;
SCMP:: MOV @PC,R0
MOV 4(SP),R1
BGE 1$
ASL R0
MOV (SP)+,R2
BLT 2$
BR 4$
1$: MOV (SP)+,R2
BLT 5$
2$: CMP R1,R2
BNE 3$
CMP 4(SP),@SP
BNE 3$
CLR R0
3$: ROR R0
BCS 5$
4$: NEG R0
5$: ADD #6,SP
TST R0
JMP @(R4)+
;
$CMP:: MOV (SP)+,R2
MOV (SP)+,R3
MOV (SP)+,R1
MOV (SP)+,R0
SUB R1,R2
BPL 1$
ADD R2,R1
1$: DEC R1
BMI 2$
CMPB (R0)+,(R3)+
BEQ 1$
JMP @(R4)+
2$: NEG R2
JMP @(R4)+
;
.IF EQ,1
SWPD:: MOV #4,R2
BR EXSWAP
SWPR:: MOV #2,R2
BR EXSWAP
SWPI:: MOV #1,R2
EXSWAP: MOV (SP)+,R0
MOV (SP)+,R1
1$: MOV @R0,-(SP)
MOV @R1,(0)+
MOV (SP)+,(1)+
SOB R2,1$
JMP @(4)+
;
SWSSI:: MOV (SP)+,R1
MOV (SP)+,R0
BR SWAP1
SWSIS:: MOV (SP)+,R0
MOV (SP)+,R1
SWAP1: MOV @R0,-(SP)
MOVB @R1,@R0
MOVB (SP)+,(1)+
TST (0)+
MOV #2,R2
BR EXSSW
SWSII:: MOV (SP)+,R0
MOV (SP)+,R1
MOV #3,R2
;
EXSSW: MOVB @R0,-(SP)
MOVB @R1,(0)+
MOVB (SP)+,(1)+
SOB R2,EXSSW
JMP @(4)+
.ENDC
;
IFT:: TST (SP)+
BNE JMP
BR NJMP
;
IFF:: TST (SP)+
BEQ JMP
BR NJMP
;
ADDRBR::.WORD EQ,GT,LT,GE,LE,NE,0
;
EQ: BEQ TRUE
FALSE: CLR -(SP)
JMP @(R4)+
;
NE: BNE TRUE
BR FALSE
;
LE: BLE TRUE
BR FALSE
;
GE: BGE TRUE
BR FALSE
;
LT: BLT TRUE
BR FALSE
;
GT: BLE FALSE
TRUE: MOV #-1,-(SP)
JMP @(R4)+
;
NEXJMP::MOV CIKL,R1
TST 22(R1)
BMI 2$
TST R0
BGT 3$
1$: MOV 2(R1),R4
JMP @(R4)+
2$: TST R0
BGE 1$
3$: ADD #24,CIKL
JMP @(R4)+
;
JSR:: MOV CIKL,R0
TST -(R0)
CMP R0,ENDCOD
BLOS STCKER
MOV LIMIT,@R0
MOV R4,-(R0)
SUB: MOV R0,CIKL
MOV R0,LIMIT
;
JMP:: MOV @R4,R4
JMP @(R4)+
;
ONJMP:: MOV (SP)+,R0
BEQ ONSKIP
BIT #177400,R0
BNE ONERR
CMP R0,@R4
BLE JUMP
ONSKIP: MOV (R4)+,R0
ASL R0
ADD R0,R4
JMP @(R4)+
ONERR: TRAP 5
;
ONJSR:: MOV (SP)+,R0
BEQ ONSKIP
BIT #177400,R0
BNE ONERR
CMP R0,@R4
BGT ONSKIP
MOV @R4,R1
ASL R1
ADD R4,R1
MOV CIKL,R2
TST -(R2)
CMP R2,ENDCOD
BLOS STCKER
MOV LIMIT,@R2
MOV R1,-(R2)
MOV R2,CIKL
MOV R2,LIMIT
JUMP: ASL R0
ADD R0,R4
BR JMP
STCKER: TRAP 7
;
RTSTO:: MOV LIMIT,R0
CMP R0,LENT
BHIS RETERR
MOV @R0,R0
BR SUB
RETERR: TRAP 3
;
RTS:: MOV LIMIT,R0
CMP R0,LENT
BHIS RETERR
MOV (R0)+,R4
MOV (R0)+,LIMIT
MOV R0,CIKL
;
NJMP: TST (R4)+
JMP @(R4)+
;
DFNRET::MOV #4,R1
;
RETFN: MOV PFACT,R0
MOV (R0)+,PFACT
MOV R1,R2
ASL R2
ADD SP,R2
1$: MOV -(2),-(0)
SOB R1,1$
MOV R0,SP
MOV @(4)+,R4
JMP @(4)+
;
SFNRET::MOV #2,R1
BR RETFN
;
IFNRET::MOV #1,R1
BR RETFN
;
DFN:: MOV (4)+,R0
MOV (4)+,R1
MOV R4,@R1
MOV R0,R4
JMP @(4)+
;
FNST:: MOV PFACT,-(SP)
MOV SP,PFACT+2
JMP @(4)+
;
FNCALL::MOV (4)+,R0
MOV (0)+,R2
BEQ 2$
MOV @R4,R1
INC R1
1$: CMP (4)+,(2)+
BNE 3$
SOB R1,1$
MOV R4,@R0
MOV R2,R4
MOV PFACT+2,PFACT
JMP @(4)+
2$: TRAP 18.
3$: TRAP 5
;
APAR:: MOV PFACT,-(SP)
SUB (4)+,@SP
JMP @(4)+
;
IPAR:: MOV #1,R1
BR PARAM
;
SPAR:: MOV #2,R1
BR PARAM
;
DPAR:: MOV #4,R1
;
PARAM: MOV PFACT,R0
SUB (4)+,R0
1$: MOV -(0),-(SP)
SOB R1,1$
JMP @(4)+
;
DCONST::MOV (R4)+,-(SP)
MOV (R4)+,-(SP)
SCONST::MOV (R4)+,-(SP)
ICONST::MOV (R4)+,-(SP)
JMP @(R4)+
;
DXVAR:: MOV (SP)+,R1
BR DVAR1
;
DVAR:: MOV (R4)+,R1
DVAR1: ADD #10,R1
MOV -(R1),-(SP)
MOV -(R1),-(SP)
MOV -(R1),-(SP)
MOV -(R1),-(SP)
JMP @(R4)+
;
SXVAR:: MOV (SP)+,R1
BR SVAR1
;
SVAR:: MOV (R4)+,R1
SVAR1: MOV 2(R1),-(SP)
MOV @R1,-(SP)
JMP @(R4)+
;
IXVAR:: MOV @(SP)+,-(SP)
JMP @(R4)+
;
IVAR:: MOV @(R4)+,-(SP)
JMP @(R4)+
;
$XVAR:: MOV @SP,R0
MOVB (R0)+,R1
MOVB (R0)+,@SP
MOVB (R0)+,1(SP)
CLR -(SP)
BISB R1,@SP
JMP @(R4)+
;
$XMOV:: MOV (SP)+,R0
MOV (SP)+,R1
MOV (SP)+,R2
MOVB R0,(R2)+
MOVB R1,(R2)+
SWAB R1
MOVB R1,(R2)+
JMP @(R4)+
;
SXMOV:: MOV 4(SP),R1
BR XMOV
;
DXMOV:: MOV 10(SP),R1
MOV (SP)+,(R1)+
MOV (SP)+,(R1)+
XMOV:: MOV (SP)+,(R1)+
MOV (SP)+,@R1
SPJ: TST (SP)+
JMP @(R4)+
;
;
IXMOV:: MOV (SP)+,@(SP)+
JMP @(R4)+
;
SMOV:: MOV (R4)+,R1
BR MOVS
;
DMOV:: MOV (R4)+,R1
MOV (SP)+,(R1)+
MOV (SP)+,(R1)+
MOVS: MOV (SP)+,(R1)+
MOV (SP)+,@R1
JMP @(R4)+
;
IMOV:: MOV (SP)+,@(R4)+
JMP @(R4)+
;
MIDMOV::MOV (SP)+,R3
MOV (SP)+,R2
MOV (SP)+,R1
MOV (SP)+,R0
CMP R3,R1
BLE 1$
MOV R1,R3
1$: DEC R3
BMI 3$
MOVB (R2)+,(R0)+
BR 1$
3$: JMP @(R4)+
;
FORDBL::MOV CIKL,R0
MOV (SP)+,-(R0)
MOV (SP)+,-(R0)
MOV (SP)+,-(R0)
MOV (SP)+,-(R0)
MOV (SP)+,-(R0)
MOV (SP)+,-(R0)
BR FORMOV
FORINT::MOV CIKL,R0
FORMOV: MOV (SP)+,-(R0)
MOV (SP)+,-(R0)
MOV (R4)+,-(R0)
MOV (R4)+,-(R0)
CMP R0,ENDCOD
BLO 1$
MOV R0,CIKL
JMP @(R4)+
1$: TRAP 7
;
LIT:: MOV (SP)+,R2
BEQ SPJ
BR OUT2
;
NXSKIP::MOV CIKL,R1
MOV (R4)+,R0
BNE 1$
MOV @R1,R0
1$: CMP R1,LIMIT
BHIS 3$
CMP R0,(R1)+
BEQ 2$
MOV -(R1),R2
ADD #10,R1
BIT #40000,-(R2)
BNE 10$
ADD #14,R1
10$: MOV R1,CIKL
BR 1$
2$: JMP @(R4)+
3$: TRAP 1
;
NEXSNG::MOV -2(R0),R2
ROL R2
BMI 1$
ROL R2
BPL NEXDBL
CLR -(SP)
CLR -(SP)
CMP (R0)+,(R0)+
BR NEXADD
1$: CMP (R4)+,(R4)+
;
NEXINT::CMP (R1)+,(R1)+
MOV @R1,R2
ADD @R0,R2
BVS 4$
MOV R2,@R0
TST @R1
BMI 2$
CMP R2,-(R1)
BGT 3$
1$: MOV -(R1),R4
JMP @(R4)+
2$: CMP R2,-(R1)
BGE 1$
3$: ADD #10,CIKL
JMP @(R4)+
4$: TRAP 6
;
NEXDBL::ADD #6,R0
MOV @R0,-(SP)
MOV -(R0),-(SP)
NEXADD: MOV -(R0),-(SP)
MOV -(R0),-(SP)
ADD #12,R1
MOV (R1)+,-(SP)
MOV (R1)+,-(SP)
MOV (R1)+,-(SP)
MOV @R1,-(SP)
JMP $DADD$
;
NEWSTR::MOV (SP),R1
CALL TSTFRE
SUB R1,FRELEN
MOV 2(SP),R0
MOV FREBEG,R2
MOV R2,2(SP)
ADD R1,FREBEG
1$: DEC R1
BMI 2$
MOVB (R0)+,(R2)+
BR 1$
2$: JMP @(R4)+
;
TSTFRE: CMP R1,FRELEN
; BLOS 1$
; MOV R1,-(SP)
; CALL STRSQU
; MOV (SP)+,R1
; CMP R1,FRELEN
BHI 2$
1$: RETURN
2$: TRAP 14.
;
NEG:: TST @SP
BEQ 1$
ADD #100000,@SP
1$: JMP @(R4)+
;
BEEP0:: MOV #7,R0 ;TIK PYPT
BR JEND ;TIK PYPT
; MOV #1000,-(SP)
;BEEP1:: MOV #37,-(SP)
;BEEP2:: MOV (SP)+,R2
; MOV (SP)+,R1
; CALL SIGNAL
; JMP @(R4)+
;
NEWLIN::MOV #12,R0
BR JEND
;
JCLS:: MOV #14,R0
JEND: MOV R4,SAVJMP
CALL ISVTO
BR OUT3
;
SOUTSP::CALL EGO
BR J_OUT
;
DOUTSP::CALL DGO
J_OUT: MOV (SP)+,R2
OUT2: MOV (SP)+,R1
OUT1: MOV R4,SAVJMP
CALL ISVETO
OUT3: CLR SAVJMP
JMP @(R4)+
;
DLPOS:: CMP (SP)+,(SP)+
SLPOS:: TST (SP)+
ILPOS:: TST (SP)+
LPOS:: CLR -(SP)
MOVB LPTPOS,@SP
INC @SP
JMP @(4)+
;
IOUTSP::MOV (SP)+,R5
CALL ISGUNP
BR OUT1
;
GETLIT::MOV R4,SAVJMP
SUB #10,SAVJMP
BR G01
;
RESTV:: MOV (4)+,DATPTR
JMP @(4)+
;
READV:: MOV DATPTR,R3
BNE 1$
TRAP 4
1$: MOV #-1,DATINP
MOV R4,SAVJMP
MOV (4)+,-(SP)
BR G1
;
GET:: MOV R4,SAVJMP
G01: MOV (R4)+,-(SP)
MOV IODEV,R0
MOV R0,DATINP
BNE G03
MOV #'?,R0
BR G00
G13: CMPB @R3,#12
BEQ G02
CMP @R4,LENT
BHIS G30
MOV R3,-(SP)
TST (4)+
JMP @(4)+
G03: CALL FILINP
CMP R1,#BUF
BNE G04
TRAP 55.
G02: MOV DATINP,R0
BEQ 1$
BPL G03
TRAP 4
1$: MOV #'?,R0
CALL ISV
G00: CALL ISV
CALL CURON
CALL IVEIL
CALL CUROFF
G04: MOV #BUF,R3
TRAP 112
CMPB @R3,#12
BEQ G5
G1: CMP R4,@SP
BEQ G6
TRAP 112
CMPB @R3,#',
BNE G13
CMP (R4)+,LENT
BHIS G12
MOV -(R4),R4
G12: INC R3
BR G1
G20: MOV #',,-(SP)
MOV R1,-(SP)
CLR R1
MOV R3,-(SP)
CMPB @R3,#'"
BNE 22$
21$: MOVB (R3)+,4(SP)
INC (SP)
22$: CMPB @R3,#12
BEQ 24$
CMPB (3)+,4(SP)
BEQ 24$
INC R1
BR 22$
24$: MOV R0,R5
MOV @SP,-(SP)
MOV R3,2(SP)
BIT #177400,R1
BNE 28$
CALL TSTFRE
MOV FREBEG,R2
MOV (SP)+,R3
MOV R1,R0
BEQ 26$
25$: MOVB (3)+,(2)+
SOB R1,25$
26$: MOV (SP)+,R3
MOV (SP)+,R1
MOVB R0,(R1)+
TSTB R5
BMI 27$
CLRB (R1)+
27$: MOVB FREBEG,(R1)+
MOVB FREBEG+1,(R1)+
SUB R0,FRELEN
MOV R2,FREBEG
CMP (SP)+,#',
BEQ G1
BR G40
28$: TRAP 15.
G30: MOV (R4)+,R1
MOV R1,R0
G3: MOV -(R0),R0
BMI G20
MOV R4,-(SP)
MOV R1,-(SP)
CALL CISLO
BR G41
BR G41
BR G41
ROL R0
BMI 32$
ROL R0
BMI 31$
JSR R4,TODBL
.WORD SD,DXMOV,G33
.WORD ID,DXMOV,G33
31$: JSR R4,TOSNG
.WORD IS,SXMOV,G33
32$: JSR R4,TOINT
.WORD SI,IXMOV,G33
G5: MOV @SP,R4
G6: CLR SAVJMP
TST DATINP
BPL G66
MOV R3,DATPTR
G66: TST (SP)+
JMP @(4)+
G33: MOV (SP)+,R4
G40: TRAP 112
CMPB @R3,#',
BEQ G12
CMPB @R3,#12
BEQ G1
TST DATINP
BGT G1
G4: TRAP 13.
TST (SP)+
MOV SAVJMP,R4
JMP @-2(R4)
G41: CMP (SP)+,(SP)+
BR G4
GETARR::MOV (SP)+,R1
MOV (SP)+,R3
MOV -6(R4),R0
BR G3
;
TOINT:: MOV (SP)+,R2
BGE 1$
MOV R5,@(SP)+
BR G33
1$: CMP @SP,#44000
BGE E1
CMP @SP,#144000
BLO 3$
BNE E1
TSTB 3(SP)
BNE E1
3$: TST R2
BNE FROMS
FROMD: MOV (SP)+,2(SP)
MOV (SP)+,2(SP)
JMP @(R4)+
;
E1:
E2:
E3: TRAP 6
TRAP 5
;
TOSNG: MOV (SP)+,R2
BMI 1$
BNE NOCONV
ROL 4(SP)
ADC 2(SP)
ADC @SP
BVS E2
BCS E2
TST (R4)+
BR FROMD
1$: TST -(R4)
BR FROMI
;
TODBL: TST (SP)+
BEQ NOCONV
BPL FROMS
CMP (R4)+,(R4)+
FROMI: MOV R5,-(SP)
NOCONV: TST (R4)+
FROMS: JMP @(R4)+
;
ARR12: TRAP 12.
;
INDEX:: MOV (R4)+,R1
MOV (R1)+,R0
BNE 1$
TSTB LYGIS
BEQ ARR12
MOV ENDCOD,R0
INC R0
BIC #1,R0
CMP R0,CIKL
BHIS AR7
MOV #11.,@R0
MOVB #1,@R1
1$: MOV (R4)+,R3
CMPB R3,@R1
BNE AR9
MOV (SP)+,R1
BMI AR5
CMP R1,(R0)+
BGE AR9
2$: DEC R3
BLE 3$
MOV (SP)+,R2
BMI AR5
CMP R2,@R0
BGE AR9
MOV R1,-(SP)
MOV -(R0),R1
CALL DAUG
ADD (SP)+,R1
CMP (R0)+,(R0)+
BR 2$
3$: MOV -4(R4),R3
MOVB 3(R3),R2
CALL DAUG
ADD R1,R0
MOV R0,-(SP)
TST (R3)+
BEQ 4$
JMP @(R4)+
4$: CMP -(R4),-(R4)
;
ARR10::MOV #10.,-(SP)
;
ARRAY:: INC ENDCOD
BIC #1,ENDCOD
AR1: MOV (R4)+,R0
TST (R0)+
BNE AR10
MOV @R4,R3
MOV ENDCOD,R0
ADD R0,R3
CMP R3,CIKL
BHIS AR7
SUB R0,R3
MOV (SP)+,R1
BMI AR5
INC R1
BVS AR7
MOV R1,(R0)+
1$: DEC R3
BEQ AR2
MOV (SP)+,R2
BLT AR5
INC R2
BVS AR7
MOV R2,(R0)+
CALL DAUG
BPL 1$
AR7: TRAP 7
AR2: MOV -2(R4),R3
MOVB 3(R3),R2
CALL DAUG
BMI AR7
ADD R1,R0
BVS AR7
CMP R0,CIKL
BHI AR7
MOV ENDCOD,(R3)+
MOV R0,ENDCOD
MOVB (R4)+,@R3
INC R4
BIT #400,@R3
BEQ 3$
2$: CLRB -(R0)
DEC R1
BGT 2$
BR 4$
3$: CLR -(R0)
SUB #2,R1
BGT 3$
4$: TSTB LYGIS
BEQ 5$
JMP @(R4)+
5$: JMP STAR
AR5: TRAP 5
AR9: TRAP 9.
AR10: TRAP 10.
;
DAUG:: MOV R1,R5
CMP R5,R2
BLOS 3$
MOV R2,R5
MOV R1,R2
3$: CLR R1
4$: TST R5
BEQ 7$
TST R2
BMI 6$
ASR R5
BCC 5$
ADD R2,R1
BVS 6$
5$: ASL R2
BR 4$
6$: MOV #-1,R5
7$: RETURN
;
CHR:: BIT #177400,@SP
BNE IFCERR
MOVB @SP,INK+1
MOV #INK+1,@SP
MOV #1,-(SP)
JMP @(R4)+
IFCERR: TRAP 5
;
POKJMP::MOV (SP)+,@(SP)+
JMP @(R4)+
;
OUTJMP::TST (SP)+
BEQ 1$
BIS (SP)+,@(SP)+
JMP @(R4)+
1$: BIC (SP)+,@(SP)+
JMP @(R4)+
;
PEEK:: MOV @(SP),(SP)
JMP @(R4)+
;
INP:: MOV @2(SP),2(SP)
COM (SP)
BIC (SP)+,(SP)
JMP @(R4)+
;
DFRE:: CMP (SP)+,(SP)+
SFRE:: TST (SP)+
IFRE:: TST (SP)+
FRE:: MOV CIKL,-(SP)
SUB ENDCOD,@SP
ENDFRE: JMP @(R4)+
;
$FRE:: TST (SP)+
CALL STRSQU
MOV FRELEN,@SP
JMP @(R4)+
;
$SQUEE::CALL STRSQU
JMP @(R4)+
;
CLRMEM::
CMP @SP,#70000
BHI IFCERR
MOV #IRPS2-10,@#BREAKW
CALL CLOALL
MOV (SP)+,R2
ASR R2
ASL R2
SUB HIMEM,R2
CALL TABMOV
ADD R2,HIMEM
CALL CLRBUF
CALL CLRCOD
MOV (SP)+,R0
INC R0
BIC #1,R0
MOV R0,STRSIZ
MOV #BREAK,@#BREAKW
S1T: JMP STAR
;
TABMOV::MOV TABTOP,R0
ADD R2,R0
CMP R0,TXEND
BLT CLRERR
MOV FCB,R1
SUB TABTOP,R1
BEQ 4$
ASR R1
TST R2
BMI 2$
MOV FCB,R3
MOV R3,R0
ADD R2,R0
3$: MOV -(R3),-(R0)
SOB R1,3$
BR 4$
2$: MOV TABTOP,R3
5$: MOV (R3)+,(R0)+
SOB R1,5$
4$: ADD R2,TABTOP
RETURN
;
CLRSTR::MOV @SP,R0
BLT IFCERR
INC R0
BIC #1,R0
MOV R0,@SP
SUB STRSIZ,R0 ;
MOV R0,R1 ;АНАЛИЗ I-ГО АРГУМЕНТА
ADD ENDCOD,R0 ;
CMP R0,LENT
BHI CLRERR
MOV (SP)+,STRSIZ
BR CLR1
CLRERR: TRAP 7