Source Code
These source code files are a reconstruction of Sundance, the Apollo 9 LM (Lunar Module) AGC
(Apollo Guidance Computer) flight software, created from binary dumps of original core rope
program modules, as follows:
Since only binary dumps (rather than listings) of Sundance are available as source material, all comments and labels are approximate. They have been taken from other AGC programs where possible, or, in some places, written from scratch to match what we believe would have been in the original listing. |
048868,000002: ## Copyright: Public domain.
048869,000003: ## Filename: POWERED_FLIGHT_SUBROUTINES.agc
048870,000004: ## Purpose: A section of a reconstructed, mixed version of Sundance
048871,000005: ## It is part of the reconstructed source code for the Lunar
048872,000006: ## Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
048873,000007: ## No original listings of this program are available;
048874,000008: ## instead, this file was created via disassembly of dumps
048875,000009: ## of various revisions of Sundance core rope modules.
048876,000010: ## Assembler: yaYUL
048877,000011: ## Contact: Ron Burkey <info@sandroid.org>.
048878,000012: ## Website: www.ibiblio.org/apollo/index.html
048879,000013: ## Mod history: 2020-06-17 MAS Created from Luminary 69.
048880,000014: ## 2021-05-30 ABS SINSLOC -> SINESLOC
048881,000015:
048882,000016: ## Sundance 302
048883,000017:
048884,000018: 14,3375 BANK 14 # SAME FBANK AS THE FINDCDUD SUB-PROGRAM
048885,000019: 23,2000 SETLOC POWFLITE
048886,000020: 23,2000 BANK
048887,000021:
048888,000022: 23,3251 0142 EBANK= DEXDEX
048889,000023: 23,3251 COUNT* $$/POWFL
048890,000024:
048891,000025: # CDUTRIG, CDUTRIG1, CDUTRIG2, AND CD*TR*GS ALL COMPUTE THE SINES AND
048892,000026: # COSINES OF THREE 2'S COMPLEMENT ANGLES AND PLACE THE RESULT, DOUBLE
048893,000027: # PRECISION, IN THE SAME ORDER AS THE INPUTS, AT SINCDU AND COSCDU. AN
048894,000028: # ADDITIONAL OUTPUT IS THE 1'S COMPLEMENT ANGLES AT CDUSPOT. THESE
048895,000029: # ROUTINES GO OUT OF THEIR WAY TO LEAVE THE MPAC AREA AS THEY FIND IT,
048896,000030: # EXCEPT FOR THE GENERALLY UNIMPORTANT MPAC +2. THEY DIFFER ONLY IN
048897,000031: # WHERE THEY GET THE ANGLES, AND IN METHOD OF CALLING.
048898,000032:
048899,000033: # CDUTRIG (AND CDUTRIG1, WHICH CAN BE CALLED IN BASIC) COMPUTE THE
048900,000034: # SINES AND COSINES FROM THE CURRENT CONTENTS OF THE CDU REGISTERS.
048901,000035: # THE CONTENTS OF CDUTEMP, ETC., ARE NOT TOUCHED SO THAT THEY MAY
048902,000036: # CONTINUE TO FORM A CONSISTENT SET WITH THE LATEST PIPA READINGS.
048903,000037:
048904,000038: # CDUTRIG1 IS LIKE CDUTRIG EXCEPT THAT IT CAN BE CALLED IN BASIC.
048905,000039:
048906,000040: # CD*TR*GS FINDS CDU VALUES IN CDUSPOT RATHER THAN IN CDUTEMP. THIS
048907,000041: # ALLOWS USERS TO MAKE TRANSFORMATIONS USING ARBITRARY ANGLES, OR REAL
048908,000042: # ANGLES IN AN ORDER OTHER THAN X Y Z. A CALL TO THIS ROUTINE IS
048909,000043: # NECESSARY IN PREPARATION FOR A CALL TO AX*SR*T IN EITHER OF ITS TWO
048910,000044: # MODES (SMNB OR NBSM). SINCE AX*SR*T EXPECTS TO FIND THE SINES AND
048911,000045: # COSINES IN THE ORDER Y Z X THE ANGLES MUST HAVE BEEN PLACED IN CDUSPOT
048912,000046: # IN THIS ORDER. CD*TR*GS NEED NOT BE REPEATED WHEN AX*SR*T IS CALLED
048913,000047: # MORE THAN ONCE, PROVIDED THE ANGLES HAVE NOT CHANGED. NOTE THAT SINCE
048914,000048: # IT CLOBBERS BUF2 (IN THE SINE AND COSINE ROUTINES) CD*TR*GS CANNOT BE
048915,000049: # CALLED USING BANKCALL. SORRY.
048916,000050:
048917,000051: # CD*TR*G IS LIKE CD*TR*GS EXCEPT THAT IT CAN BE CALLED IN
048918,000052: # INTERPRETIVE.
048919,000053:
048920,000054: 23,3251 77776 CDUTRIG EXIT
048921,000055: 23,3252 03261 TC CDUTRIGS
048922,000056: 23,3253 06014 TC INTPRET
048923,000057: 23,3254 77616 RVQ
048924,000058:
048925,000059: 23,3255 77776 CD*TR*G EXIT
048926,000060: 23,3256 03267 TC CD*TR*GS
048927,000061: 23,3257 06014 TC INTPRET
048928,000062: 23,3260 77616 RVQ
048929,000063:
048930,000064: 23,3261 30032 CDUTRIGS CA CDUX
048931,000065: 23,3262 54772 TS CDUSPOT +4
048932,000066: 23,3263 30033 CA CDUY
048933,000067: 23,3264 54766 TS CDUSPOT
048934,000068: 23,3265 30034 CA CDUZ
048935,000069: 23,3266 54770 TS CDUSPOT +2
048936,000070:
048937,000071: 23,3267 00006 CD*TR*GS EXTEND
048938,000072: 23,3270 22142 QXCH TEM2
048939,000073: 23,3271 35024 CAF FOUR
048940,000074: 23,3272 76216 TR*GL**P MASK SIX # MAKE IT EVEN AND SMALLER
048941,000075: 23,3273 54143 TS TEM3
048942,000076: 23,3274 50143 INDEX TEM3
048943,000077: 23,3275 30766 CA CDUSPOT
048944,000078: 23,3276 52155 DXCH MPAC # STORING 2'S COMP ANGLE, LOADING MPAC
048945,000079: 23,3277 52127 DXCH VBUF +4 # STORING MPAC FOR LATER RESTORATION
048946,000080: 23,3300 04766 TC USPRCADR
048947,000081: 23,3301 21457 CADR CDULOGIC
048948,000082: 23,3302 00006 EXTEND
048949,000083: 23,3303 30155 DCA MPAC
048950,000084: 23,3304 50143 INDEX TEM3
048951,000085: 23,3305 52767 DXCH CDUSPOT # STORING 1'S COMPLEMENT ANGLE
048952,000086: 23,3306 04766 TC USPRCADR
048953,000087: 23,3307 01516 CADR COSINE
048954,000088: 23,3310 52155 DXCH MPAC
048955,000089: 23,3311 50143 INDEX TEM3
048956,000090: 23,3312 52745 DXCH COSCDU # STORING COSINE
048957,000091: 23,3313 00006 EXTEND
048958,000092: 23,3314 50143 INDEX TEM3
048959,000093: 23,3315 30767 DCA CDUSPOT # LOADING 1'S COMPLEMENT ANGLE
048960,000094: 23,3316 04766 TC USPRCADR
048961,000095: 23,3317 01530 CADR SINE +1 # SINE +1 EXPECTS ARGUMENT IN A AND L
048962,000096: 23,3320 52127 DXCH VBUF +4 # BRINGING UP PRIOR MPAC TO BE RESTORED
048963,000097: 23,3321 52155 DXCH MPAC
048964,000098: 23,3322 50143 INDEX TEM3
048965,000099: 23,3323 52737 DXCH SINCDU
048966,000100: 23,3324 10143 CCS TEM3
048967,000101: 23,3325 13272 TCF TR*GL**P
048968,000102: 23,3326 00142 TC TEM2
048969,000103: # ****************************************************************************************************************
048970,000104: # QUICTRIG, INTENDED FOR GUIDANCE CYCLE USE WHERE TIME IS CRITICAL, IS A MUCH FASTER VERSION OF CD*TR*GS.
048971,000105: # QUICTRIG COMPUTES AND STORES THE SINES AND COSINES OF THE 2'S COMPLEMENT ANGLES AT CDUSPOT, CDUSPOT +2,
048972,000106: # AND CDUSPOT +4. UNLIKE CD*TR*GS, QUICTRIG DOES NOT LEAVE THE 1'S COMPLEMENT VERSIONS OF THE ANGLES IN
048973,000107: # CDUSPOT. QUICTRIG'S EXECUTION TIME IS 4.1 MS; THIS IS 10 TIMES AS FAST AS CD*TR*GS. QUICTRIG MAY BE
048974,000108: # CALLED FROM INTERPRETIVE AS AN RTB OP-CODE, OR FROM BASIC VIA BANKCALL OR IBNKCALL.
048975,000109:
048976,000110: 23,3327 00006 QUICTRIG EXTEND
048977,000111: 23,3330 22142 QXCH TEM2
048978,000112: 23,3331 35024 CAF FOUR
048979,000113: 23,3332 76216 +4 MASK SIX
048980,000114: 23,3333 54143 TS TEM3
048981,000115: 23,3334 50143 INDEX TEM3
048982,000116: 23,3335 30766 CA CDUSPOT
048983,000117: 23,3336 05103 TC SPSIN
048984,000118: 23,3337 00006 EXTEND
048985,000119: 23,3340 75011 MP BIT14 # SCALE DOWN TO MATCH INTERPRETER OUTPUTS
048986,000120: 23,3341 50143 INDEX TEM3
048987,000121: 23,3342 52737 DXCH SINCDU
048988,000122: 23,3343 50143 INDEX TEM3
048989,000123: 23,3344 30766 CA CDUSPOT
048990,000124: 23,3345 05102 TC SPCOS
048991,000125: 23,3346 00006 EXTEND
048992,000126: 23,3347 75011 MP BIT14
048993,000127: 23,3350 50143 INDEX TEM3
048994,000128: 23,3351 52745 DXCH COSCDU
048995,000129: 23,3352 10143 CCS TEM3
048996,000130: 23,3353 13332 TCF QUICTRIG +3
048997,000131: 23,3354 00142 TC TEM2
048998,000132:
048999,000133: # ****************************************************************************************************************
049000,000134: # THESE INTERFACE ROUTINES MAKE IT POSSIBLE TO CALL AX*SR*T, ETC., IN
049001,000135: # INTERPRETIVE. LATER, WHERE POSSIBLE, THEY WILL BE ELIMINATED.
049002,000136:
049003,000137: # NBSM WILL BE THE FIRST TO GO. IT SHOULD NOT BE USED.
049004,000138:
049005,000139: 23,3355 77620 NBSM STQ
049006,000140: 23,3356 00047 X2
049007,000141: 23,3357 76740 LXC,1 VLOAD*
049008,000142: 23,3360 00050 S1 # BASE ADDRESS OF THE CDU ANGLES IS IN S1
049009,000143: 23,3361 00001 0,1
049010,000144: 23,3362 24767 STOVL CDUSPOT
049011,000145: 23,3363 00041 32D # VECTOR TO BE TRANSFORMED IS IN 32D
049012,000146: 23,3364 77624 CALL
049013,000147: 23,3365 47406 TRG*NBSM
049014,000148: 23,3366 34041 STCALL 32D # SINCE THERE'S NO STGOTO
049015,000149: 23,3367 00047 X2
049016,000150:
049017,000151: # THESE INTERFACE ROUTINES ARE PERMANENT. ALL RESTORE USER'S EBANK
049018,000152: # SETTING. ALL ARE STRICT INTERPRETIVE SUBROUTINES, CALLED USING "CALL",
049019,000153: # RETURNING VIA QPRET. ALL EXPECT AND RETURN THE VECTOR TO BE TRANSFOR-
049020,000154: # MED INTERPRETER-STYLE IN MPAC; COMPONENTS AT MPAC, MPAC +3, AND MPAC +5.
049021,000155:
049022,000156: # TRG*SMNB AND TRG*NBSM BOTH EXPECT TO SEE THE 2'S COMPLEMENT ANGLES
049023,000157: # AT CDUSPOT (ORDER Y Z X, AT CDUSPOT, CDUSPOT +2, AND CDUSPOT +4; ODD
049024,000158: # LOCATIONS NEED NOT BE ZEROED). TRG*NBSM DOES THE NB TO SM TRANSFOR-
049025,000159: # MATION; TRG*SMNB, VICE VERSA.
049026,000160:
049027,000161: # CDU*NBSM DOES ITS TRANSFORMATION USING THE PRESENT CONTENTS OF
049028,000162: # THE CDU COUNTERS. OTHERWISE IT IS LIKE TRG*NBSM.
049029,000163:
049030,000164: # CDU*SMNB IS THE COMPLEMENT OF CDU*NBSM.
049031,000165:
049032,000166: 23,3370 77776 CDU*SMNB EXIT
049033,000167: 23,3371 03261 TC CDUTRIGS
049034,000168: 23,3372 13375 TCF C*MM*N1
049035,000169:
049036,000170: 23,3373 77776 TRG*SMNB EXIT
049037,000171: 23,3374 03267 TC CD*TR*GS
049038,000172: 23,3375 07504 C*MM*N1 TC MPACVBUF # AX*SR*T EXPECTS VECTOR IN VBUF
049039,000173: 23,3376 46221 CS THREE # SIGNAL FOR SM TO NB TRANSFORMATION
049040,000174: 23,3377 03417 C*MM*N2 TC AX*SR*T
049041,000175: 23,3400 06014 TC INTPRET
049042,000176: 23,3401 43575 VLOAD RVQ
049043,000177: 23,3402 00123 VBUF
049044,000178:
049045,000179: 23,3403 77776 CDU*NBSM EXIT
049046,000180: 23,3404 03261 TC CDUTRIGS
049047,000181: 23,3405 13410 TCF C*MM*N3
049048,000182:
049049,000183: 23,3406 77776 TRG*NBSM EXIT
049050,000184: 23,3407 03267 TC CD*TR*GS
049051,000185: 23,3410 07504 C*MM*N3 TC MPACVBUF # FOR AX*SR*T
049052,000186: 23,3411 36221 CA THREE # SIGNAL FOR NB TO SM TRANSFORMATION
049053,000187: 23,3412 13377 TCF C*MM*N2
049054,000188:
049055,000189: # *NBSM* AND *SMNB* EXPECT TO SEE THE SINES AND COSINES (AT SINCDU
049056,000190: # AND COSCDU) RATHER THAN THE ANGLES THEMSELVES. OTHERWISE THEY ARE
049057,000191: # LIKE TRG*NBSM AND TRG*SMNB.
049058,000192:
049059,000193: # NOTE THAT JUST AS CD*TR*GS NEED BE CALLED ONLY ONCE FOR EACH SERIES
049060,000194: # OF TRANSFORMATIONS USING THE SAME ANGLES, SO TOO ONLY ONE OF TRG*NBSM
049061,000195: # AND TRG*SMNB NEED BE CALLED FOR EACH SERIES. FOR SUBSEQUENT TRANSFOR-
049062,000196: # MATIONS USE *NBSM* AND *SMNB*.
049063,000197:
049064,000198: 23,3413 77776 *SMNB* EXIT
049065,000199: 23,3414 13375 TCF C*MM*N1
049066,000200:
049067,000201: 23,3415 77776 *NBSM* EXIT
049068,000202: 23,3416 13410 TCF C*MM*N3
049069,000203:
049070,000204: # AX*SR*T COMBINES THE OLD SMNB AND NBSM. FOR THE NB TO SM
049071,000205: # TRANSFORMATION, ENTER WITH +3 IN A. FOR SM TO NB, ENTER WITH -3.
049072,000206: # THE VECTOR TO BE TRANSFORMED ARRIVES, AND IS RETURNED, IN VBUF.
049073,000207: # AX*SR*T EXPECTS TO FIND THE SINES AND COSINES OF THE ANGLES OF ROTATION
049074,000208: # AT SINCDU AND COSCDU, IN THE ORDER Y Z X. A CALL TO CD*TR*GS, WITH
049075,000209: # THE 2'S COMPLEMENT ANGLES (ORDER Y Z X) AT CDUSPOT, WILL TAKE CARE OF
049076,000210: # THIS. HERE IS A SAMPLE CALLING SEQUENCE:-
049077,000211: # TC CDUTRIGS
049078,000212: # CS THREE ("CA THREE" FOR NBSM)
049079,000213: # TC AX*SR*T
049080,000214: # THE CALL TO CD*TR*GS NEED NOT BE REPEATED, WHEN AX*SR*T IS CALLED MORE
049081,000215: # THAN ONCE, UNLESS THE ANGLES HAVE CHANGED.
049082,000216:
049083,000217: # AX*SR*T IS GUARANTEED SAFE ONLY FOR VECTORS OF MAGNITUDE LESS THAN
049084,000218: # UNITY. A LOOK AT THE CASE IN WHICH A VECTOR OF GREATER MAGNITUDE
049085,000219: # HAPPENS TO LIE ALONG AN AXIS OF THE SYSTEM TO WHICH IT IS TO BE TRANS-
049086,000220: # FORMED CONVINCES ONE THAT THIS IS A RESTRICTION WHICH MUST BE ACCEPTED.
049087,000221:
049088,000222: 23,3417 54142 AX*SR*T TS DEXDEX # WHERE IT BECOMES THE INDEX OF INDEXES
049089,000223: 23,3420 00006 EXTEND
049090,000224: 23,3421 22145 QXCH RTNSAVER
049091,000225:
049092,000226: 23,3422 10142 R*TL**P CCS DEXDEX # +3 --> 0 -3 --> 2
049093,000227: 23,3423 40142 CS DEXDEX # THUS: +2 --> 1 -2 --> 1
049094,000228: 23,3424 66221 AD THREE # +1 --> 2 -1 --> 0
049095,000229: 23,3425 00006 EXTEND
049096,000230: 23,3426 50000 INDEX A
049097,000231: 23,3427 33506 DCA INDEXI
049098,000232: 23,3430 52144 DXCH DEXI
049099,000233:
049100,000234: 23,3431 35026 CA ONE
049101,000235: 23,3432 54130 TS BUF
049102,000236: 23,3433 00006 EXTEND
049103,000237: 23,3434 50143 INDEX DEX1
049104,000238: 23,3435 40123 DCS VBUF
049105,000239: 23,3436 13440 TCF LOOP1 # REALLY BE A SUBTRACT, AND VICE VERSA
049106,000240:
049107,000241: 23,3437 52131 LOOP2 DXCH BUF # LOADING VECTOR COMPONENT, STORING INDEX
049108,000242: 23,3440 52155 LOOP1 DXCH MPAC
049109,000243: 23,3441 33504 CA SINESLOC
049110,000244: 23,3442 60143 AD DEX1
049111,000245: 23,3443 54116 TS ADDRWD
049112,000246:
049113,000247: 23,3444 07063 TC DMPSUB # MULTIPLY BY SIN(CDUANGLE)
049114,000248: 23,3445 10142 CCS DEXDEX
049115,000249: 23,3446 52155 DXCH MPAC # NBSM CASE
049116,000250: 23,3447 13452 TCF +3
049117,000251: 23,3450 00006 EXTEND # SMNB CASE
049118,000252: 23,3451 40155 DCS MPAC
049119,000253: 23,3452 52134 DXCH TERM1TMP
049120,000254:
049121,000255: 23,3453 36216 CA SIX # SINCDU AND COSCDU (EACH 6 WORDS) MUST
049122,000256: 23,3454 26116 ADS ADDRWD # BE CONSECUTIVE AND IN THAT ORDER
049123,000257:
049124,000258: 23,3455 00006 EXTEND
049125,000259: 23,3456 50130 INDEX BUF
049126,000260: 23,3457 50143 INDEX DEX1
049127,000261: 23,3460 30123 DCA VBUF
049128,000262: 23,3461 52155 DXCH MPAC
049129,000263: 23,3462 07063 TC DMPSUB # MULTIPLY BY COS(CDUANGLE)
049130,000264: 23,3463 52155 DXCH MPAC
049131,000265: 23,3464 20134 DAS TERM1TMP
049132,000266: 23,3465 52134 DXCH TERM1TMP
049133,000267: 23,3466 20001 DDOUBL
049134,000268: 23,3467 50130 INDEX BUF
049135,000269: 23,3470 50143 INDEX DEX1
049136,000270: 23,3471 52123 DXCH VBUF
049137,000271: 23,3472 52131 DXCH BUF # LOADING INDEX, STORING VECTOR COMPONENT
049138,000272:
049139,000273: 23,3473 10000 CCS A # 'CAUSE THAT'S WHERE THE INDEX NOW IS
049140,000274: 23,3474 13437 TCF LOOP2
049141,000275:
049142,000276: 23,3475 00006 EXTEND
049143,000277: 23,3476 26142 DIM DEXDEX # DECREMENT MAGNITUDE PRESERVING SIGN
049144,000278:
049145,000279: 23,3477 10142 TSTPOINT CCS DEXDEX # ONLY THE BRANCHING FUNCTION IS USED
049146,000280: 23,3500 13422 TCF R*TL**P
049147,000281: 23,3501 00145 TC RTNSAVER
049148,000282: 23,3502 13422 TCF R*TL**P
049149,000283: 23,3503 00145 TC RTNSAVER
049150,000284:
049151,000285: 23,3504 00736 SINESLOC ADRES SINCDU # FOR USE IN SETTING ADDRWD
049152,000286:
049153,000287: 23,3505 00004 INDEXI DEC 4 B-14 # ********** DON'T **********
049154,000288: 23,3506 00002 DEC 2 B-14 # ********** TOUCH **********
049155,000289: 23,3507 00000 DEC 0 B-14 # ********** THESE **********
049156,000290: 23,3510 00004 DEC 4 B-14 # ********** CONSTANTS **********
049157,000291:
049158,000292: # ****************************************************************************************************************
049159,000293: # THIS SUBROUTINE COMPUTES INCREMENTAL CHANGES IN CDU(GIMBAL) ANGLES FROM INCREMENTAL CHANGES ABOUT SM AXES. IT
049160,000294: # REQUIRES SM INCREMENTS AS A DP VECTOR SCALED AT ONE REVOLUTION(DTHETASM,+2,+4). SIN,COS(CDUY,Z,X) ARE IN
049161,000295: # SINCDU,+2,+4 AND COSCDU,+2,+4 RESPECTIVELY,SCALED TO ONE HALF. CDU INCREENTS ARE PLACED IN DCDU,+2,+4 SCALED TO
049162,000296: # ONE REVOLUTION.
049163,000297:
049164,000298: # * COS(IGA)SEC(MGA) 0 -SIN(IGA)SEC(MGA) *
049165,000299: # * *
049166,000300: # * -COS(IGA)TAN(MGA) 1 SIN(IGA)TAN(MGA) *
049167,000301: # * *
049168,000302: # * SIN(IGA) 0 COS(IGA) *
049169,000303:
049170,000304: 14,3375 BANK 14
049171,000305: 23,2000 SETLOC POWFLIT1
049172,000306: 23,2000 BANK
049173,000307: 23,3511 41345 SMCDURES DLOAD DMP
049174,000308: 23,3512 01267 DTHETASM
049175,000309: 23,3513 00745 COSCDUY
049176,000310:
049177,000311: 23,3514 41325 PDDL DMP
049178,000312: 23,3515 01273 DTHETASM +4
049179,000313: 23,3516 00737 SINCDUY
049180,000314:
049181,000315: 23,3517 77621 BDSU
049182,000316: 23,3520 77671 DDV
049183,000317: 23,3521 00747 COSCDUZ
049184,000318: 23,3522 03233 STORE DCDU
049185,000319:
049186,000320: 23,3523 72405 DMP SL1 # SCALE
049187,000321: 23,3524 00741 SINCDUZ
049188,000322: 23,3525 77621 BDSU
049189,000323:
049190,000324: 23,3526 01271 DTHETASM +2
049191,000325: 23,3527 17235 STODL DCDU +2
049192,000326: 23,3530 01267 DTHETASM
049193,000327:
049194,000328: 23,3531 65205 DMP PDDL
049195,000329: 23,3532 00737 SINCDUY
049196,000330: 23,3533 01273 DTHETASM +4
049197,000331:
049198,000332: 23,3534 43205 DMP DAD
049199,000333: 23,3535 00745 COSCDUY
049200,000334: 23,3536 77752 SL1
049201,000335: 23,3537 03237 STORE DCDU +4
049202,000336: 23,3540 77616 RVQ
049203,000337:
End of include-file POWERED_FLIGHT_SUBROUTINES.agc. Parent file is MAIN.agc