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:
  • B1 — Revision 292
  • B2 — Revision 302
  • B3 — Revision 302
  • B4 — Revision 302
  • B5 — Revision 292
  • B6 — Revision 306
This means that source code does not represent a specific historical revision of Sundance, but rather a mixture of the three released versions. Nonetheless, it is capable of flying the whole Apollo 9 mission. This source code matches the binary dumps, as closely as feasible, but 100% match is not possible, due mostly to changes in memory addresses at which code and variables were allocated in different revisions of Sundance. Refer to this list of explanations for each binary mismatch.

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.

059708,000002:                                                                                                  ## Copyright:   Public domain.
059709,000003:                                                                                                  ## Filename:    SPS_BACK-UP_RCS_CONTROL.agc
059710,000004:                                                                                                  ## Purpose:     A section of a reconstructed, mixed version of Sundance
059711,000005:                                                                                                  ##              It is part of the reconstructed source code for the Lunar
059712,000006:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
059713,000007:                                                                                                  ##              No original listings of this program are available;
059714,000008:                                                                                                  ##              instead, this file was created via disassembly of dumps
059715,000009:                                                                                                  ##              of various revisions of Sundance core rope modules.
059716,000010:                                                                                                  ## Assembler:   yaYUL
059717,000011:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
059718,000012:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
059719,000013:                                                                                                  ## Mod history: 2020-06-17 MAS  Created from Luminary 69.
059720,000014: 
059721,000015:                                                                                                  ## Sundance 302
059722,000016: 
059723,000017:                                                                                                  #  PROGRAM NAME:  SPSRCS
059724,000018: 
059725,000019:                                                                                                  #  AUTHOR:  EDGAR M. OSHIKA (AC ELECTRONICS)
059726,000020: 
059727,000021:                                                                                                  #  MODIFIED:  TO RETURN TO ALL AXES VIA Q BY P. S. WEISSMAN, OCT 7, 1968
059728,000022: 
059729,000023:                                                                                                  #  FUNCTIONAL DESCRIPTION:
059730,000024: 
059731,000025:                                                                                                  #  THIS PROGRAM CONTROLS THE FIRING OF ALL RCS JETS IN THE DOCKED CONFIGURATION ACCORDING TO THE FOLLOWING PHASE
059732,000026:                                                                                                  #  PLANE LOGIC.
059733,000027: 
059734,000028:                                                                                                  #  1.  OUTER RATE LIMIT (SPSRCS)
059735,000029: 
059736,000030:                                                                                                  #  IF MAGNITUDE OF EDOT IS GREATER THAN 1.73 DEG/SEC SET JET FIRING TIME, TJ, TO REDUCE RATE AND THEN RETURN TO
059737,000031:                                                                                                  #  CALLING PROGRAM (REQUESTING 4 JETS FOR P-AXIS).
059738,000032:                                                                                                  #  OTHERWISE, CONTINUE.
059739,000033: 
059740,000034:                                                                                                  #  2.  RATE DEAD BAND TEST ( JTONTEST)
059741,000035: 
059742,000036:                                                                                                  #  IF JETS ARE FIRING NEGATIVE AND RATE IS GREATER THAN -0.101 DEG/SEC, LEAVE JETS ON AND RETURN,
059743,000037:                                                                                                  #  IF JETS ARE FIRING POSITIVE AND RATE IS LESS THAN +0.101 DEG/SEC, LEAVE JETS ON AND RETURN, OTHERWISE CONTINUE.
059744,000038: 
059745,000039:                                                                                                  #  3.  COASTING TEST (SPSSTART)
059746,000040: 
059747,000041:                                                                                                  #  IF STATE (E,EDOT) IS BELOW LINE  E + 4 X EDOT > -1.4 DEG  AND EDOT IS LESS THAN 1.30 DEG/SEC SET JET TIME POSI-
059748,000042:                                                                                                  #  TIVE AND RETURN,
059749,000043:                                                                                                  #  IF STATE IS ABOVE LINE E + 4 X EDOT > +1.4 DEG AND EDOT IS GREATER THAN -1.30 DEG/SEC, SET JET TIME NEGATIVE
059750,000044:                                                                                                  #  AND RETURN,
059751,000045:                                                                                                  #  OTHERWISE, SET JET TIME ZERO AND RETURN.
059752,000046: 
059753,000047:                                                                                                  #  THE MINIMUM PULSE WIDTH OF THIS CONTROLLER IS DETERMINED BY THE REPETITION  RATE AT WHICH THIS ROUTINE IS CALLED
059754,000048:                                                                                                  #  AND IS NOMINALLY 100 MS FOR ALL AXES IN DRIFTING FLIGHT.   DURING POWERED FLIGHT THE MINIMUM IS 100 MS FOR THE
059755,000049:                                                                                                  #  P AXIS AND 200 MS FOR THE CONTROL OF THE U AND V AXES.
059756,000050: 
059757,000051:                                                                                                  #  CALLING SEQUENCE:
059758,000052: 
059759,000053:                                                                                                  #           TC     SPSRCS          FROM Q,R AXES RCS AUTOPILOT
059760,000054:                                                                                                  #                      INHINT                  FROM P-AXIS RCS AUTOPILOT
059761,000055:                                                                                                  #                      TC      IBNKCALL
059762,000056:                                                                                                  #                      CADR    SPSRCS
059763,000057: 
059764,000058: 
059765,000059:                                                                                                  #  EXIT:
059766,000060: 
059767,000061:                                                                                                  #           TC     Q
059768,000062:                                                                                                  #  ALARM/ABORT MODE:    NONE
059769,000063: 
059770,000064:                                                                                                  #  SUBROUTINES CALLED:    NONE
059771,000065: 
059772,000066:                                                                                                  #  INPUT:      E, EDOT
059773,000067: 
059774,000068:                                                                                                  #             TJP, TJV, TJU           TJ MUST NOT BE NEGATIVE ZERO
059775,000069: 
059776,000070:                                                                                                  #  OUTPUT:    TJP, TJV, TJU
059777,000071:                                                                                                  #             NUMBERT = 6,            WHEN RATE LIMITING P AXIS.
059778,000072: 
059779,000073: 
059780,000074: 17,3526                                           BANK     17                                    
059781,000075: 17,2000                                           SETLOC   DAPS2                                 
059782,000076: 17,2000                                           BANK                                           
059783,000077: 
059784,000078: 17,3526                                           COUNT*   $$/DAPBU                              
059785,000079: 
059786,000080: 17,3526  E6,1517                                  EBANK=   TJU                                   
059787,000081: 17,3526           31543        SPSRCS             CA       EDOT                                  
059788,000082: 17,3527           00006                           EXTEND                                         
059789,000083: 17,3530           75036                           MP       RATELIM1                              #  OUTER RATE LIMIT = 1.73 DEG/SEC
059790,000084: 17,3531           00006                           EXTEND                                         
059791,000085: 17,3532           13563                           BZF      JTONTEST                              
059792,000086: 
059793,000087: 17,3533           54001                           TS       L                                     
059794,000088: 17,3534           36216                           CA       SIX                                   
059795,000089: 17,3535           55740                           TS       NUMBERT                               
059796,000090: 17,3536           10001                           CCS      L                                     
059797,000091: 17,3537           13617                           TCF      NEGTHRST                              
059798,000092: 17,3540           05723                           TC       CCSHOLE                               #  **TEMP ** FILL WITH A CONSTANT
059799,000093: 17,3541  17,3512               RATELIM2           =        .1AT4                                 #  = OCT 00632,  1.125 DEG/SEC
059800,000094: 17,3541           35011        POSTHRST           CA       HALF                                  
059801,000095: 
059802,000096: 17,3542           51471                           NDX      AXISCTR                               
059803,000097: 17,3543           55517                           TS       TJU                                   
059804,000098: 17,3544           11471                           CCS      AXISCTR                               
059805,000099: 17,3545           13550                           TCF      +3                                    
059806,000100: 17,3546           13550                           TCF      +2                                    
059807,000101: 17,3547           00002                           TC       Q                                     
059808,000102: 
059809,000103: 17,3550           30101                           CA       FLAGWRD5                              
059810,000104: 17,3551           75012                           MASK     SNUFFBIT                              
059811,000105: 17,3552           00006                           EXTEND                                         
059812,000106: 17,3553           12522                           BZF      AFTERTJ    -2                         
059813,000107: 17,3554           31102                           CA       DAPBOOLS                              
059814,000108: 17,3555           75017                           MASK     DRIFTBIT                              
059815,000109: 17,3556           10000                           CCS      A                                     
059816,000110: 17,3557           12522                           TCF      AFTERTJ    -2                         
059817,000111: 
059818,000112: 17,3560           51471                           NDX      AXISCTR                               
059819,000113: 17,3561           55517                           TS       TJU                                   
059820,000114: 17,3562           12522                           TCF      AFTERTJ    -2                         
059821,000115: 
059822,000116: 17,3563           51471        JTONTEST           NDX      AXISCTR                               
059823,000117: 17,3564           11517                           CCS      TJU                                   
059824,000118: 17,3565           13571                           TCF      +4                                    
059825,000119: 17,3566           13603                           TCF      SPSSTART                              
059826,000120: 17,3567           31543                           CA       EDOT                                  
059827,000121: 17,3570           13572                           TCF      +2                                    
059828,000122: 
059829,000123: 17,3571           41543                 +4        CS       EDOT                                  
059830,000124: 17,3572           22000                           LXCH     A                                     
059831,000125: 17,3573           41102                           CS       DAPBOOLS                              #  IF DRIFTBIT = 1, USE ZERO TARGET RATE
059832,000126: 17,3574           75017                           MASK     DRIFTBIT                              #  IF DRIFTBIT = 0, USE 0.10 RATE TARGET
059833,000127: 17,3575           10000                           CCS      A                                     
059834,000128: 17,3576           35037                           CA       RATEDB1                               
059835,000129: 17,3577           60001                           AD       L                                     
059836,000130: 17,3600           00006                           EXTEND                                         
059837,000131: 17,3601           63603                           BZMF     +2                                    
059838,000132: 17,3602           13544                           TCF      POSTHRST   +3                         
059839,000133: 
059840,000134: 17,3603           31543        SPSSTART           CA       EDOT                                  
059841,000135: 17,3604           61542                           AD       E                                     
059842,000136: 17,3605           00006                           EXTEND                                         
059843,000137: 17,3606           71411                           MP       DKDB                                  #  PAD LOADED DEADBAND. FRESHSTART: 1.4 DEG
059844,000138: 17,3607           00006                           EXTEND                                         
059845,000139: 17,3610           13625                           BZF      TJZERO                                
059846,000140: 
059847,000141: 17,3611           00006                           EXTEND                                         
059848,000142: 17,3612           63621                           BZMF     +7                                    
059849,000143: 17,3613           31543                           CA       EDOT                                  
059850,000144: 17,3614           63512                           AD       RATELIM2                              
059851,000145: 17,3615           00006                           EXTEND                                         
059852,000146: 17,3616           63625                           BZMF     TJZERO                                
059853,000147: 17,3617           45011        NEGTHRST           CS       HALF                                  
059854,000148: 17,3620           13542                           TCF      POSTHRST   +1                         
059855,000149: 17,3621           43512                 +7        CS       RATELIM2                              
059856,000150: 17,3622           61543                           AD       EDOT                                  
059857,000151: 17,3623           00006                           EXTEND                                         
059858,000152: 17,3624           63541                           BZMF     POSTHRST                              
059859,000153: 17,3625           35030        TJZERO             CA       ZERO                                  
059860,000154: 17,3626           13542                           TCF      POSTHRST   +1                         
059861,000155: 
059862,000156: 
059863,000157: 17,3627     5036               RATELIM1           =        CALLCODE                              #  = 00032, CORRESPONDING TO 1.73 DEG/SEC
059864,000158: 17,3627     5037               RATEDB1            =        TBUILDFX                              #   = 00045, CORRESPONDS TO 0.101 DEG/SEC

End of include-file SPS_BACK-UP_RCS_CONTROL.agc.  Parent file is MAIN.agc