Source Code

This source code is very close to the Apollo Guidance Computer software for the Apollo 13 Lunar module. This revision of the Luminary 131 program is from December of 1969, whereas there was a later revision in January of 1970, and still another revision in February, which is the code that flew on the mission. As far as this transcription is concerned, it was originally from a copy made in 1991 of a printout from the collection of AGC developer Don Eyles for collector David Craig. It was subsequently scanned by Gary Neff, reprocessed for online presentation at the now-discontinued History of Recent Science and Technology (HRST) website of MIT's Dibner Institute (the full-quality scans being discarded in the process), and finally transcribed by Ron Burkey for the Virtual AGC Project. Although a high-quality replacement scan for a completely illegible page was later provided by Gary Neff, the reduced legibility of the reprocessed HRST posting nevertheless caused many errors to be introduced into the transcription. Accordingly, a second scan of the same physical printout was made in 2017 for the Virtual AGC Project's collection at the Internet Archive, and used to correct the transcription errors. All of the scanned materials mentioned, as well as other Luminary 131 related material, are available online. Don Eyles apprently made additional hand-written notes in printout between 1991 and 2017, so the two scans are not identical in that respect. The page-headings in the printout read, in part:
	GAP:  ASSEMBLE REVISION 131 OF AGC PROGRAM LUMINARY BY NASA 2021112-091
	17:53 DEC. 19, 1969
Note that the date is the date the printout was made, not the date on which the program revision was released, although these happen to be very close together.

007692,000002:                                                                                                  ## Copyright:   Public domain.
007693,000003:                                                                                                  ## Filename:    RCS_FAILURE_MONITOR.agc
007694,000004:                                                                                                  ## Purpose:     RCS FAILURE MONITOR code for for Luminary 1C, revision 131.
007695,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
007696,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13.
007697,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
007698,000008:                                                                                                  ##              that the code format has been changed to conform to the
007699,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the 
007700,000010:                                                                                                  ##              original YUL assembler.
007701,000011:                                                                                                  ## Reference:   pp. 192-194
007702,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
007703,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
007704,000014:                                                                                                  ## Mod history: 05/05/03 RSB.   Began transcribing.
007705,000015:                                                                                                  ##              05/14/05 RSB    Corrected website references above.
007706,000016:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
007707,000017:                                                                                                  ##                              original harcopy, as opposed to the PDF page
007708,000018:                                                                                                  ##                              numbers in 1701.pdf.
007709,000019:                                                                                                  ##              2017-02-16 RSB  Proofed comment text using octopus/ProoferComments.
007710,000020:                                                                                                  ##              2017-03-14 RSB  Comment-text fixes noted in proofing Luminary 116.
007711,000021:                                                                                                  ##              2017-08-18 RSB  Comment-text bug identified in ZERLINA 56.
007712,000022: 

Page 192

007714,000024:                                                                                                  #  PROGRAM DESCRIPTION
007715,000025: 
007716,000026:                                                                                                  #  AUTHOR: J S MILLER
007717,000027: 
007718,000028:                                                                                                  #  MODIFIED 6 MARCH 1968 BY P S WEISSMAN TO SET UP JOB FOR 1/ACCS WHEN THE MASKS ARE CHANGED.
007719,000029: 
007720,000030:                                                                                                  #  THIS ROUTINE IS ATTACHED TO T4RUPT, AND IS ENTERED EVERY 480 MS.  ITS FUNCTION IS TO EXAMINE THE LOW 8 BITS
007721,000031:                                                                                                  #  OF CHANNEL 32 TO SEE IF ANY ISOLATION-VALVE CLOSURE BITS HAVE APPEARED OR DISAPPEARED (THE CREW IS WARNED OF JET
007722,000032:                                                                                                  #  FAILURES BY LAMPS LIT BY THE GRUMMAN FAILURE-DETECTION CIRCUITRY; THEY MAY RESPOND BY OPERATING SWITCHES WHICH
007723,000033:                                                                                                  #  ISOLATE PAIRS OF JETS FROM THE PROPELLANT TANKS AND SET BITS IN CHANNEL 32).  IN THE EVENT THAT CHANNEL 32 BITS
007724,000034:                                                                                                  #  DIFFER FROM 'PVALVEST', THE RECORD OF ACTIONS TAKEN BY THIS ROUTINE, THE APPROPRIATE BITS IN 'CH5MASK' &
007725,000035:                                                                                                  #  'CH6MASK', USED BY THE DAP JET-SELECTION LOGIC, ARE UPDATED, AS IS 'PVALVEST'.  TO SPEED UP & SHORTEN THE
007726,000036:                                                                                                  #  ROUTINE, NO MORE THAN ONE CHANGE IS ACCEPTED PER ENTRY.  THE HIGHEST-NUMBERED BIT IN CHANNEL 32 WHICH REQUIRES
007727,000037:                                                                                                  #  ACTION IS THE ONE PROCESSED.
007728,000038: 
007729,000039:                                                                                                  #  THE CODING IN THE FAILURE MONITOR HAS BEEN WRITTEN SO AS TO HAVE ALMOST COMPLETE RESTART PROTECTION.  FOR
007730,000040:                                                                                                  #  EXAMPLE, NO ASSUMPTION IS MADE WHEN SETTING A 'CH5MASK' BIT TO 1 THAT THE PREVIOUS STATE IS 0, ALTHOUGH IT OF
007731,000041:                                                                                                  #  COURSE SHOULD BE.  ONE CASE WHICH MAY BE SEEN TO EVADE PROTECTION IS THE OCCURRENCE OF A RESTART AFTER UPDATING
007732,000042:                                                                                                  #  ONE OR BOTH DAP MASK-WORDS BUT BEFORE UPDATING 'PVALVEST', COUPLED WITH A CHANGE IN THE VALVE-BIT BACK TO ITS
007733,000043:                                                                                                  #  FORMER STATE.  THE CONSEQUENCE OF THIS IS THAT THE NEXT ENTRY WOULD NOT SEE THE CHANGE INCOMPLETELY INCORP-
007734,000044:                                                                                                  #  ORATED BY THE LAST PASS (BECAUSE IT WENT AWAY AT JUST THE RIGHT TIME), BUT THE DAP MASK-WORDS WILL BE INCORRECT.
007735,000045:                                                                                                  #  THIS COMBINATION OF EVENTS SEEMS QUITE REMOTE, BUT NOT IMPOSSIBLE UNLESS THE CREW OPERATES THE SWITCHES AT HALF-
007736,000046:                                                                                                  #  SECOND INTERVALS OR LONGER.  IN ANY EVENT, A DISAGREEMENT BETWEEN REALITY AND THE DAP MASKS WILL BE CURED IF
007737,000047:                                                                                                  #  THE MISINTERPRETED SWITCH IS REVERSED AND THEN RESTORED TO ITS CORRECT POSITION (SLOWLY).
007738,000048: 
007739,000049:                                                                                                  #  CALLING SEQUENCE:
007740,000050: 
007741,000051:                                                                                                  #        TCF     RCSMONIT                (IN INTERRUPT MODE, EVERY 480 MS.)
007742,000052: 
007743,000053:                                                                                                  #  EXIT: TCF RCSMONEX (ALL PATHS EXIT VIA SUCH AN INSTRUCTION)
007744,000054: 
007745,000055: 06,3164     5270               RCSMONEX           EQUALS   RESUME                                
007746,000056: 
007747,000057:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED:
007748,000058: 
007749,000059:                                                                                                  #        VIA FRESH START:        PVALVEST        =       +0      (ALL JETS ENABLED)
007750,000060:                                                                                                  #                                CH5MASK,CH6MASK =       +0      (ALL JETS OK)
007751,000061: 
007752,000062:                                                                                                  #  OUTPUT:       CH5MASK & CH6MASK UPDATED (1'S WHERE JETS NOT TO BE USED, IN CHANNEL 5 & 6 FORMAT)
007753,000063:                                                                                                  #                PVALTEST UPDATED (1,S WHEN VALVE CLOSURES HAVE BEEN TRANSLATED INTO CH5MASK & CH6MASK; CHAN 32 FORMAT)
007754,000064:                                                                                                  #                JOB TO DO 1/ACCS.
007755,000065: 
007756,000066:                                                                                                  #  DEBRIS:  A, L, Q AND DEBRIS OF NOVAC.
007757,000067: 
007758,000068:                                                                                                  #  SUBROUTINE CALLED:  NOVAC.
007759,000069: 
007760,000070: 06,3164     1257                                  EBANK=   CH5MASK                               
007761,000071: 
007762,000072: 23,2000                                           BANK     23                                    
007763,000073: 06,2000                                           SETLOC   RCSMONT                               
007764,000074: 06,2000                                           BANK                                           

Page 193

007766,000076: 06,3164                                           COUNT*   $$/T4RCS                              
007767,000077: 
007768,000078: 06,3164           44755        RCSMONIT           CS       ZERO                                  
007769,000079: 06,3165           00006                           EXTEND                                         
007770,000080: 06,3166           06032                           RXOR     CHAN32                                #  PICK UP + INVERT INVERTED CHANNEL 32.
007771,000081: 06,3167           74357                           MASK     LOW8                                  #  KEEP JET-FAIL BITS ONLY.
007772,000082: 06,3170           54002                           TS       Q                                     
007773,000083: 
007774,000084: 06,3171           41273                           CS       PVALVEST                              #        -   -
007775,000085: 06,3172           70002                           MASK     Q                                     #  FORM PC + PC.
007776,000086: 06,3173           54001                           TS       L                                     #        (P = PREVIOUS ISOLATION VALVE STATE,
007777,000087: 06,3174           40002                           CS       Q                                     #         C = CURRENT VALVE STATE (CH32)).
007778,000088: 06,3175           71273                           MASK     PVALVEST                              
007779,000089: 06,3176           26001                           ADS      L                                     #  RESULT NZ INDICATES ACTION REQUIRED.
007780,000090: 
007781,000091: 06,3177           00006                           EXTEND                                         
007782,000092: 06,3200           15270                           BZF      RCSMONEX                              #  QUIT IF NO ACTION REQUIRED.
007783,000093: 
007784,000094: 06,3201           00006                           EXTEND                                         
007785,000095: 06,3202           74745                           MP       BIT7                                  #  MOVE BITS 8-1 OF A TO 14-7 OF L.
007786,000096: 06,3203           56001                           XCH      L                                     #  ZERO TO L IN THE PROCESS.
007787,000097: 
007788,000098: 06,3204           24001                 -3        INCR     L                                     
007789,000099: 06,3205           60000                           DOUBLE                                         #  BOUND TO GET OVERFLOW IN THIS LOOP,
007790,000100: 06,3206           54000                           OVSK                                           #  SINCE WE ASSURED INITIAL NZ IN A.
007791,000101: 06,3207           13204                           TCF      -3                                    
007792,000102: 
007793,000103: 06,3210           50001                           INDEX    L                                     
007794,000104: 06,3211           34743                           CA       BIT8       -1                         #  SAVE THE RELEVANT BIT (8-1).
007795,000105: 06,3212           54002                           TS       Q                                     
007796,000106: 06,3213           71273                           MASK     PVALVEST                              #  LOOK AT PREVIOUS VALVE STATE BIT.
007797,000107: 06,3214           10000                           CCS      A                                     
007798,000108: 06,3215           13231                           TCF      VOPENED                               #  THE VALVE HAS JUST BEEN OPENED.
007799,000109: 
007800,000110: 06,3216           41257                           CS       CH5MASK                               #  THE VALVE HAS JUST BEEN CLOSED.
007801,000111: 06,3217           50001                           INDEX    L                                     
007802,000112: 06,3220           73250                           MASK     5FAILTAB                              
007803,000113: 06,3221           27257                           ADS      CH5MASK                               #  SET INHIBIT BIT FOR CHANNEL 5 JET.
007804,000114: 
007805,000115: 06,3222           41260                           CS       CH6MASK                               
007806,000116: 06,3223           50001                           INDEX    L                                     
007807,000117: 06,3224           73260                           MASK     6FAILTAB                              
007808,000118: 06,3225           27260                           ADS      CH6MASK                               #  SET INGIBIT BIT FOR CHANNEL 6 JET.
007809,000119: 
007810,000120: 06,3226           30002                           CA       Q                                     
007811,000121: 06,3227           27273                           ADS      PVALVEST                              #  RECORD ACTION TAKEN.
007812,000122: 
007813,000123: 06,3230           13244                           TCF      1/ACCFIX                              #  SET UP 1/ACCJOB AND EXIT.
007814,000124: 

Page 194

007816,000126: 06,3231           50001        VOPENED            INDEX    L                                     #  A VALVE HAS JUST BEEN OPENED.
007817,000127: 06,3232           43250                           CS       5FAILTAB                              
007818,000128: 06,3233           71257                           MASK     CH5MASK                               
007819,000129: 06,3234           55257                           TS       CH5MASK                               #  REMOVE INHIBIT BIT FOR CHANNEL 5 JET.
007820,000130: 
007821,000131: 06,3235           50001                           INDEX    L                                     
007822,000132: 06,3236           43260                           CS       6FAILTAB                              
007823,000133: 06,3237           71260                           MASK     CH6MASK                               
007824,000134: 06,3240           55260                           TS       CH6MASK                               #  REMOVE INHIBIT BIT FOR CHANNEL 6 JET.
007825,000135: 
007826,000136: 06,3241           40002                           CS       Q                                     
007827,000137: 06,3242           71273                           MASK     PVALVEST                              
007828,000138: 06,3243           55273                           TS       PVALVEST                              #  RECORD ACTION TAKEN.
007829,000139: 
007830,000140: 06,3244           37720        1/ACCFIX           CAF      PRIO27                                #  SET UP 1/ACCS SO THAT THE SWITCH CURVES
007831,000141: 06,3245           05072                           TC       NOVAC                                 #        FOR TJETLAW CAN BE MODIFIED IF CH5MASK
007832,000142: 06,3246  E6,1536                                  EBANK=   AOSQ                                  #        HAS BEEN ALTERED.
007833,000143: 06,3246           03652 42106                     2CADR    1/ACCJOB                              
007834,000144: 
007835,000145: 06,3250           15270                           TCF      RCSMONEX                              #  EXIT.
007836,000146: 
007837,000147: 06,3251                        5FAILTAB           EQUALS   -1                                    #  CH 5 JET BIT CORRESPONDING TO CH 32 BIT:
007838,000148: 06,3251           00040                           OCT      00040                                 #  8
007839,000149: 06,3252           00020                           OCT      00020                                 #  7
007840,000150: 06,3253           00100                           OCT      00100                                 #  6
007841,000151: 06,3254           00200                           OCT      00200                                 #  5
007842,000152: 06,3255           00010                           OCT      00010                                 #  4
007843,000153: 06,3256           00001                           OCT      00001                                 #  3
007844,000154: 06,3257           00004                           OCT      00004                                 #  2
007845,000155: 06,3260           00002                           OCT      00002                                 #  1
007846,000156: 
007847,000157: 06,3261                        6FAILTAB           EQUALS   -1                                    #  CH 6 JET BIT CORRESPONDING TO CH 32 BIT:
007848,000158: 06,3261           00010                           OCT      00010                                 #  8
007849,000159: 06,3262           00020                           OCT      00020                                 #  7
007850,000160: 06,3263           00004                           OCT      00004                                 #  6
007851,000161: 06,3264           00200                           OCT      00200                                 #  5
007852,000162: 06,3265           00001                           OCT      00001                                 #  4
007853,000163: 06,3266           00002                           OCT      00002                                 #  3
007854,000164: 06,3267           00040                           OCT      00040                                 #  2
007855,000165: 06,3270           00100                           OCT      00100                                 #  1
007856,000166: 
007857,000167: 

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