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.

006782,000002:                                                                                                  ## Copyright:   Public domain.
006783,000003:                                                                                                  ## Filename:    RCS_FAILURE_MONITOR.agc
006784,000004:                                                                                                  ## Purpose:     A section of a reconstructed, mixed version of Sundance
006785,000005:                                                                                                  ##              It is part of the reconstructed source code for the Lunar
006786,000006:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
006787,000007:                                                                                                  ##              No original listings of this program are available;
006788,000008:                                                                                                  ##              instead, this file was created via disassembly of dumps
006789,000009:                                                                                                  ##              of various revisions of Sundance core rope modules.
006790,000010:                                                                                                  ## Assembler:   yaYUL
006791,000011:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
006792,000012:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
006793,000013:                                                                                                  ## Mod history: 2020-06-17 MAS  Created from Luminary 69.
006794,000014: 
006795,000015:                                                                                                  ## Sundance 302
006796,000016: 
006797,000017:                                                                                                  #  PROGRAM DESCRIPTION
006798,000018: 
006799,000019:                                                                                                  #  AUTHOR:  J S MILLER
006800,000020: 
006801,000021:                                                                                                  #  MODIFIED 6 MARCH 1968 BY P S WEISSMAN TO SET UP JOB FOR 1/ACCS WHEN THE MASKS ARE CHANGED.
006802,000022: 
006803,000023:                                                                                                  #       THIS ROUTINE IS ATTACHED TO T4RUPT, AND IS ENTERED EVERY 480 MS.  ITS FUNCTION IS TO EXAMINE THE LOW 8 BITS
006804,000024:                                                                                                  #  OF CHANNEL 32 TO SEE IF ANY ISOLATION-VALVE CLOSURE BITS HAVE APPEARED OR DISAPPEARED (THE CREW IS WARNED OF JET
006805,000025:                                                                                                  #  FAILURES BY LAMPS LIT BY THE GRUMMAN FAILURE-DETECTION CIRCUITRY; THEY MAY RESPOND BY OPERATING SWITCHES WHICH
006806,000026:                                                                                                  #  ISOLATE PAIRS OF JETS FROM THE PROPELLANT TANKS AND SET BITS IN CHANNEL 32).  IN THE EVENT THAT CHANNEL 32 BITS
006807,000027:                                                                                                  #  DIFFER FROM 'PVALVEST', THE RECORD OF ACTIONS TAKEN BY THIS ROUTINE, THE APPROPRIATE BITS IN 'CH5MASK' &
006808,000028:                                                                                                  #  'CH6MASK', USED BY THE DAP JET-SELECTION LOGIC, ARE UPDATED, AS IS 'PVALVEST'.  TO SPEED UP & SHORTEN THE
006809,000029:                                                                                                  #  ROUTINE, NO MORE THAN ONE CHANGE IS ACCEPTED PER ENTRY.  THE HIGHEST-NUMBERED BIT IN CHANNEL 32 WHICH REQUIRES
006810,000030:                                                                                                  #  ACTION IS THE ONE PROCESSED.
006811,000031: 
006812,000032:                                                                                                  #       THE CODING IN THE FAILURE MONITOR HAS BEEN WRITTEN SO AS TO HAVE ALMOST COMPLETE RESTART PROTECTION.  FOR
006813,000033:                                                                                                  #  EXAMPLE, NO ASSUMPTION IS MADE WHEN SETTING A 'CH5MASK' BIT TO 1 THAT THE PREVIOUS STATE IS 0, ALTHOUGH IT OF
006814,000034:                                                                                                  #  COURSE SHOULD BE.  ONE CASE WHICH MAY BE SEEN TO EVADE PROTECTION IS THE OCCURRENCE OF A RESTART AFTER UPDATING
006815,000035:                                                                                                  #  ONE OR BOTH DAP MASK-WORDS BUT BEFORE UPDATING 'PVALVEST', COUPLED WITH A CHANGE IN THE VALVE-BIT BACK TO ITS
006816,000036:                                                                                                  #  FORMER STATE.  THE CONSEQUENCE OF THIS IS THAT THE NEXT ENTRY WOULD NOT SEE THE CHANGE INCOMPLETELY INCORP-
006817,000037:                                                                                                  #  ORATED BY THE LAST PASS (BECAUSE IT WENT AWAY AT JUST THE RIGHT TIME), BUT THE DAP MASK-WORDS WILL BE INCORRECT.
006818,000038:                                                                                                  #  THIS COMBINATION OF EVENTS SEEMS QUITE REMOTE, BUT NOT IMPOSSIBLE UNLESS THE CREW OPERATES THE SWITCHES AT HALF-
006819,000039:                                                                                                  #  SECOND INTERVALS OR LONGER.  IN ANY EVENT, A DISAGREEMENT BETWEEN REALITY AND THE DAP MASKS WILL BE CURED IF
006820,000040:                                                                                                  #  THE MISINTERPRETED SWITCH IS REVERSED AND THEN RESTORED TO ITS CORRECT POSITION (SLOWLY).
006821,000041: 
006822,000042:                                                                                                  #  CALLING SEQUENCE:
006823,000043: 
006824,000044:                                                                                                  #           TCF    RCSMONIT        (IN INTERRUPT MODE, EVERY 480 MS.)
006825,000045: 
006826,000046:                                                                                                  #  EXIT:  TCF  RCSMONEX  (ALL PATHS EXIT VIA SUCH AN INSTRUCTION)
006827,000047: 06,3153  06,3260               RCSMONEX           EQUALS   STAGEMON                              
006828,000048: 
006829,000049:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED:
006830,000050: 
006831,000051:                                                                                                  #           VIA FRESH START:  PVALVEST          = +0  (ALL JETS ENABLED)
006832,000052:                                                                                                  #                             CH5MASK, CH6MASK  = +0  (ALL JETS OK)
006833,000053: 
006834,000054:                                                                                                  #  OUTPUT:  CH5MASK & CH6MASK UPDATED  (1'S WHERE JETS NOT TO BE USED, IN CHANNEL 5 & 6 FORMAT)
006835,000055:                                                                                                  #           PVALTEST UPDATED  (1,S WHEN VALVE CLOSURES HAVE BEEN TRANSLATED INTO CH5MASK & CH6MASK; CHAN 32 FORMAT)
006836,000056:                                                                                                  #           JOB TO DO 1/ACCS.
006837,000057: 
006838,000058:                                                                                                  #  DEBRIS:  A, L, Q AND DEBRIS OF NOVAC.
006839,000059: 
006840,000060:                                                                                                  #  SUBROUTINE CALLED:  NOVAC.
006841,000061: 
006842,000062: 06,3153     1264                                  EBANK=   CH5MASK                               
006843,000063: 
006844,000064: 23,2000                                           BANK     23                                    
006845,000065: 06,2000                                           SETLOC   RCSMONT                               
006846,000066: 06,2000                                           BANK                                           
006847,000067: 
006848,000068: 06,3153                                           COUNT*   $$/T4RCS                              
006849,000069: 
006850,000070: 06,3153  06,3153               RCSMONIT           EQUALS   RCSMON                                
006851,000071: 
006852,000072: 06,3153           45030        RCSMON             CS       ZERO                                  
006853,000073: 06,3154           00006                           EXTEND                                         
006854,000074: 06,3155           06032                           RXOR     CHAN32                                #  PICK UP + INVERT INVERTED CHANNEL 32.
006855,000075: 06,3156           74371                           MASK     LOW8                                  #  KEEP JET-FAIL BITS ONLY.
006856,000076: 06,3157           54002                           TS       Q                                     
006857,000077: 
006858,000078: 06,3160           41300                           CS       PVALVEST                              #        -   -
006859,000079: 06,3161           70002                           MASK     Q                                     #  FORM PC + PC.
006860,000080: 06,3162           54001                           TS       L                                     #    (P = PREVIOUS ISOLATION VALVE STATE,
006861,000081: 06,3163           40002                           CS       Q                                     #     C = CURRENT VALVE STATE (CH32)).
006862,000082: 06,3164           71300                           MASK     PVALVEST                              
006863,000083: 06,3165           26001                           ADS      L                                     #  RESULT NZ INDICATES ACTION REQUIRED.
006864,000084: 
006865,000085: 06,3166           00006                           EXTEND                                         
006866,000086: 06,3167           13260                           BZF      RCSMONEX                              #  QUIT IF NO ACTION REQUIRED.
006867,000087: 
006868,000088: 06,3170           00006                           EXTEND                                         
006869,000089: 06,3171           75020                           MP       BIT7                                  #  MOVE BITS 8 - 1 OF A TO 14 - 7 OF L.
006870,000090: 06,3172           56001                           XCH      L                                     #  ZERO TO L IN THE PROCESS.
006871,000091: 
006872,000092: 06,3173           24001                 -3        INCR     L                                     
006873,000093: 06,3174           60000                           DOUBLE                                         #  BOUND TO GET OVERFLOW IN THIS LOOP,
006874,000094: 06,3175           54000                           OVSK                                           #  SINCE WE ASSURED INITIAL NZ IN A.
006875,000095: 06,3176           13173                           TCF      -3                                    
006876,000096: 
006877,000097: 06,3177           50001                           INDEX    L                                     
006878,000098: 06,3200           35016                           CA       BIT8       -1                         #  SAVE THE RELEVANT BIT (8 - 1).
006879,000099: 06,3201           54002                           TS       Q                                     
006880,000100: 06,3202           71300                           MASK     PVALVEST                              #  LOOK AT PREVIOUS VALVE STATE BIT.
006881,000101: 06,3203           10000                           CCS      A                                     
006882,000102: 06,3204           13220                           TCF      VOPENED                               #  THE VALVE HAS JUST BEEN OPENED.
006883,000103: 
006884,000104: 06,3205           41264                           CS       CH5MASK                               #  THE VALVE HAS JUST BEEN CLOSED.
006885,000105: 06,3206           50001                           INDEX    L                                     
006886,000106: 06,3207           73237                           MASK     5FAILTAB                              
006887,000107: 06,3210           27264                           ADS      CH5MASK                               #  SET INHIBIT BIT FOR CHANNEL 5 JET.
006888,000108: 
006889,000109: 06,3211           41265                           CS       CH6MASK                               
006890,000110: 06,3212           50001                           INDEX    L                                     
006891,000111: 06,3213           73247                           MASK     6FAILTAB                              
006892,000112: 06,3214           27265                           ADS      CH6MASK                               #  SET INGIBIT BIT FOR CHANNEL 6 JET.
006893,000113: 
006894,000114: 06,3215           30002                           CA       Q                                     
006895,000115: 06,3216           27300                           ADS      PVALVEST                              #  RECORD ACTION TAKEN.
006896,000116: 
006897,000117: 06,3217           13233                           TCF      1/ACCFIX                              #  SET UP 1/ACCJOB AND EXIT.
006898,000118: 
006899,000119: 06,3220           50001        VOPENED            INDEX    L                                     #  A VALVE HAS JUST BEEN OPENED.
006900,000120: 06,3221           43237                           CS       5FAILTAB                              
006901,000121: 06,3222           71264                           MASK     CH5MASK                               
006902,000122: 06,3223           55264                           TS       CH5MASK                               #  REMOVE INHIBIT BIT FOR CHANNEL 5 JET.
006903,000123: 
006904,000124: 06,3224           50001                           INDEX    L                                     
006905,000125: 06,3225           43247                           CS       6FAILTAB                              
006906,000126: 06,3226           71265                           MASK     CH6MASK                               
006907,000127: 06,3227           55265                           TS       CH6MASK                               #  REMOVE INHIBIT BIT FOR CHANNEL 6 JET.
006908,000128: 
006909,000129: 06,3230           40002                           CS       Q                                     
006910,000130: 06,3231           71300                           MASK     PVALVEST                              
006911,000131: 06,3232           55300                           TS       PVALVEST                              #  RECORD ACTION TAKEN.
006912,000132: 
006913,000133: 06,3233           37667        1/ACCFIX           CAF      PRIO27                                #  SET UP 1/ACCS SO THAT THE SWITCH CURVES
006914,000134: 06,3234           05142                           TC       NOVAC                                 #    FOR TJETLAW CAN BE MODIFIED IF CH5MASK
006915,000135: 06,3235  E6,1532                                  EBANK=   AOSQ                                  #    HAS BEEN ALTERED.
006916,000136: 06,3235           02312 40006                     2CADR    1/ACCJOB                              
006917,000137: 
006918,000138: 06,3237           13260                           TCF      RCSMONEX                              #  EXIT.
006919,000139: 
006920,000140: 06,3240                        5FAILTAB           EQUALS   -1                                    #  CH 5 JET BIT CORRESPONDING TO CH 32 BIT:
006921,000141: 06,3240           00040                           OCT      00040                                 #  8
006922,000142: 06,3241           00020                           OCT      00020                                 #  7
006923,000143: 06,3242           00100                           OCT      00100                                 #  6
006924,000144: 06,3243           00200                           OCT      00200                                 #  5
006925,000145: 06,3244           00010                           OCT      00010                                 #  4
006926,000146: 06,3245           00001                           OCT      00001                                 #  3
006927,000147: 06,3246           00004                           OCT      00004                                 #  2
006928,000148: 06,3247           00002                           OCT      00002                                 #  1
006929,000149: 
006930,000150: 06,3250                        6FAILTAB           EQUALS   -1                                    #  CH 6 JET BIT CORRESPONDING TO CH 32 BIT:
006931,000151: 06,3250           00010                           OCT      00010                                 #  8
006932,000152: 06,3251           00020                           OCT      00020                                 #  7
006933,000153: 06,3252           00004                           OCT      00004                                 #  6
006934,000154: 06,3253           00200                           OCT      00200                                 #  5
006935,000155: 06,3254           00001                           OCT      00001                                 #  4
006936,000156: 06,3255           00002                           OCT      00002                                 #  3
006937,000157: 06,3256           00040                           OCT      00040                                 #  2
006938,000158: 06,3257           00100                           OCT      00100                                 #  1

End of include-file RCS_FAILURE_MONITOR.agc.  Parent file is MAIN.agc