-
Notifications
You must be signed in to change notification settings - Fork 1
/
logo.mac
7814 lines (6916 loc) · 176 KB
/
logo.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
TITLE LOGO
; TM
;(C) COPYRIGHT,1970,BOLT BERANEK AND NEWMAN INC., CAMBRIDGE, MASS.
;MODIFIED AT NATIONAL RESEARCH COUNCIL (ISS/REED), OTTAWA, CANADA BY A.G.SMITH
;AND R.A. ORCHARD
; NRC MODIFICATIONS INCLUDE NRCTUR AND MUSIC SYSTEM IMPLEMENTATION
; FOR NRCTUR EITHER THE TEKTRONIX 4010 (TEKTUR) OR THE PLASMA
; PANEL (PLSTUR) ARE AVAILABLE.
MLON
SALL
TWOSEG
;CONFIGURATION PARAMETERS
IFNDEF CONFIG,<DEFINE CONFIG,<TEN50!SAVBRK!NRCTUR!PLSTUR!MUSIC>>
DEFINE OPTIONS,<
MAYBE TEN50
MAYBE TENEX
MAYBE BBN50
MAYBE TURTLE
MAYBE SAVBRK; ;IF ON, SAVEUP THE STATE OF LOGO SO THAT "GO" PROCEEDS
MAYBE LEVELC
MAYBE DRIBBLE
MAYBE MOCKTURTLE
MAYBE COMPTK
MAYBE MITREI
MAYBE NRCTUR
MAYBE PLSTUR
MAYBE TEKTUR
MAYBE MUSIC
MAYBE TENKI
>
DEFINE MAYBE (A),
< A==%V
%V==%V+%V>
%V==1
OPTIONS
DEFINE MAYBE (A),
<A==CONFIG&A>
OPTIONS
;TO MAKE CONFIGURATION DEPENDENT STUFF READ LIKE ENGLISH
SYN IFN,FOR
SYN IFE,NOTFOR
FOR TEN50,<
BBNVER==2 ;BBN VERSION NUMBER
NRCVER==6 ;NRC MODIFICATION LEVEL
OTHVER==0 ;OTHER MODIFICATION LEVEL
EDITVR==44 ;EDIT NUMBER, INCREMENTED AT EVERY EDITING SESSION
.JBVER==137
LOC .JBVER
BYTE (3)OTHVER(9)BBNVER(6)NRCVER(18)EDITVR
>
ERPDLL==20 ;LENGTH OF ERROR PDL, NEEDS TO BE LONG ENOUGH TO
; AVOID PDL OVERFLOW TRAP
SUBTTL STORAGE ALLOCATION AND FLAG ASSIGNMENT
;ACCUMULATOR ASSIGNMENTS
F=0 ;FLAGS AND BITS
A=1
B=2
C=3
D=4
E=5
G=7
H=10
R=11
L=12
M=13
N=14
W=15
S=16 ;ARGUMENT PUSHDOWN STACK
P=17 ;CONTROL PUSHDOWN STACK
;FLAGS FOR THE LH OF F
LDONF==1 ;LINE DONE FLAG FOR EDIT MODE
EDITF==2
UPFF==4 ;COMEXR CALLED FROM RETURN CODE, NOT FROM COMEX
TIF==10
BREAKF==20
TOF==40 ;TYPE OR PRINT IN PROGRESS
GOF==100 ;USER TYPED DIRECT GO
RQF==200 ;A REQUEST IN PROGRESS
COMF==400 ;1 IF USER PROCEDURE BEING LEFT SHOULD BE TREATED LIKE COMMAND
GCF==1000 ;1 IF THIS K HAS NOT BEEN GARBAGE COLLECTED YET
TITLEF==2000 ;DOING TITLE DURING A TO
BROKE==4000 ;ERROR WAS NON-TYI BREAK KEY
GETF==10000 ;GET IN PROGRESS
SAVEF==20000 ;SAVE IN PROGRESS, FOR ALTERNATE FORMS OF TYPEOUT
;UNASSIGNED
NOBREAK==100000 ;TO TEMPORARILY INHIBIT BREAK KEY
FCHARF==200000 ;FOR COMPUTING THE TIME BETWEEN _ AND CHAR 1
GCCSF==400000 ;PROGRAM EDIT DONE, CODE PTRS ON STACK MAY BE INVALID
;FLAGS FOR THE RIGHT HALF OF F
TF==1 ;A TEMPORARY FLAG FOR MANY ROUTINES
PMF==2 ;+- SIGN
NWF==4 ;NOT WORD INPUT
CRF==10
FSYMF==20 ;0 IF FIRST ELEMENT OF LINE BEING COMPILED,USED W NNUMF
NNUMF==40 ;NON-NUMERIC INPUT
GRAPHF==100 ;TERMINAL IS IN GRAPHICS MODE
PREFIX==200 ;FOR PWORD
SUFFIX==400 ;ALSO FOR PWORD
MAKEF==1000 ;COMPIL CALLED WITH THIS=1 MEANS CALLED FROM MAKE
STORED==2000
FLUSHF==4000 ;GETTING AN ALREADY DEFINED PROCEDURE
EABBRF==10000 ;DOING LIST ENTRY ABBREVIATIONS
ECONTF==20000 ; " " " CONTENTS
EENTRF==40000 ; " " " ENTRY
ENAMEF==100000 ; " " " NAMES
EELSEF==200000 ; 1_ELSE IS OK LINE TERMINATOR
ESCHF==400000 ;SEEN A NON-PRINTING CHAR IN PRODNM
;FLAG DEFINITIONS FOR LH OF STRING POINTER
IMMEDIATE==400000 ;POINTER IS NOT A POINTER, BUT IS DATA
COMPOUND==200000 ; ELEMENT POINTED TO IS A LIST OF POINTERS
WORDF==100 ;STRING IS A WORD
SENTF==200 ;SENTENCE
EMPTYF==400 ;EMPTY
UNBOUN==40000 ;FOUND IN VP AND DP, 1_NOT EXPLICITLY SET
GLOBLF==100000 ; " " " " " , 1_TOPMOST BINDING, DONE BY MAKE
;FLAG DEFINITIONS FOR LH OF COMPILED ELEMENT
MPF==100000
UPRF==40000
VARF==20000
LITF==10000
INFOP==4000 ;IS AN INFIX OPERATOR
MVARF==2000 ; LIKE VARF, BUT TABLE APPEARS IN CODE
COMMTF==1000 ;IS A COMMENT
ANDF==400 ;USED IN TO LINES, IMPLIES THIS DUMMY PRECEDED BY AND
SCHF==20000 ;USED IN USER PROCEDURE NAMES, 1_NOT PROPER FORM
MAKESC==40 ;MEANS 2 LINE MAKE AND END OF NAME:
;ALSO IN THE LEFT HALF OF COMPILED ELEMENT CAN BE STRING BITS
;FLAG DEFINITIONS FOR LEFT HALF OF FIRST WORD OF RP PAIR
TRACEF==100000 ;THIS PROCEDURE IS BEING TRACED
;FLAG DEFINITION FOR LH OF 2ND WORD OF MACHINE NAME PAIR
COMPUT==400000 ;IF ONE, THIS NAME MUST BE COMPUTED, ADDR IN RH
;UUO DEFINITIONS
OPDEF ERROR [1B8]
OPDEF EXPAND [2B8]
OPDEF GARBAGE [3B8]
OPDEF SQUEZE [4B8]
OPDEF PJRST [254B8]
FOR PLSTUR,<
;CHARACTERS FOR SCREEN CONTROL FOR THE PLASMA PANEL TERMINAL
GRFON==16 ;TURN ON GRAPHIC MODE
DEFINE NEWPAG,<BYTE(7) 17,14,0> ;SHIFT OUT OF GRAPHICS AND CLEAR SCREEN
GRFOFF==17 ;TURN OFF GRAPHIC MODE
;PARAMETERS OF THE TERMINAL
CNTRLB==2 ;OCTAL FOR CONTROL B
PCHAR==120 ;OCTAL FOR CHARACTER "P"
HIXOFS==60 ;OFFSET FOR HIGH ORDER X COORDINATE
LOXOFS==120 ;OFFSET FOR LOW " " "
HIYOFS==60 ;ALSO FOR Y COORDINATE
LOYOFS==120 ;
HILIMX==^D511 ;UPPER AND LOWER SCREEN LIMITS FOR X
LOLIMX==0 ;
HILIMY==^D511 ;UPPER AND LOWER SCREEN LIMITS FOR Y
LOLIMY==0 ;
; SOME PARAMETERS RELATING TO THIS IMPLEMENTATION
TURSSC==1.0 ;FLOATING POINT SCREEN SCALE FACTOR
TURHMX==256.0 ;FLOATING POINT HOME POSITION FOR X AND Y
TURHMY==256.0 ;
;HOME POSITION IS CENTER OF SCREEN (256,256) FOR PLASMA TERMINAL
DEFINE TURHOM,<BYTE (7) 70,120,70,120,^D90>
;FIRST 4 BYTES OF TURHOM ARE THE HOME VALUES TURNYH,TURNYL,TURNXH,TURNXL
;LAST BYTE IS HOME VALUE OF ORIENT (90 DEGREES,I.E. STRAIGHT UP)
>
FOR TEKTUR,<
;CHARACTERS FOR SCREEN CONTROL FOR TEKTRONIX 4010 TERMINAL
GRFON==35 ;TURN ON GRAPHIC OUTPUT MODE
GRFOFF==37 ;TURN OFF GRAPHIC OUTPUT MODE
DEFINE NEWPAG,<BYTE (7)33,14,0> ;CLEAR SCREEN
;PARAMETERS OF THIS TERMINAL
HIXOFS==40 ;CHARACTER CODE OFFSET FOR HIGH ORDER X COORDINATE
LOXOFS==100 ;FOR LOW ORDER X COORDINATE
HIYOFS==40 ;FOR HIGH ORDER Y COORDINATE
LOYOFS==140 ;FOR LOW ORDER Y COORDINATE
HILIMX==^D1023 ;UPPER LIMIT FOR X ON SCREEN
LOLIMX==0 ;LOWER LIMIT FOR X ON SCREEN
HILIMY==^D780 ;UPPER LIMIT FOR Y ON SCREEN
LOLIMY==0 ;LOWER LIMIT FOR Y ON SCREEN
;PARAMETERS RELATING TO THIS IMPLEMENTATION
TURSSC==1.024 ;FLOATING POINT SCREEN SCALE FACTOR
TURHMX==500.0 ;FLOATING POINT HOME POSITION - X
TURHMY==381.3 ;FLOATING POINT HOME POSITION - Y
;HOME POSITION IS CENTER OF SCREEN (512,390) FOR THIS TERMINAL
DEFINE TURHOM,<BYTE (7)54,146,60,100,^D90>
;FIRST FOUR BYTES OF TURHOM ARE THE HOME VALUES OF TURNYH,TURNYL,TURNXH,TURNXL
;LAST BYTE IS HOME VALUE OF ORIENT (90 DEGREES, I.E. STRAIGHT UP)
>
;STORAGE ALLOCATION TABLE DEFINITIONS
DEFINE TABLES
;ANY CHANGE TO THE ORDER OF THESE TABLES MUST BE REFLECTED AT CMPRSS:
<TT RP,40,<[EXP RPA,0]> ;THESE THREE MAY BE IN ANY ORDER
TT VP,40,<[EXP VPA,0]>
TT UA,40
TT PS,200,<[EXP PSA,PSD,PSM,0]> ;THESE TWO MUST BE IN THIS ORDER
TT DP,200,<[EXP DPC,0]>
TT SP,40,<[EXP UUOACS+S,0]> ;THESE TWO MUST OCCUR IN THE SAME ORDER AS IN ACS
TT PP,200,<[EXP UUOACS+P,0]>
FOR TENEX,< TT WS,2000,<[EXP W,WSA,WSM,WSB,WSD,UUOACS+W,0]>>
FOR TEN50,<TT WS,2000,<[EXP W,WSA,WSM,WSB,WSD,UUOACS+W,BUFLOC,BUFLOC+1,FPTR,FPTR+1,0]>>
;THIS ONE MUST ALWAYS BE LAST SO MEM TRAP CAN BE USED AS END TEST
>
DEFINE POINTR
<MM RP,A
MM VP,A
MM PS,A
MM PS,D
MM PS,M
MM DP,C
MM WS,A
MM WS,M
MM WS,D
MM WS,B>
DEFINE U(A1)<UU(A1,1)>
DEFINE UU(A1,A2)<
A1: BLOCK A2 >
DEFINE UNDEX (AC)
< ADD AC,[XWD 070000,0]
CAIG AC,0
SUB AC,[XWD 430000,1]>
RELOC 0
;UNSHARED AREA, NON-ZERO STUFF FIRST
FOR MOCKTURTLE,<TURJFN=.
BLOCK 1 > ; SET BY OTHER PROCESS AND NEVER CLEARED BY LOGO
FURST==. ;IN CASE DIFFERENT SYSTEMS PUT DATA IN DIFFERENT PLACES
UU UUOTRP,2; ;Z
;JRST DOUUO
DEFINE MM (A1,A2)
<U A1'A2>
POINTR
U PTOP; ;ORDER OF THE NEXT TWO IS EXTREMELY IMPORTANT, MUST BE
U DTOP;
U WTOP;
U RANNO; ;STUFF TO COMPUTE PSEUDO-RANDOM DIGIT
FOR TENEX,< UU JFNTAB,10; ;FOR OPENNING FILES
UU CHNTAB,^D23> ;PSEUDO-INTERRUPT CHANNEL DISPATCHES
;OTHER GOOD FILE STUFF
U CHIN; ;INSTRUCTION TO EXECUTE TO READ A CHARACTER
U CHOUT; ;INSTRUCTION TO EXECUTE TO WRITE A CHARACTER
U INFILE;
U FPTRL0; ;ADDRESS OF BYTE POINTER FOR LOGICAL BUFFER 0
U FPTRL1; ;ADDRESS OF BYTE POINTER FOR LOGICAL BUFFER 1
U CCOUNT; ;COUNT OF CHARS REMAINING UNUSED IN LBUF+1
U TANDD; ;TIME AND DATE OF STARTUP
U FILEAD; ;FIRST BLOCK OF ENTRY BEING WRITTEN
U FILECT; ;COUNT OF BLOCKS USED IN WRITING THIS FILE
U LABS; ;WHERE PTR TO TOP OF FREE SPACE IS STORED DURING OPERATION
;I.E. NUMBER OF FIRST FREE LOGICAL BLOCK OF A FILE
U LDIRNO; ;BLOCK NUMBER OF PREVIOUS DIRECTORY
U LDIRL; ;NUMBER OF ENTRIES IN LDIRNO
U FILSIZ; ;SIZE IN DISC BLOCKS OF FILE
UU DMPLST,2
;DATA FOR EACH PHYSICAL BUFFER
UU BUFLOC,2; ;LOCATION IN CORE
UU PBLOCK,2; ;LOGICAL BLOCK NUMBER IN THE BUFFER
UU CHANGE,2; ;0 IF NOT ALTERED
UU FPTR,2; ;BYTE PTR INTO A BUFFER
;DATA FOR EACH LOGICAL BUFFER
UU LBLOCK,2; ;LOGICAL BLOCK NUMBER IN THIS LOGICAL BUFFER
UU LBUF,2; ;PHYSICAL BUFFER USED BY LOG BUFFER (0 OR 1)
FOR TEN50,<
UU OPNPAR,3; ;THIS MUST PRECEDE LUKDAT FOR COPY TO CLEAR!
UU LUKDAT,4
UU BUFADR,2; ;STRING POINTER LOCATIONS OF FILE BUFFERS
>
FOR DRIBBLE,<
U DRIBFL; ;FILE NUMBER OF DRIBBLE FILE
U DRIBTM; ;TIME OF TYPING _ FOR THE TIME STAMP
>
;DATA FOR NRC SCREEN TURTLE
FOR NRCTUR,<
U TURNYH; ;CHARACTER CODE FOR CURRENT HIGH-ORDER Y
U TURNYL; ; " " " LOW-ORDER Y
U TURNXH; ; " " " HIGH-ORDER X
U TURNXL; ; " " " LOW-ORDER X
U TURNFX; ;CURRENT X POSITION IN FLOATING POINT
U TURNFY; ; Y " " "
U TUROYH; ;CHARACTER CODE FOR PREVIOUS HIGH-ORDER Y
U TUROYL; ; " " " LOW-ORDER Y
U TUROXH; ; " " " HIGH-ORDER X
U TUROXL; ; " " " LOW-ORDER X
U TUROFX; ;PREVIOUS X POSITION IN FLOATING POINT
U TUROFY; ; Y " " "
U ORIENT; ;TURTLE'S CURRENT ORIENTATION (FIXED POINT - IN DEGREES)
U PENST; ;STATE (RAISED OR LOWERED) OF PEN
U OFFSCR; ;ON-SCREEN/OFF-SCREEN STATUS OF PEN
>
FOR MUSIC,< ;DATA FOR LOGO MUSIC BOX
U BXTYPE; ;HOLDS TYPE OF MUSIC BOX IN USE
U MBUFP
U MBMAX
U MBPOS
U NVOICE
U STCATO
>
DEFINE TT(A1,A2,A3)
<.'A1==.-BASETB
U A1>
BASETB:
TABLES
U CHARNO; ;THESE FOR INPUT SECTION
U BCHAR
U TRACEM; ;LIKE BCHAR BUT ONLY FOR TRACE OUTPUT
U SCOUNT
U LINENO
U PRODNM; ;NAME OF PROCEDURE IN PROGRESS
U TRUTH
U CBOT; ;BASE OF LINE PTED TO BY CPP
U CSTOCT; ;COUNT OF ROOM LEFT IN LINE BEING COMPILED
U CPP; ;POINTER INTO COMPILED LINE
U SPP; ;CONTENTS OF S AND P AT START OF LINE
U LINBOT
U SRCBOT
U NEWBOT
U NXLINE; ;PTR TO NEXT LINE IN CURRENT PROCEDURE
U THISPR; ;MACHINE PROCEDURE LAST IN, PTR TO 2ND ENTRY IN CMPT
U TOPROD; ;NAME OF PROCEDURE BEING DEFINED
U BRKTEM; ;TEM STORAGE FOR BREAKY ROUTINE
FOR TENEX,<U BRKTEB> ;MORE TEM FOR BREAK KEY
U GODEPT; ;THE NUMBER OF GO'S IN THE STACK
U TOFDAY; ;TIME OF STARTUP IN SECS SINCE MIDNIGHT OR RESET CLOCK
U BSP; ;SPP ASSOCIATED WITH GODEPTH, STACKS AT LAST SAVED BREAK
U GCTEM; ;TEM STORAGE FOR GC AND ALLOCATOR
U SAV.A
U SAV.B
U SAV.D
U SAVEIT
UU UUOACS,20
UU ERRPDL,ERPDLL; ;FIXED PUSHDOWN FOR ERROR HANDLER
FOR TENEX,< UU LEVLTB,3> ;FOR PSI SYSTEM
U GETDST; ;STUFF FOR COPY
U SAVSRC
FOR TENEX,<U COPJFN>
FOR TEN50,<
U FPTR2
U CCNT2
U BUFLC2; ;ABS ADDR OF COPY BUFFER
U BUFAD2;> ;WS ADDR OF COPY BUFFER
FOR MOCKTURTLE,<
U CURX
U CURY
U CURA
U PENPOS; ;0_DOWN, -1_UP
U TURX
U TURY
U TURXO
U TURYO; ; OLD TURX AND TURY FOR CHECKING FOR LONG MOVES
>
BLAST==.-1
SUBTTL INITIALIZATION
JOB41=.JB41##
JOBSA=.JBSA##
JOBREL=.JBREL##
JOBUUO=.JBUUO##
FOR TEN50,<
JOBREN=.JBREN##
JOBAPR=.JBAPR##
JOBOPC=.JBOPC##
JOBDDT=.JBDDT##
JOBFF=.JBFF##
JOBCNI=.JBCNI##
JOBTPC=.JBTPC##
RELOC 400000
>
FOR TENEX,<
SEARCH STENEX
RELOC> ;PAGE 0 WILL BE WRITABLE,1-LOGEND NOT
LOGO: MOVEI F,0 ;CLEAR FLAGS, MAY BE SKIPPED ON CERTAIN RESTARTS
FOR TEN50,<
CALLI 0 ;RESET
MOVEI A,BREAKY
MOVEM A,JOBREN ;FOR BREAK KEY
MOVEI A,ALLOC
MOVEM A,JOBAPR ;FOR ILLEGAL MEMORY REFS
HLRZ A,JOBSA ;INITIALIZE THE LOW SEG
HRLI A,(A)
ADDI A,1
HRRZ B,JOBREL ;TOP OF HIGHEST K ASSIGNED
SETZM -1(A)
BLT A,(B) > ;CLEAR FROM JOBFF TO TOP OF ASSIGNED CORE
FOR TENEX,<
RESET
MOVE A,[SIXBIT /LOGO/]
SETNM ;SET UP NAME FOR SYSTAT
MOVE A,[XWD 30000,30001]
SETZM 30000
BLT A,31777 >
FOR TEN50,<
MOVE 1,[SIXBIT /LOGO/]
SETNAM 1, >
MOVE A,[JSR UUOTRP]
MOVEM A,JOB41 ;FOR UUOS
MOVE A,[XWD FURST,FURST+1]
SETZM FURST
BLT A,BLAST ;CLEAR FROM START OF CORE TO EITHER DDT OR JOBFF
MOVE A,[XWD SPFRST,FURST]
BLT A,FURST+SPLLEN-1 ;SET UP NON-ZERO PART OF UNSHARED CORE
FOR TEN50,< HLRZ B,JOBSA> ;ALWAYS THE FIRST FREE LOCATION
FOR TENEX,< MOVEI B,30000> ;ENOUGH ROOM FOR CODE AND SYMBOLS
HRLZI A,-.WS-1
INILU: HLRZ C,ALOCTB(A) ;POINTER TO LIST OF CELLS TO BE SET UP
HRRZM B,BASETB(A) ;RP ETC.
JUMPE C,INILUR ;NO SUBSIDIARY LIST
INILU1: SKIPN E,(C)
JRST INILUR ;END OF SUBSIDIARY LIST
HRRM B,(E) ;NO, RPA ETC.
AOJA C,INILU1 ;NEXT IN THIS LIST
INILUR: ADD B,ALOCTB(A) ;HOW MUCH TO GIVE TO THIS SPACE
AOBJN A,INILU ;MORE SPACES TO GO
MOVEI A,0
JSP C,SETPDL
FOR TEN50,<
HRRZ A,JOBREL
CAIGE A,@WTOP ;IS WTOP INSIDE CURRENT ALLOCATION?
EXPAND WS ;NO, GET A K SO WS WILL FIT
PUSHJ P,SETTTM ;SET TELETYPE MODE TO BBN'S TELCOMP MODE
MOVEI A,220000
APRENB A, ;REQUEST PDL AND ILL MEM REF TRAPS
>
FOR TENEX,<
MOVEI A,30000-1
MOVEM A,JOBREL
JSP G,NEWMEM
ERROR . >
HRRZI A,(W)
HRLI A,.WBASE
BLT A,.WTOP-.WBASE-1(W)
HRRZI A,FLUSHM
HRRM A,JOBSA ;DON'T REDO THE INITIAL STORAGE ALLOCATION
PUSHJ P,TIMDAY ;IN SECONDS SINCE MIDNIGHT
TRNN F,TF
MOVEM C,TOFDAY ;TIME OF LAST RESET CLOCK
MOVEI B,[ASCIZ /
LOGO
/]
TRNN F,TF ;1 IF CALLED BY ERASE ALL
PUSHJ P,TOSS
RESET: SETZM TRACEM ;TRACE MARGIN
FOR NRCTUR,<PUSHJ P,TURRST> ;RESET SCREEN PARAMETERS
FOR TEN50,< PUSHJ P,SETTTM ;ENTER TELCOMP MODE
MOVEI A,220000
CALLI A,16> ;APR ENABLE
FOR TENEX,<
CIS ;CLEAR PSI SYSTEM
MOVEI A,400000 ;DENOTE THIS FORK
MOVE B,[XWD LEVTAB,CHNTAB]
SIR ;SET UP PSI SYSTEM
MOVEI A,0 ;BREAK TO CHANNEL 0
ATI ;ASSIGN TERMINAL INTERRUPT
MOVEI A,400000 ;THIS FORK
MOVE B,[1B0+1B9+1B10+1B11+1B22] ;
AIC ;ACTIVATE THESE CHANNELS
EIR ;ENABLE THE SYSTEM
MOVEI A,101
MOVE B,[EXP 525252525252]
MOVE C,B
SFCOC ;SET ALL CONTROL CHAR TYPEOUTS TO BE THEMSELVES
MOVEI A,100
RFMOD ;READ THE TERMINAL INPUT MODES
ANDCMI B,770000 ;ZERO OUT THE WAKEUP SET
IORI B,140000 ;SET THE WAKEUP SET TO ALL CONTROLS
SFMOD > ;SET THEM
SQUEZE ;TAKE OUT ANY EXTRA ALLOCATION
TRZE F,TF ;1 IF CALLED BY ERASE ALL
JRST MAINL
FOR DRIBBLE,< ;INITIALIZE THE DRIBBLE FILE
FOR TENEX,<
TLO F,NOBREAK ;DO NOT ALLOW BREAK KEY HERE
MOVEI B,[ASCIZ /INITIALS PLEASE: /]
PUSHJ P,TIS ;REQUEST INITIALS
JRST .-2 ;RUBOUT
MOVEI A,[ASCIZ /DRB/]
MOVEM A,JFNTAB+5
MOVE B,0(S)
MOVEI A,10
CAMGE A,@WSB
ERROR FILER9
ADDI B,1(W)
HRRZM B,JFNTAB+4
MOVE A,[ASCIZ /NMI/]
CAMN A,(B) ;TO OVERRIDE DRIBBLE CAPABILITY?
JRST DRIBEND ;YES
;FIX UP THE INPUT NAME
MOVEI A,1
MOVEM A,JFNTAB
MOVEI A,JFNTAB
SETZ B,
GTJFN
ERROR IOPERR
MOVE B,[XWD 070000,020000] ;FOR APPENDING
OPENF
ERROR IOPERR
MOVEM A,DRIBFL
MOVEI B,";"
BOUT
SETO B,
SETZ C,
ODTIM
MOVEI B," "
BOUT
MOVE D,0(S)
HRLI D,(POINT 7,(W),34)
ILDB B,D
BOUT ;MAYBE?
JUMPN B,.-2
MOVEI B,37
BOUT
DRIBEND: POP S,A
TLZ F,NOBREAK
>>
SUBTTL MAIN PROCESSOR LOOP
MAINL: MOVEI B,[ASCIZ /_/]
SKIPE TOPROD ;ARE WE DEFINING A PROCEDURE NOW?
MOVEI B,[ASCIZ />/] ;YES, READY CHAR IS >
PUSHJ P,TIS
JRST MAINL
MAINL1: PUSHJ P,COMPIL
JRST MAINL ;GOT A STORED LINE
PUSHJ P,EXECUT
JRST MAINL
;UUO TRAP HANDLER
DOUUO: MOVEM 17,UUOACS+17
HRRZI 17,UUOACS
BLT 17,UUOACS+16
MOVE 17,UUOACS+17
HLRZ A,JOBUUO
ASH A,-11 ;FLUSH AC, IF ONE
CAILE A,4 ;SQUEZE IS THE HIGHEST KNOWN UUO
JRST ILLUUO
JRST @.(A) ;ZERO CAUGHT BY MONITOR
ERRORR
ALLOCATOR
CALGAR
CMPRSS
CALGAR: MOVE B,WTOP
EXCH B,UUOACS+B
MOVEM B,SAV.B
JSP P,GARCOL ;NO PUSHES OR POPS IN GC
MOVE B,SAV.B
MOVEM B,UUOACS+B ; GARCOL NEEDS MAX REF FOR DE-ALLOC
JRST UUORET
FOR TEN50,<
CALDDT:
FOR BBN50,<MOVEI A,20000 ;LEAVE TELCOMP MODE IF IN IT
TTCALL 6,A
TLZ A,600000
TTCALL 7,A >
HRRZ A,JOBDDT
JUMPE A,[ERROR .]
PUSHJ P,(A) ;SO DEBUGGER MAY POPJ P,$X TO RETURN
PUSHJ P,SETTTM
JRST COMEX
SETTTM:
FOR BBN50,< MOVEI A,20000
TTCALL 6,A
TLO A,600000
TTCALL 7,A >
POPJ P,
BREAKY: TTCALL 11,
TTCALL 12,
TLNE F,NOBREAK ;IGNORE BREAK KEY?
JRST .+3 ;YES
TLNE F,TIF ;LEAVE IT SET FOR BRAKER ROUTINE
ERROR BREAK ;BREAK IMMEDIATELY IF TYPE IN HUNG
TLO F,BREAKF ;OTHERWISE, JUST FLAG IT FOR LATER
JRST 2,@JOBOPC >
FOR TENEX,<
BREAKY: MOVEM A,BRKTEM
MOVEM B,BRKTEB
HRLZI A,400000 ;DENOTE THIS FORK
MOVE B,A ;DENOTE INTERRUPT CHANNEL 0
DIC ;DEACTIVATE BREAK KEY
MOVE B,BRKTEB
MOVEI A,100
CFIBF ;CLEAR THE INPUT BUFFER
MOVEI A,101
CFOBF ;OUTPUT BUFFER TOO
MOVE A,BRKTEM
TLNE F,NOBREAK ;IGNORE BREAK?
JRST .+3 ;YES
TLNE F,TIF
ERROR BREAK
TLO F,BREAKF
DEBRK ;RETURN TO STOPPED PROCESS
CALDDT: PUSHJ P,770000 ;FOR NOW, ASSUME RESIDENT DDT
JRST COMEX >
SUBTTL COMPILE A LINE OF INPUT
COMPIL: TRZ F,STORED
MOVEI A,10
MOVEM A,CSTOCT
PUSHJ P,MAKELM
TLO B,COMPOUND
MOVEM B,CBOT
MOVEM B,CPP ;MAKE AN ELEMENT TO PUT COMPILED LINE IN
CMCOMP: TRZ F,FSYMF ;ENTER HERE FROM CMAKE
POP S,L
MOVE M,UA ;IF THE DEPTH OF ABBREVIATION EXPANSION
SUB M,UA+1 ;IS GREATER THAN THE NUMBER OF ABBS
LSH M,-1 ;THEN THERE IS A LOOP IN ABB DEFINITION
HRLZI M,-2(M) ;-MAX NO OF ABBREVIATIONS,,0
COMPAB: HRLI L,(POINT 7,(W),34)
MOVEM L,LINBOT
IBP L
GNS: TRZ F,NNUMF!ESCHF
SETZB N,SCOUNT ;CLEAR TYPE OF SYMBOL (N) AND CHAR COUNT
PUSHJ P,NEWSTR
GNS1: JSP E,LCH ;PICK UP PREV TERMINATR, MAY BE RELEVANT
JRST .+2
ILDB C,L ; NEXT CHAR FROM INPUT STRING
CAIN C," "
JRST .-2
JRST GNS2 ; HAVE FIRST NON-SPACE CHAR OF SYMBOL
GNSLET: CAIN C,"_" ; IS IT ASSIGNMENT OPERATOR?
JRST GNSMAK ; YES
GNSABC: TRO F,NNUMF ; NON-NUMERIC CHAR SEEN
GNSB: IDPB C,B ;STORE CHAR IN SYMBOL
AOS SCOUNT ; UPDATE LENGTH OF SYMBOL
ILDB C,L ; NEXT CHAR OF INPUT
GNS2: JUMPE C,GNSEND ; POSSIBLE END OF INPUT STRING
CAIL C,77 ; NOT, ? AND ABOVE ARE ALL PRINTING
JRST GNSLET ; CHARS AND LEGAL SYMBOL CONSTITUENTS
CAIL C,40 ; BELOW 40 ARE ALL CONTROL CHARS
JRST GNSSCH ; NOT, THE REST TAKE SPECIAL CARE
CAIN C,24 ; IS A CONTROL, IS IT CONTROL-T?
JRST [ MOVEI D,GNSLIT ; YES, THEN IT IS THE QUOTE FOR FILES
JRST GNSCH1 ]
GNODCH: TRO F,ESCHF ; THE REST THAT GOT THRU ARE SYMBOL
JRST GNSABC ; CONSTITUENTS BUT NOT FOR PROCEDURE NAM
GNSSCH: MOVE D,INFCTB-40(C) ; TABLE ENTRY FOR THE CHAR
TLNN D,TERM ; IS IT A TERMINATOR FOR PREVIOUS SYMBOL
JRST (D) ; NO, THEN DISPATCH ON ITS TYPE
GNSCH1: SKIPE SCOUNT ; IS THERE A PREVIOUS SYMBOL?
JRST GNSEND ; YES, THEN FIND OUT WHAT KIND IT IS
TLNN D,FOP ; IS IT AN INFIX OPERATOR?
JRST (D) ; NO, THEN IT HAS A SPECIAL HANDLER
IBP L ; YES, LETS NOT SEE THIS ONE AGAIN
HRR N,D ; YES, RH IS PTR INTO PRINTNAME TABLE
HRLI N,INFOP!IMMEDI ; LH OF COMPILED ELEMENT SAYS INFIX OP
JRST CMPLA ; AND WE STORE IT IN THE COMPILED CODE
GNSMAK: IBP L
MOVE N,[XWD INFOP!IMMEDI,IMAKEL+1]
JRST CMPLA
GNSEND: SKIPN SCOUNT ;NEW SYMBOL EMPTY?
JRST CMPLA ; YES, AT END OF WHOLE INPUT STRING
PUSHJ P,ENDSTR ;GOT A SYMBOL, FINISH IT
POP S,A ;THIS IS IT
TRNN F,NNUMF ;MIGHT IT BE A NUMBER, IE A LITERAL
JRST GNSN ;IT IS A POSSIBLE LINE NUMBER
;CHECK ELEMENT TO SEEE IF IT IS AN ABBREVIATION
ABBA:
HRRZ B,UA ;USER DEFINED ABBREVIATIONS FIRST
PUSHJ P,LOOKY
JRST NOABBS
MOVE C,1(N)
JUMPE C,GNSP3 ;A DELETED SYSTEM ABBREV, MUST BE A UPROC
AOJE C,NOABBS ;A DELETED ABBREVIATION
PUSH S,LINBOT
SUB L,LINBOT
PUSH P,L ;SAVE RELATIVE POINTER INTO SOURCE STRING
HRRZ L,1(N) ;USE THE VALUE OF THE ABBREV AS THE NEW SOURCE
AOBJN M,COMPAB ;WE ARE NOW ONE LEVEL DEEPER IN ABBREVS
ERROR ABBER1 ;LOOP IN ABBREVIATION DEFINITION
LCH: LDB C,L
JUMPN C,(E)
TRNN M,-1 ;TOP LEVEL ABBREVIATION?
JRST (E) ; YES, DONE WITH WHOLE INPUT STRING
POP S,LINBOT ;NOT TOP LEVEL
POP P,L
ADD L,LINBOT
SUB M,[XWD 1,1] ;UP ONE LEVEL
JRST LCH
DEFINE XOP (RH,LH)
<XWD LH,RH>
TERM==1
FOP==2
INFCTB:
XOP GNSEND,TERM ;SPACE
XOP GNSABC ; !
XOP GNSLIT,TERM ; "
XOP GNODCH ; # ,NOT LEGAL IN PNAME BECAUSE IT ECHOES AS SP
REPEAT 4,<XOP GNSABC> ; $%&'
XOP GNSLP,TERM ; (
XOP GNSRP,TERM ; )
XOP ITIMES+1,TERM+FOP ; *
XOP IPLUS+1,TERM+FOP ; +
XOP GNSABC ; ,
XOP IMINUS+1,TERM+FOP ; -
XOP GNSABC ; .
XOP IQUOT+1,TERM+FOP ; /
REPEAT 12,<GNSB> ; DIGITS 0-9
XOP GNSVAR,TERM ; :
XOP GNSCOM,TERM ; ;
XOP ILTHAN+1,TERM+FOP ; LEFT ANGLE BRACKET
XOP IEQUAL+1,TERM+FOP ; =
XOP IGRTR+1,TERM+FOP ; RIGHT ANGLE BRACKET
;TO RESTORE LOGO TO A PREFIX ONLY LANGUAGE, ALL "TERM+FOP"S
; SHOULD BE CHANGED TO GNSABC, IE LEGAL SYMBOL CONSTITUENTS
GNSLP: SKIPA N,[LPREN]
GNSRP: MOVEI N,RPREN
IBP L
CMPLMP: TLO N,MPF!IMMEDIATE
HRLZI C,200000
TDNE C,1(N) ;IS THIS MACHINE PROCEURE "MAKE"?
JRST CMAKE ;YES
ADDI N,1 ;NO, STORE MACHINE PROCEDURE CALL
CMPLA: PUSHJ P,CSTORE
TRO F,FSYMF ;NO LONGER FIRST ELEMENT
JUMPN N,GNS
CMPEND: TRNE F,MAKEF
POPJ P,
AOS A,CPP ;MAKE CPP POINT TO ONE BEYOND ELEMENT
MOVE B,CBOT
SUBI A,(B) ;GET LENGTH OF ELEMENT
MOVEI A,-1(A) ;STORED LENGTH IS ONE LESS THAN TOTAL LENGTH
EXCH A,@WSB ;SHORTEN THE ELEMENT
SUB A,@WSB ;SUBTRACT NEW LENGTH FROM OLD LENGTH
SOSL A ;FILL IN DUMMY ELEMENT FOR GARBAGE COLLECTOR
MOVEM A,@CPP
MOVEM B,CPP ;AND MAKE CPP POINT AT BEG OF LINE
TRZE F,STORED
JRST TOLINE
JRST CPOPJ1
GNSN: HRLZI N,LITF!WORDF
HRR N,NEWBOT
TRNN F,FSYMF!MAKEF ;IS IT FIRST ELEMENT AND NOT IN 2 LINE MAKE?
TRO F,STORED ;YES, NUMBER+FIRST_STORED LINE
JRST CMPLA
;NOT AN ABBREVIATION, CHECK FOR EXISTING PROCEDURE NAMES
NOABBS: MOVE A,NEWBOT
PUSHJ P,SYSLKP
JRST GNSP3
SKIPL 1(N) ;IS IT AN ABBREVIATION
JRST CMPLMP ;NO, A MACHINE PROCEDURE NAME
PUSH S,LINBOT
SUB L,LINBOT
PUSH P,L
HRRZ L,1(N)
HRLI L,350700
SETZM LINBOT
AOBJN M,GNS
ERROR IOPERR ;SYSTEM ABB MUST TERMINATE THE LOOP
GNSP3: MOVE A,NEWBOT
HRRZ B,RP
PUSHJ P,LOOKY
JRST .+2
JRST GNSP1 ;AND CALL THIS A USER PROCEDURE
MOVEI E,2(N) ;SPACE FOR THE NEW ENTRY IN TABLE
CAML E,RP+1 ;IS IT THERE ALREADY?
EXPAND RP
MOVE A,NEWBOT
MOVEM A,(N) ;NAME OF NEW PROCEDURE
SETOM 1(N) ;NOT YET TO'D
SETZM 2(N) ;NEW END OF TABLE
GNSP1: SUB N,RP
TLO N,UPRF!IMMEDIATE
TRZE F,ESCHF
TLO N,SCHF
AOJA N,CMPLA
;COMMENTS, LITERALS, AND VARIABLE NAMES GET COPIED AND EXTRA SPACES FLUSHED
GNSLIT: TLO N,LITF
JRST WEFA
GNSCOM: TLOA N,COMMTF
GNSVAR: TLO N,VARF
WEFA: MOVEI D,(C) ;SAVE THE PROPER TERMINATOR
PUSHJ P,WEFS
IBP L
WEFAB: TLNE N,VARF ;STARTED BY : ?
JRST VAREND ; ENDING A VERIABLE IS SPECIAL
POP S,B
IOR N,B
JRST CMPLA
WEFS: TRZ F,TF!NWF ;MAKE A WELL-FORMED STRING,
; I.E. NO LEADING SPACES, NO TRAILING,
; AND AT MOST ONE IN THE MIDDLE
ILDB C,L
CAIN C," "
JRST .-2
WEFC: CAIN C,(D) ;DONE YET?
JRST WEFB
JUMPE C,WEFD ;NO SECOND " / OR ;
TRO F,TF ;HAVE SEEN A REAL CHAR
IDPB C,B
ILDB C,L
CAIE C," "
JRST WEFC
ILDB C,L
CAIN C," "
JRST .-2 ;SAD SPC
CAIN C,(D)
JRST WEFB
JUMPE C,WEFD
MOVEI C," "
IDPB C,B
JSP E,LCH ;GET FIRST CHAR OF NEXT WORD AGAIN
TRO F,NWF ;GOT MORE THAN ONE WORD
JRST WEFC
WEFD: TLNN N,COMMTF ;IF A COMMENT, EOL IS OK
ERROR INERR1 ;BUT NOT LITS OR VARS
WEFB: TRNE F,TF ;IS THIS THING EMPTY?
JRST ENDSTR ;NO, FINISH THE STRING NORMALLY
PUSH S,[XWD WORDF!SENTF!EMPTYF,] ;EMPTY
POPJ P,
VAREND: MOVE A,(S) ; GOT A VARIABLE NAME
TLNE A,EMPTYF ; IS IT EMPTY?
ERROR NMERR5 ; YES, :: NOT PERMITTED
MOVEI B,MV
PUSHJ P,SYSLUK ; IS IT ONE OF THE BUILT IN NAMES?
JRST VAREN2 ; NO
POP S,A ; FLUSH THE GENERATED SYMBOL
TLO N,MVARF!IMMEDI ; CALL IT A MACHINE VARIABLE
AOJA N,CMPLA ; AND STORE ABS PTR TO VALUE WD IN MV
VAREN2: MOVE A,(S)
MOVE B,VP ; SEE IF IT EXISTS IN OBLIST
PUSH S,[XWD WORDF!SENTF!EMPTYF!UNBOUN!GLOBLF,0]
PUSHJ P,LOOKY
PUSHJ P,MAKEN ; NOT ALREADY THERE, ADD IT, VALUE AS ABOVE
POP S,A
POP S,A
SUB N,VP ; COMPILED ELEM IS PTR REL TO VP
TLO N,VARF!IMMEDI ; AND IS FLAGGED AS A VARIABLE
AOJA N,CMPLA
CMAKE: TRNE F,MAKEF ;ALREADY IN A 2 LINE MAKE?
AOJA N,CMPLA ;YES
JSP E,LCH
JUMPE C,CMAKE2
MOVE A,L
ILDB C,L
CAIN C," "
JRST .-2 ;SAD SPC
CAIE C,";" ;MAKE-COMMENT-CR
AOJA N,[MOVE L,A ;THIS IS ALSO A BUG, EVEN MORE OBSCURE!
JRST CMPLA ]
PUSHJ P,NEWSTR
PUSH S,[XWD COMMTF,0]
PUSHJ P,BTFCP1
ADD N,[XWD MAKESC,1]
PUSHJ P,CSTORE
POP S,N
JRST CMAKE3
CMAKE2: ADD N,[XWD MAKESC,1]
CMAKE3: TRO F,MAKEF
PUSHJ P,CSTORE
MOVEI B,[ASCIZ / NAME: /]
PUSHJ P,TIS ;ASK FOJ IT
JRST .-2
PUSHJ P,CMCOMP
SOS A,CPP
AOS CSTOCT
MOVSI B,MAKESC
IORM B,@WSA
MOVEI B,[ASCIZ / THING: /] ;CONTINUE TO ASK
PUSHJ P,TIS
JRST .-2
PUSHJ P,CMCOMP
TRZ F,MAKEF
JRST CMPEND
CSTORE: AOS A,CPP
MOVEM N,@WSA
SOSE CSTOCT
POPJ P,
MOVEI A,10 ;ADD THIS MUCH ROOM TO LINE ELEMENT
MOVEM A,CSTOCT
MOVE B,CBOT
PUSHJ P,COPYUP
TLO B,COMPOUND
MOVEM B,CBOT ;LOCATION OF NEW ELEMENT
MOVEM A,CPP ;NEW PTR TO OLD END