forked from chrislgarry/Apollo-11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INTERPRETER.s
3059 lines (2524 loc) · 76.8 KB
/
INTERPRETER.s
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
# Copyright: Public domain.
# Filename: INTERPRETER.agc
# Purpose: Part of the source code for Colossus 2A, AKA Comanche 055.
# It is part of the source code for the Command Module's (CM)
# Apollo Guidance Computer (AGC), for Apollo 11.
# Assembler: yaYUL
# Contact: Ron Burkey <info@sandroid.org>.
# Website: www.ibiblio.org/apollo.
# Pages: 1107-1199
# Mod history: 2009-05-08 RSB Adapted from the Luminary131/ file of the
# same name, using Comanche055 page images.
# 2009-05-20 RSB Corrections: P00D00 -> P00DOO, fixed a
# "Page N" reference.
# 2009-05-21 RSB Corrected definition of 5B10, which overflowed
# integer arithmetic.
#
# This source code has been transcribed or otherwise adapted from digitized
# images of a hardcopy from the MIT Museum. The digitization was performed
# by Paul Fjeld, and arranged for by Deborah Douglas of the Museum. Many
# thanks to both. The images (with suitable reduction in storage size and
# consequent reduction in image quality as well) are available online at
# www.ibiblio.org/apollo. If for some reason you find that the images are
# illegible, contact me at info@sandroid.org about getting access to the
# (much) higher-quality images which Paul actually created.
#
# Notations on the hardcopy document read, in part:
#
# Assemble revision 055 of AGC program Comanche by NASA
# 2021113-051. 10:28 APR. 1, 1969
#
# This AGC program shall also be referred to as
# Colossus 2A
# Page 1107
# SECTION 1: DISPATCHER
#
# ENTRY TO THE INTERPRETER. INTPRET SETS LOC TO THE FIRST INSTRUCTION, BANKSET TO THE BBANK OF THE
# OBJECT INTERPRETIVE PROGRAM, AND INTBIT15 TO THE BIT15 CONTENTS OF FBANK. INTERPRETIVE PROGRAMS MAY BE IN
# VIRTUALLY ALL BANKS PRESENT UNDER ANY SUPER-BANK SETTING, WITH THE RESTRICTION THAT PROGRAMS IN HIGH BANKS
# (BIT15 OF FBANK = 1) DO NOT REFER TO LOWBANKS, AND VICE-VERSA. THE INTERPRETER DOES NOT SWITCH SUPERBANKS.
# E-BANK SWITCHING OCCURS WHENEVER GENERAL ERASABLE (100-3777) IS ADDRESSED.
BLOCK 03
COUNT* $$/INTER
INTPRET RELINT
EXTEND # SET LOC TO THE WORD FOLLOWING THE TC.
QXCH LOC
+2 CA BBANK # INTERPRETIVE BRANCHES FINISH HERE.
TS BANKSET
MASK BIT15 # GET 15TH BIT FOR INDEXABLE ADDRESSES.
TS INTBIT15
TS EDOP # MAKE SURE NO INSTRUCTIONS LEFT OVER
TCF NEWOPS # PICK UP OP CODE PAIR AND BEGIN.
INTRSM LXCH BBANK # RESUME SUSPENDED INTERPRETIVE JOB
TCF INTPRET +3
# DLOAD LOADS MPAC, MPAC +1, LEAVING ZERO IN MPAC +2.
DLOAD EXTEND
INDEX ADDRWD
DCA 0 # LOAD DP C(C(ADDRWD)) INT MPAC,MPAC +1
SLOAD2 DXCH MPAC
CAF ZERO # ZERO MPAC +2
# Page 1108
# AT THE END OF MOST INSTRUCTIONS, CONTROL IS GIVEN TO DANZIG TO DISPATCH THE NEXT OPERATION.
TS MPAC +2 # AND DECLARE DP MODE
NEWMODE TS MODE # PROLOGUE FOR MODE-CHANGING INSTRUCTIONS.
DANZIG CA BANKSET # SET BBANK BEFORE TESTING NEWJOB SO THAT
TS BBANK # IT MAY BE SAVED DIRECTLY BY CHANJOB.
NOIBNKSW CCS EDOP # SEE IF AN ORDER CODE IS LEFT OVER FROM
TCF OPJUMP # THE LAST PAIR RETRIEVED. IF SO, EXECUTE.
# EDOP IS SET TO ZERO ON ITS RE-EDITIING.
CCS NEWJOB # SEE IF A JOB OF HIGHER PRIORITY IS
TCF CHANG2 # PRESENT, AND IF SO, CHANGE JOBS.
INCR LOC # ADVANCE THE LOCATION COUNTER.
# ITRACE (1) REFERS TO "NEWOPS"
NEWOPS INDEX LOC # ENTRY TO BEGIN BY PICKING OP CODE PAIR.
CA 0 # MAY BE AN OPCODE PAIR OR A STORE CODE.
CCS A # TEST SIGN AND GET DABS(A).
TCF DOSTORE # PROCESS STORE CODE.
LOW7 OCT 177
TS EDOP # OP CODE PAIR. LEAVE THE OTHER IN EDOP
MASK LOW7 # WHERE CCS EDOP WILL HONOR IT NEXT.
OPJUMP TS CYR # LOWWD ENTERS HERE IF A RIGHT-HAND OP
CCS CYR # CODE IS TO BE PROCESSED. TEST PREFICES.
TCF OPJUMP2 # TEST SECOND PREFIX BIT.
TCF EXIT # +0 OP CODE IS EXIT
# Page 1109
# PROCESS ADDRESSES WHICH MAY BE DIRECT, INDEXED, OR REFERENCE THE PUSHDOWN LIST.
ADDRESS MASK BIT1 # SEE IF ADDRESS IS INDEXED. CYR CONTAINED
CCS A # 400XX, SO BIT 1 IS NOW AS IT WAS IN CYR.
TCF INDEX # FORM INDEXED ADDRESS.
DIRADRES INDEX LOC # LOOK AHEAD TO NEXT WORD TO SEE IF
OCT40001 CS 1 # ADDRESS IS GIVEN.
CCS A
TCF PUSHUP # IF NOT.
NEG4 DEC -4
INCR LOC # IF SO, TO SHOW WE PICKED UP A WORD.
TS ADDRWD
# Page 1110
# FINAL DIGESTION OF DIRECT ADDRESSES OF OP CODES WITH 01 PREFIX IS DONE HERE. IN EACH CASE, THE
# REQUIRED 12-BIT SUB-ADDRESS IS LEFT IN ADDRWD, WITH ANY REQUIRED E OR F BANK SWITCHING DONE. ADDRESSES LESS
# THAN 45D ARE TAKEN TO BE RELATIVE TO THE WORK AREA. THE OP CODE IS NOW IN BITS 1-5 OF CYR WITH BIT 14 = 1.
AD -ENDVAC # SEE IF ADDRESS RELATIVE TO WORK AREA.
CCS A
AD -ENDERAS # IF NOT, SEE IF IN GENERAL ERASABLE.
TCF IERASTST
NETZERO CA FIXLOC # IF SO, LEAVE THE MODIFIED ADDRESS IN
ADS ADDRWD # ADDRWD AND DISPATCH.
ITR15 INDEX CYR # THIS INDEX MAKES THE NEXT INSTRUCTION
7 INDJUMP -1 # TCF INDJUMP + OP, EDITING CYR.
IERASTST EXTEND
BZMF GEADDR # GO PROCESS GENERAL-ERASABLE ADDRESS.
MASK LOW10 # FIXED BANK ADDRESS. RESTORE AND ADD B15.
AD LOW10 # SWITCH BANKS AND LEAVE SUBADDRESS IN
XCH ADDRWD # ADDRWD FOR OPERAND RETRIEVAL. (THIS
AD INTBIT15 # METHOD PRECLUDES USE OF THE LAST
TS FBANK # LOCATION IN EACH FBANK.)
ITR12 INDEX CYR
7 INDJUMP -1
GEADDR MASK LOW8
AD OCT1400
XCH ADDRWD
TS EBANK
ITR10 INDEX CYR
7 INDJUMP -1
# Page 1111
# THE FOLLOWING ROUTINE PROCESSES INTERPRETIVE INDEXED ADDRESSES. AN INTERPRETER INDEX REGISTER MAY
# CONTAIN THE ADDRESS OF ANY ERASABLE REGISTER (0-42 BEING RELATIVE TO THE VAC AREA) OR ANY INTERPRETIVE PROGRAM
# BANK, OR ANY INTEGER IN THAT RANGE.
DODLOAD* CAF DLOAD* # STODL* COMES HERE TO PROCESS LOAD ADR.
TS CYR # (STOVL* ENTERS HERE).
INDEX CA FIXLOC # SET UP INDEX LOCATION.
TS INDEXLOC
INCR LOC # (ADDRESS ALWAYS GIVEN).
INDEX LOC
CS 0
CCS A # INDEX 2 IF ADDRESS STORED COMPLEMENTED.
INCR INDEXLOC
NOOP
TS ADDRWD # 14 BIT ADDRESS TO ADDRWD.
MASK HIGH4 # IF ADDRESS GREATER THAN 2K, ADD INTBIT15
EXTEND
BZF INDEX2
CA INTBIT15
ADS ADDRWD
INDEX2 INDEX INDEXLOC
CS X1
ADS ADDRWD # DO AUGMENT, IGNORING AND CORRECTING OVF.
MASK HIGH9 # SEE IF ADDRESS IS IN WORK AREA.
EXTEND
BZF INDWORK
MASK HIGH4 # SEE IF IN FIXED BANK.
EXTEND
BZF INDERASE
CA ADDRWD # IN FIXED -- SWITCH BANKS AND CREATE
TS FBANK # SUB-ADDRESS
MASK LOW10
AD 2K
TS ADDRWD
ITR11 INDEX CYR
3 INDJUMP -1
INDWORK CA FIXLOC # MAKE ADDRWD RELATIVE TO WORK AREA.
TCF ITR13 -1
INDERASE CA OCT1400
XCH ADDRWD
TS EBANK
MASK LOW8
-1 ADS ADDRWD
# Page 1112
ITR13 INDEX CYR
3 INDJUMP -1
# Page 1113
# PUSH-UP ROUTINES. WHEN NO OPERAND ADDRESS IS GIVEN, THE APPROPRIATE OPERAND IS TAKEN FROM THE PUSH-DOWN
# LIST. IN MOST CASES THE MODE OF THE RESULT (VECTOR OR SCALAR) OF THE LAST ARTGHMETIC OPERATION PERFORMED
# IS THE SAME AS THE TYPE OF OPERAND DESIRED (ALL ADD/SUBTRACT ETC.). EXCEPTIONS TO THIS GENERAL RULE ARE LISTED
# BELOW (NOTE THAT IN EVERY CASE THE MODE REGISTER IS LEFT INTACT):
#
# 1. VXSC AND V/SC WANT THE OPPOSITE TYPE OF OPERAND, E.G., IF THE LAST OPERATION YIELDED A VECTOR
# RESULT, VXSC WANTS A SCALAR.
#
# 2. THE LOAD CODES SHOULD LOAD THE ACCUMULATOR INDEPENDENT OF THE RESULT OF THE LAST OPERATION. THIS
# INCLUDES VLOAD, DLOAD, TLOAD, PDDL, AND PDVL (NO PUSHUP WITH SLOAD).
#
# 3. SOME ARITHMETIC OPERATIONS REQUIRE A STANDARD TYPE OF OPERAND REGARDLESS OF THE PREVIOUS OPERATION.
# THIS INCLUDES SIGN WANTING DP AND TAD REQUIRING TP.
PUSHUP CAF OCT23 # IF THE LOW 5 BITS OF CYR ARE LESS THAN
MASK CYR # 20, THIS OP REQUIRES SPECIAL ATTENTION.
AD -OCT10 # (NO -0).
CCS A
TCF REGUP # FOR ALL CODES GREATEER THAN OCT 7.
-OCT10 OCT -10
AD NEG4 # WE NOW HAVE 7 -- OP CODE (MOD4). SEE IF
CCS A # THE OP CODE (MOD4) IS THREE (REVERSE).
INDEX A # NO -- THE MODE IS DEFINITE. PICK UP THE
CS NO.WDS
TCF REGUP +2
INDEX MODE # FOR VXSC AND V/SC WE WANT THE REQUIRED
CS REVCNT # PUSHLOC DECREMENT WITHOUT CHANGING THE
TCF REGUP +2 # MODE AT THE IS TIME.
REGUP INDEX MODE # MOST ALL OP CODES PUSHUP HERE.
CS NO.WDS
+2 ADS PUSHLOC
TS ADDRWD
ITR14 INDEX CYR
7 INDJUMP -1 # (THE INDEX MAKES THIS A TCF.)
OCT 2 # REVERSE PUSHUP DECREMENT. VECTOR TAKES 2
REVCNT OCT 6 # WORDS, SCALAR TAKES 6.
OCT 6
NO.WDS OCT 2 # CONVENTIONAL DECREMENT IS 6 WORDS VECTOR
OCTAL3 OCT 3 # 2 IN DP, AND 3 IN TP.
OCT 6
# Page 1114
# TEST THE SECOND PREFIX BIT TO SEE IF THIS IS A MISCELLANEOUS OR A UNARY/SHORT SHIFT OPERATION.
OPJUMP2 CCS CYR # TEST SECOND PREFIX BIT.
TCF OPJUMP3 # TEST THIRD BIT TO SEE IF UNARY OR SHIFT
-ENDVAC DEC -45
# THE FOLLOWING ROUTINE PROCESSES ADDRESSES OF SUFFIX CLASS 10. THEY ARE BASICALLY WORK AREA ADDRESSES
# IN THE RANGE 0-52, ERASABLE ECADR CONSTANTS FROM 100-3777, AND FCADRS ABOVE THAT. ALL 15 BITS ARE AVAILABLE
# IN CONTRAST TO SUFFIX 1, IN WHICH ONLY THE LOW ORDER 14 ARE AVAILABLE.
15BITADR INCR LOC # (ENTRY HERE FROM STCALL).
INDEX LOC # PICK UP ADDRESS WORD.
CA 0
TS POLISH # WE MAY NEED A SUBADDRESS LATER.
CAF LOW7+2K # THESE INSTRUCTIONS ARE IN BANK 1.
TS FBANK
MASK CYR
ITR7 INDEX A
TCF MISCJUMP
# Page 1115
# COMPLETE THE DISPATCHING OF UNARY AND SHORT SHIFT OPERATIONS.
OPJUMP3 TS FBANK # CALL IN BANK 0 (BIT5S 11-15 OF A ARE 0.)
CCS CYR # TEST THIRD PREFIX BIT.
INDEX A # THE DECREMENTED UNARY CODE IS IN BITS
TCF UNAJUMP # 1-4 OF A (ZERO, EXIT, HAS BEEN DETECTED)
CCS MODE # IT'S A SHORT SHIFT CODE. SEE IF PRESENT
TCF SHORTT # SCALAR OR VECTOR.
TCF SHORTT
TCF SHORTV # CALLS THE APPROPRIATE ROUTINE.
FBANKMSK EQUALS BANKMASK
LVBUF ADRES VBUF
# Page 1116
# THE FOLLOWING IS THE JUMP TABLE FOR OP CODES WHICH MAY HAVE INDEXABLE ADDRESSES OR MAY PUSH UP.
INDJUMP TCF VLOAD # 00 -- LOAD MPAC WITH A VECTOR.
TCF TAD # 01 -- TRIPLE PRECISION ADD TO MPAC.
TCF SIGN # 02 -- COMPLEMENT MPAC (V OR SC) IF X NEG.
TCF VXSC # 03 -- VECTOR TIMES SCALAR.
TCF CGOTO # 04 -- COMPUTED GO TO.
TCF TLOAD # 05 -- LOAD MPAC WITH TRIPLE PRECISION.
TCF DLOAD # 06 -- LOAD MPAC WITH A DP SCALAR.
TCF V/SC # 07 -- VECTOR DIVIDED BY A SCALAR.
TCF SLOAD # 10 -- LOAD MPAC IN SINGLE PRECISION.
TCF SSP # 11 -- SET SINGLE PRECISION INTO X.
TCF PDDL # 12 -- PUSH DOWN MPAC AND RE-LOAD IN DP.
TCF MXV # 13 -- MATRIX POST-MULTIPLIED BY VECTOR.
TCF PDVL # 14 -- PUSH DOWN AND VECTORLOAD.
TCF CCALL # 15 -- COMPUTED CALL.
TCF VXM # 16 -- MATRIX PRE-MULTIPLIED BY VECTOR.
TCF TSLC # 17 -- NORMALIZE MPAC (SCALAR ONLY).
TCF DMPR # 20 -- DP MULTIPLY AND ROUND.
TCF DDV # 21 -- DP DIVIDE BY.
TCF BDDV # 22 -- DP DIVIDE INTO.
TCF GSHIFT # 23 -- GENERAL SHIFT INSTRUCTION
TCF VAD # 24 -- VECTOR ADD.
TCF VSU # 25 -- VECTOR SUBTRACT.
TCF BVSU # 26 -- VECTOR SUBTRACT FROM.
TCF DOT # 27 -- VECTOR DOT PRODUCT.
TCF VXV # 30 -- VECTOR CROSS PRODUCT.
TCF VPROJ # 31 -- VECTOR PROJECTION.
TCF DSU # 32 -- DP SUBTRACT.
TCF BDSU # 33 -- DP SUBTRACT FROM.
TCF DAD # 34 -- DP ADD.
TCF +0 # 35 -- AVAILABLE
TCF DMP1 # 36 -- DP MULTIPLY.
TCF SETPD # 37 -- SET PUSH DOWN POINTER (DIRECT ONLY)
# CODES 10 AND 14 MUST NOT PUSH UP. CODE 04 MAY BE USED FOR VECTOR DECLARE BEFORE PUSHUP IF DESIRED.
# Page 1117
# THE FOLLOWING JUMP TABLE APPLIES TO INDEX, BRANCH, AND MISCELLANEOUS INSTRUCTIONS.
MISCJUMP TCF AXT # 00 -- ADDRESS TO INDEX TRUE.
TCF AXC # 01 -- ADDRESS TO INDEX COMPLEMENTED.
TCF LXA # 02 -- LOAD INDEX FROM ERASABLE.
TCF LXC # 03 -- LOAD INDEX FROM COMPLEMENT OF ERAS.
TCF SXA # 04 -- STORE INDEX IN ERASABLE.
TCF XCHX # 05 -- EXCHANGE INDEX WITH ERASABLE.
TCF INCR # 06 -- INCREMENT INDEX REGISTER.
TCF TIX # 07 -- TRANSFER ON INDEX.
TCF XAD # 10 -- INDEX REGISTER ADD FROM ERASABLE.
TCF XSU # 11 -- INDEX SUBTRACT FROM ERASABLE.
TCF BZE/GOTO # 12 -- BRANCH ZERO AND GOTO
TCF BPL/BMN # 13 -- BRANCH PLUS AND BRANCH MINUS.
TCF RTB/BHIZ # 14 -- RETURN TO BASIC AND BRANCH HI ZERO.
TCF CALL/ITA # 15 -- CALL AND STORE QPRET.
TCF SW/ # 16 -- SWITCH INSTRUCTIONS AND AVAILABLE.
TCF BOV(B) # 17 -- BRANCH ON OVERFLOW TO BASIC OR INT.
# Page 1118
# THE FOLLOWING JUMP TABLE APPLIES TO UNARY INSTRUCTIONS
COUNT* $$/INTER
BANK 0 # 00 -- EXIT -- DETECTED EARLIER.
UNAJUMP TCF SQRT # 01 -- SQUARE ROOT.
TCF SINE # 02 -- SIN.
TCF COSINE # 03 -- COS.
TCF ARCSIN # 04 -- ARC SIN.
TCF ARCCOS # 05 -- ARC COS.
TCF DSQ # 06 -- DP SQUARE.
TCF ROUND # 07 -- ROUND TO DP.
TCF COMP # 10 -- COMPLEMENT VECTOR OR SCALAR
TCF VDEF # 11 -- VECTOR DEFINE.
TCF UNIT # 12 -- UNIT VECTOR.
TCF ABVALABS # 13 -- LENGTH OF VECTOR OR MAG OF SCALAR.
TCF VSQ # 14 -- SQUARE OF LENGTH OF VECTOR.
TCF STADR # 15 -- PUSH UP ON STORE CODE.
TCF RVQ # 16 -- RETURN VIA QPRET.
TCF PUSH # 17 -- PUSH MPAC DOWN.
# Page 1119
# SECTION 2 LOAD AND STORE PACKAGE.
#
# A SET OF EIGHT STORE CODES IS PROVIDED AS THE PRIMARY METHOD OF STORING THE MULTI-PURPOSE
# ACCUMULATOR (MPAC). IF IN THE DANZIG SECTION LOC REFERS TO AN ALGEBRAICALLY POSITIVE WORD, IT IS TAKEN AS A
# STORE CODE WITH A CORRESPONDING ERASABLE ADDRESS. MOST OF THESE CODES ARE TWO ADDRESS, SPECIFYING THAT THE WORD
# FOLLOWING THE STORE CODE IS TO BE USED AS AN ADDRESS FROM WHICH TO RE-LOAD MPAC. FOUR OPTIONS ARE AVAILABLE:
#
# 1. STORE STORE MPAC. THE E ADDRESS MAY BE INDEXED.
# 2. STODL STORE MPAC AND RE-LOAD IT IN DP WITH THE NEXT ADDRESS (THE LOAD MAY BE INDEXED).
# 3. STOVL STORE MPAC AND RE-LOAD A VECTOR (AS ABOVE).
# 4. STCALL STORE AND DO A CALL (BOTH ADDRESSES MUST BE DIRECT HERE).
#
# STODL AND STOVL WILL TAKE FROM THE PUSH-DOWN LIST IF NO LOAD ADDRESS IS GIVEN.
BLOCK 3
COUNT 03/INTER
STADR CA BANKSET # THE STADR CODE (PUSHUP UP ON STORE
TS FBANK # ADDRESS) ENTERS HERE.
INCR LOC
ITR1 INDEX LOC # THE STORECODE WAS STORED COMPLEMENTED TO
CS 0 # MAKE IT LOOK LIKE AN OPCODE PAIR.
AD NEGONE # (YUL CAN'T REMOVE 1 BECAUSE OF EARLY CCS)
DOSTORE TS ADDRWD
MASK LOW11 # ENTRY FROM DISPATCHER. SAVE THE ARASABLE
XCH ADDRWD # ADDRESS AND JUMP ON THE STORE CODE NO.
MASK B12T14
EXTEND
MP BIT5 # EACH TRANSFER VECTOR ENTRY IS TWO WORDS.
ITR0 INDEX A
TCF STORJUMP
# Page 1120
# STORE CODE JUMP TABLE. CALLS THE APPROPRIATE STORING ROUTINE AND EXITS TO DANZIG OR TO ADDRESS WITH
# A SUPPLIED OPERATION CODE.
#
# STORE STORE,1 AND STORE,2 RETURN TO DANZIG, THUS RESETTING THE EBANK TO ITS STATE AT INTPRET.
STORJUMP TC STORE # STORE.
TCF DANZIG # PICK UP NEW OP CODE(S).
TC STORE,1
TCF DANZIG
TC STORE,2
TCF DANZIG
TC STORE # STODL.
TCF DODLOAD
TC STORE # STODL WITH INDEXED LOAD ADDRESS.
TCF DODLOAD*
TC STORE # STOVL.
TCF DOVLOAD
TC STORE # STOVL WITH INDEXED LOAD ADDRESS.
TCF DOVLOAD*
TC STORE # STOTC.
CAF CALLCODE
TS CYR
TCF 15BITADR # GET A 15 BIT ADDRESS.
# Page 1121
# STORE CODE ADDRESS PROCESSOR.
STORE,1 INDEX FIXLOC
CS X1
TCF PRESTORE
STORE,2 INDEX FIXLOC
CS X2
PRESTORE ADS ADDRWD # RESULTANT ADDRESS IS IN ERASABLE.
STORE CS ADDRWD
AD DEC45
CCS A # DOES THE ADDRESS POINT TO THE WORK AREA?
CA FIXLOC # YES.
TCF AHEAD5
CA OCT1400 # NO. SET EBANK & MAKE UP SUBADDRESS.
XCH ADDRWD
TS EBANK
MASK LOW8
AHEAD5 ADS ADDRWD
# Page 1122
# STORING ROUTINES. STORE DP, TP, OR VECTOR AS INDICATED BY MODE.
STARTSTO EXTEND # MPAC,+1 MUST BE STORED IN ANY EVENT.
# ITRACE (5) REFERS TO "STARTSTO".
DCA MPAC
INDEX ADDRWD
DXCH 0
CCS MODE
TCF TSTORE
TC Q
VSTORE EXTEND
DCA MPAC +3
INDEX ADDRWD
DXCH 2
EXTEND
DCA MPAC +5
INDEX ADDRWD
DXCH 4
TC Q
TSTORE CA MPAC +2
INDEX ADDRWD
TS 2
TC Q
# Page 1123
# ROUTINES TO BEGIN PROCESSING OF THE SECOND ADDRESS ASSOCIATED WITH ALL STORE-TYPE CODES EXCEPT STORE
# ITSELF.
DODLOAD CAF DLOADCOD
TS CYR
TCF DIRADRES # GO GET A DIRECT ADDRESS.
DOVLOAD CAF VLOADCOD
TS CYR
TCF DIRADRES
DOVLOAD* CAF VLOAD*
TCF DODLOAD* +1 # PROLOGUE TO INDEX ROUTINE.
# Page 1124
# THE FOLLOWING LOAD INSTRUCTIONS ARE PROVIDED FOR LOADING THE MULTI-PURPOSE ACCUMULATOR MPAC.
TLOAD INDEX ADDRWD
CA 2 # LOAD A TRIPLE PRECISION ARGUMENT INTO
TS MPAC +2 # THE FIRST THREE MPAC REGISTERS, WITH THE
EXTEND # CONTENTS OF THE OTHER FOUR IRRELEVANT.
INDEX ADDRWD
DCA 0
DXCH MPAC
TMODE CAF ONE
TCF NEWMODE # DECLEARE TRIPLE PRECISION MODE.
SLOAD ZL # LOAD A SINGLE PRECISION NUMBER INTO
INDEX ADDRWD # MPAC, SETTING MPAC+1,2 TO ZERO. THE
CA 0 # CONTENTS OF THE REMAINING MPAC REGISTERS
TCF SLOAD2 # ARE IRRELEVANT.
VLOAD EXTEND # LOAD A DOUBLE PRECISION VECTOR INTO
INDEX ADDRWD # MPAC,+1, MPAC+3,4, AND MPAC+5,6. THE
DCA 0 # CONTENTS OF MPAC +2 ARE IRRELEVANT.
DXCH MPAC
ENDVLOAD EXTEND # PDVL COMES HERE TO FINISH UP FOR DP, TP.
INDEX ADDRWD
DCA 2
DXCH MPAC +3
+4 EXTEND # TPDVL FINISHES HERE.
INDEX ADDRWD
DCA 4
DXCH MPAC +5
VMODE CS ONE # DECLARE VECTOR MODE.
TCF NEWMODE
# Page 1125
# THE FOLLOWING INSTRUCTIONS ARE PROVIDED FOR STORING OPERANDS IN THE PUSHDOWN LIST:
# 1. PUSH PUSHDOWN AND NO LOAD.
# 2. PDDL PUSHDOWN AND DOUBLE PRECISION LOAD.
# 3. PDVL PUSHDOWN AND VECTOR LOAD.
PDDL EXTEND
INDEX ADDRWD # LOAD MPAC,+1, PUSHING THE FORMER
DCA 0 # CONTENTS DOWN.
DXCH MPAC
INDEX PUSHLOC
DXCH 0
INDEX MODE # ADVANCE THE PUSHDOWN POINTER APPRO-
CAF NO.WDS # PRIATELY.
ADS PUSHLOC
CCS MODE
TCF ENDTPUSH
TCF ENDDPUSH
TS MODE # NOW DP.
ENDVPUSH TS MPAC +2
DXCH MPAC +3 # PUSH DOWN THE REST OF THE VECTOR HERE.
INDEX PUSHLOC
DXCH 0 -4
DXCH MPAC +5
INDEX PUSHLOC
DXCH 0 -2
TCF DANZIG
ENDDPUSH TS MPAC +2 # SET MPAC +2 TO ZERO AND EXIT ON DP.
TCF DANZIG
ENDTPUSH TS MODE
XCH MPAC +2 # ON TRIPLE, SET MPAC +2 TO ZERO, PUSHING
+2 INDEX PUSHLOC # DOWN THE OLD CONTENTS
TS 0 -1
TCF DANZIG
# Page 1126
# PDVL -- PUSHDOWN AND VECTOR LOAD
PDVL EXTEND # RELOAD MPAC AND PUSH DOWN ITS CONTENTS.
INDEX ADDRWD
DCA 0
DXCH MPAC
INDEX PUSHLOC
DXCH 0
INDEX MODE # ADVANCE THE PUSHDOWN POINTER.
CAF NO.WDS
ADS PUSHLOC
CCS MODE # TEST PAST MODE.
TCF TPDVL
TCF ENDVLOAD # JUST LOAD LAST FOUR REGISTERS ON DP.
VPDVL EXTEND # PUSHDOWN AND RE-LOAD LAST TWO COMPONENTS
INDEX ADDRWD
DCA 2
DXCH MPAC +3
INDEX PUSHLOC
DXCH 0 -4
EXTEND
INDEX ADDRWD
DCA 4
DXCH MPAC +5
INDEX PUSHLOC
DXCH 0 -2
TCF DANZIG
TPDVL EXTEND # ON TP, WE MUST LOAD THE Y COMPONENT
INDEX ADDRWD # BEFORE STORING MPAC +2 IN CASE THIS IS A
DCA 2 # PUSHUP.
DXCH MPAC +3
CA MPAC +2
INDEX PUSHLOC # IN DP.
TS 0 -1
TCF ENDVLOAD +4
# SSP (STORE SINGLE PRECISION) IS EXECUTED HERE.
SSP INCR LOC # PICK UP THE WORD FOLLOWING THE GIVEN
INDEX LOC # ADDRESS AND STORE IT AT X.
CA 0
STORE1 INDEX ADDRWD # SOME INDEX AND MISCELLANEOUS OPS END
TS 0 # HERE.
# Page 1127
TCF DANZIG
# Page 1128
# SEQUENCE CHANGING AND SUBROUTINE CALLING OPTIONS.
#
# THE FOLLOWING OPERATIONS ARE AVAILABLE FOR SEQUENCING CHANGING, BRANCHING, AND CALLING SUBROUTINES:
# 1. GOTO GO TO.
# 2. CALL CALL SUBROUTINE SETTING QPRET.
# 3. CGOTO COMPUTED GO TO.
# 4. CCALL COMPUTED CALL.
# 7. BPL BRANCH IF MPAC POSITIVE OR ZERO.
# 8. BZE BRANCH IF MPAC ZERO.
# 9. BMN BRANCH IF MPAC NEGATIVE NON-ZERO.
CCALL INCR LOC # MAINTAIN LOC FOR QPRET COMPUTATION
INDEX LOC
# Was CAF --- RSB 2009.
CA 0 # GET BASE ADDRESS OF CADR LIST.
INDEX ADDRWD
AD 0 # ADD INCREMENT.
TS FBANK # SELECT DESIRED CADR.
MASK LOW10
INDEX A
CAF 10000
TS POLISH
CALL CA BANKSET # FOR ANY OF THE CALL OPTIONS, MAKE UP THE
MASK BANKMASK # ADDRESS OF THE NEXT OP-CODE PAIR/STORE
AD BANKMASK # CODE AND LEAVE IT IN QPRET. NOTE THAT
AD LOC # BANKMASK = -(2000 - 1).
INDEX FIXLOC
TS QPRET
GOTO CA POLISH # BASIC BRANCHING SEQUENCE.
+1 MASK HIGH4
EXTEND
BZF GOTOERS # SEE IF ADDRESS POINTS TO FIXED OR ERAS.
+4 CA BANKSET # SET EBANK PART OF BBANK. NEXT, SET UP
TS BBANK # FBANK. THE COMBINATION IS PICKED UP &
CA POLISH # PUT INTO BANKSET AT INTPRET +2.
TS FBANK
MASK LOW10
AD 2K
TS LOC
TCF INTPRET +3
EBANK= 1400 # SO YUL DOESN'T CUSS THE "CA 1400" BELOW.
GOTOERS CA POLISH # THE GIVEN ADDRESS IS IN ERASABLE -- SEE
AD -ENDVAC # IF RELATIVE TO THE WORK ARA.
CCS A
CA POLISH # GENERAL ERASABLE.
TCF GOTOGE
# Page 1129
CA FIXLOC # WORK AREA.
AD POLISH
INDEX A # USE THE GIVEN ADDRESS AS THE ADDRESS OF
CA 0 # THE BRANCH ADDRESS.
TS POLISH
TCF GOTO +1 # ALLOWS ARBITRARY INDIRECTNESS LEVELS.
GOTOGE TS EBANK
MASK LOW8
INDEX A # USE THE GIVEN ADDRESS AS THE ADDRESS OF
CA 1400 # THE BRANCH ADDRESS.
TS POLISH
TCF GOTO +1
CGOTO INDEX LOC # COMPUTED GO TO. PICK UP ADDRESS OF CADR
CA 1 # LIST
INDEX ADDRWD # ADD MODIFIER.
AD 0
TS FBANK # SELECT GOTO ADDRESS
MASK LOW10
INDEX A
CA 10000
TS POLISH
TCF GOTO +1 # WITH ADDRESS IN A.
SWBRANCH CA BANKSET # SWITCH INSTRUCTIONS WHICH ELECT TO
TS FBANK # BRANCH COME HERE TO DO SO.
INDEX LOC
CA 1
TS POLISH
TCF GOTO +1
# Page 1130
# TRIPLE PRECISION BRANCHING ROUTINE. IF CALLING TC IS AT L, RETURN IS AS FOLLOWS:
# L+1 IF MPAC IS GREATER THAN ZERO.
# L+2 IF MPAC IS EQUAL TO +0 OR -0.
# L+3 IF MPAC IS LESS THAN ZERO.
BRANCH CCS MPAC
TC Q
TCF +2 # ON ZERO.
TCF NEG
CCS MPAC +1
TC Q
TCF +2
TCF NEG
CCS MPAC +2
TC Q
TCF +2
TCF NEG
Q+1 INDEX Q
TC 1
NEG INDEX Q # IF FIRST NON-ZERO REGISTER WAS NEGATIVE.
TC 2
Q+2 = NEG
# ITRACE (3) REFERS TO "EXIT".
EXIT CA BANKSET # RESTORE USER'S BANK SETTING, AND LEAVE
TS BBANK # INTERPRETIVE MODE.
INDEX LOC
TC 1
# Page 1131
# SECTION 3 -- ADD/SUBTRACT PACKAGE.
#
# THE FOLLOWING OPERATIONS ARE PROVIDED FOR ADDING TO AND SUBTRACTING FROM THE MULTI-PURPOSE ACCUMULATOR
# MPAC:
# 1. DAD DOUBLE PRECISION ADD.
# 2. DSU DOUBLE PRECISION SUBTRACT.
# 3. BDSU DOUBLE PRECISION SUBTRACT FROM.
# 4. TAD TRIPLE PRECISION ADD.
# 5. VAD VECTOR ADD.
# 6. VSU VECTOR SUBTRACT.
# 7. BVSU VECTOR SUBTRACT FROM.
# THE INTERPRETIVE OVERFLOW INDICATOR OVFIND IS SET NON-ZERO IF OVERFLOW OCCURS IN ANY OF THE ABOVE.
VSU CAF BIT15 # CHANGES 0 TO DCS.
TCF +2
VAD CAF PRIO30 # CHANGES 0 TO DCA.
ADS ADDRWD
EXTEND
INDEX ADDRWD
READ HISCALAR # DCA 2 OR DCS 2
DAS MPAC +3
EXTEND # CHECK OVERFLOW.
BZF +2
TC OVERFLWY
EXTEND
INDEX ADDRWD
READ CHAN5 # DCA 4 OR DCS 4
DAS MPAC +5
EXTEND
BZF +2
TC OVERFLWZ
EXTEND
INDEX ADDRWD
READ LCHAN # DCA 0 OR DCS 0
TCF ENDVXV
DAD EXTEND
INDEX ADDRWD
DCA 0
ENDVXV DAS MPAC # VXV FINISHES HERE.
EXTEND
BZF DANZIG
# Page 1132
SETOVF TC OVERFLOW
TCF DANZIG
# Page 1133
DSU EXTEND
INDEX ADDRWD
DCS 0
TCF ENDVXV
OVERFLWZ TS L # ENTRY FOR THIRD COMPONENT.
CAF FIVE
TCF +3
OVERFLWY TS L # ENTRY FOR SECOND COMPONENT.
CAF THREE
XCH L
OVERFLOW INDEX A # ENTRY FOR 1ST COMP OR DP (L=0).
CS LIMITS # PICK UP POSMAX OR NEGMAX.
TS BUF
EXTEND
AUG A
INDEX L
ADS MPAC +1
TS 7
CAF ZERO
AD BUF
INDEX L
ADS MPAC
TS 7
TC Q # NO OVERFLOW EXIT.
TCF SETOVF2 # SET OVFIND AND EXIT.
BVSU EXTEND
INDEX ADDRWD
DCA 2
DXCH MPAC +3
EXTEND
DCOM
DAS MPAC +3
EXTEND
BZF +2
TC OVERFLWY
EXTEND
INDEX ADDRWD
DCA 4
DXCH MPAC +5
EXTEND
DCOM
DAS MPAC +5
EXTEND
BZF +2
TC OVERFLWZ
# Page 1134
BDSU EXTEND
INDEX ADDRWD
DCA 0
DXCH MPAC
EXTEND
DCOM
TCF ENDVXV
# Page 1135
# TRIPLE PRECISION ADD ROUTINE.
TAD EXTEND
INDEX ADDRWD
DCA 1 # ADD MINOR PARTS FIRST.
DAS MPAC +1
INDEX ADDRWD
AD 0
AD MPAC
TS MPAC
TCF DANZIG
TCF SETOVF # SET OVFIND IF SUCH OCCURS.
# Page 1136
# ARITHMETIC SUBROUTINES REQUIRED IN FIXED-FIXED.
# 1. DMPSUB DOUBLE PRECISION MULTIPLY, MULTIPLY THE CONTENTS OF MPAC,+1 BY THE DP WORD WHOSE ADDRESS
# IS IN ADDRWD AND LEAVE A TRIPLE-PRECISION RESULT IN MPAC.
# 2. ROUNDSUB ROUND THE TRIPLE PRECISION CONTENTS OF MPAC TO DOUBLE PRECISION.
# 3. DOTSUB TAKE THE DOT PRODUCT OF THE VECTOR IN MPAC AND THE VECTOR WHOSE ADDRESS IS IN ADDRWD
# AND LEAVE THE TRIPLE PRECISION RESULT IN MPAC.
# 4. POLY USING THE CONTENTS OF MPAC AS A DP ARGUMENT, EVALUATE THE POLYNOMIAL WHOSE DEGREE AND
# COEFFICIENTS IMMEDIATELY FOLLOW THE TC POLY INSTRUCTION (SEE ROUTINE FOR DETAILS).
DMP INDEX Q # BASIC SUBROUTINE FOR USE BY PINBALL, ETC
# Was CAF --- RSB 2009.
CA 0
INCR Q
-1 TS ADDRWD # (PROLOGUE FOR SETTING ADDRWD.)
DMPSUB INDEX ADDRWD # GET MINOR PART OF OPERAND AT C(ADDRWD).
CA 1
TS MPAC +2 # THIS WORKS FOR SQUARING MPAC AS WELL.
CAF ZERO # SET MPAC +1 TO ZERO SO WE CAN ACCUMULATE
XCH MPAC +1 # THE PARTIAL PRODUCTS WITH DAS
TS MPTEMP # INSTRUCTIONS.
EXTEND
MP MPAC +2 # MINOR OF MPAC X MINOR OF C(ADDRWD).
XCH MPAC +2 # DISCARD MINOR PART OF ABOVE RESULT AND
EXTEND # FORM MAJOR OF MPAC X MINOR OF C(ADDRWD).
MP MPAC
DAS MPAC +1 # GUARANTEED NO OVERFLOW.
INDEX ADDRWD # GET MAJOR PART OF ARGUMENT AT C(ADDRWD).
CA 0
XCH MPTEMP # SAVE AND BRING OUT MINOR OF MPAC.
DMPSUB2 EXTEND
MP MPTEMP # MAJOR OF C(ADDRWD) X MINOR OF MPAC.
DAS MPAC +1 # ACCUMULATE, SETTING A TO NET OVERFLOW.
XCH MPAC # SETTING MPAC TO 0 OR +-1.
EXTEND
MP MPTEMP # MAJOR OF MPAC X MAJOR OF C(ADDRWD).
DAS MPAC # GUARANTEED NO OVERFLOW.
TC Q # 49 MCT = .573 MS. INCLUDING RETURN.
# Page 1137
# ROUND MPAC TO DOUBLE PRECISION, SETTING OVFIND ON THE RARE EVENT OF OVERFLOW.
ROUNDSUB CAF ZERO # SET MPAC +2 = 0 FOR SCALARS AND CHANGE
+1 TS MODE # MODE TO DP.
VROUND XCH MPAC +2 # BUT WE NEEDN'T TAKE THE TIME FOR VECTORS.
DOUBLE
TS L
TC Q
AD MPAC +1 # ADD ROUDING BIT IF MPAC +2 WAS GREATER
TS MPAC +1 # THAN .5 IN MAGNITUDE.
TC Q
AD MPAC # PROPAGATE INTERFLOW.
TS MPAC
TC Q
SETOVF2 TS OVFIND # (RARE).
TC Q
# Page 1138
# THE DOT PRODUCT SUBROUTINE USUALLY FORMS THE DOT PRODUCT OF THE VECTOR IN MPAC WITH A STANDARD SIX
# REGISTER VECTOR WHOSE ADDRESS IS IN ADDRWD. IN THIS CASE C(DOTINC) ARE SET TO 2. VXM, HOWEVER, SETS C(DOTINC) TO
# 6 SO THAT DOTSUB DOTS MPAC WITH A COLUMN VECTOR OF THE MATRIX IN QUESTION IN THIS CASE.
PREDOT CAF TWO # PROLOGUE TO SET DOTINC TO 2.
TS DOTINC
DOTSUB EXTEND
QXCH DOTRET # SAVE RETURN
TC DMPSUB # DOT X COMPONENTS.
DXCH MPAC +3 # POSITION Y COMPONENT OF MPAC FOR
DXCH MPAC # MULTIPLICATION WHILE SAVING RESULT IN
DXCH BUF # THREE WORD BUFFER, BUF.
CA MPAC +2
TS BUF +2
CA DOTINC # ADVANCE ADDRWD TO Y COMPONENT OF
ADS ADDRWD # OTHER ARGUMENT.
TC DMPSUB
DXCH MPAC +1 # ACCUMULATE PARTIAL PRODUCTS.
DAS BUF +1
AD MPAC
AD BUF
TS BUF
TCF +2
TS OVFIND # IF OVERFLOW OCCURS.
DXCH MPAC +5 # MULTIPLY Z COMPONENTS.
DXCH MPAC
CA DOTINC
ADS ADDRWD
TC DMPSUB
ENDDOT DXCH BUF +1 # LEAVE FINAL ACCUMULATION IN MPAC.
DAS MPAC +1
AD MPAC
AD BUF
TS MPAC
TC DOTRET
TC OVERFLOW # ON OVERFLOW HERE.
TC DOTRET
# Page 1139
# DOUBLE PRECISION POLYNOMIAL EVALUATOR
# N N-1