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.

059004,000002:                                                                                                  ## Copyright:   Public domain.
059005,000003:                                                                                                  ## Filename:    DAP_INTERFACE_SUBROUTINES.agc
059006,000004:                                                                                                  ## Purpose:     A section of Luminary 1C, revision 131.
059007,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
059008,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13.
059009,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
059010,000008:                                                                                                  ##              that the code format has been changed to conform to the
059011,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
059012,000010:                                                                                                  ##              original YUL assembler.
059013,000011:                                                                                                  ## Reference:   pp. 1398-1401
059014,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
059015,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
059016,000014:                                                                                                  ## Mod history: 06/07/03 RSB.   Began transcribing.
059017,000015:                                                                                                  ##              05/14/05 RSB    Corrected website reference above.
059018,000016:                                                                                                  ##              2010-10-25 JL   Indentation fixes.
059019,000017:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
059020,000018:                                                                                                  ##                              original hardcopy, as opposed to the PDF page
059021,000019:                                                                                                  ##                              numbers in 1701.pdf.
059022,000020:                                                                                                  ##              2017-02-28 RSB  Proofed comment text using octopus/ProoferComments.
059023,000021:                                                                                                  ##              2017-03-01 RSB  Fixed lingering comment-text typos.
059024,000022:                                                                                                  ##              2017-03-10 RSB  Comment-text fixes noted in proofing Luminary 116.
059025,000023: 

Page 1398

059027,000025: 20,2115                                           BANK     20                                    
059028,000026: 20,2000                                           SETLOC   DAPS3                                 
059029,000027: 20,2000                                           BANK                                           
059030,000028: 
059031,000029: 20,2115  E6,1634                                  EBANK=   CDUXD                                 
059032,000030: 20,2115                                           COUNT*   $$/DAPIF                              
059033,000031: 
059034,000032:                                                                                                  #  MOD 0         DATE    11/15/66        BY GEORGE W. CHERRY
059035,000033:                                                                                                  #  MOD 1                  1/23/67        MODIFICATION BY PETER ADLER
059036,000034: 
059037,000035:                                                                                                  #  FUNCTIONAL DESCRIPTION
059038,000036:                                                                                                  #        HEREIN ARE A COLLECTION OF SUBROUTINES WHICH ALLOW MISSION CONTROL PROGRAMS TO CONTROL THE MODE
059039,000037:                                                                                                  #        AND INTERFACE WITH THE DAP.
059040,000038: 
059041,000039:                                                                                                  #  CALLING SEQUENCES
059042,000040:                                                                                                  #        IN INTERRUPT OR WITH INTERRUPT INHIBITED
059043,000041:                                                                                                  #                TC      IBNKCALL
059044,000042:                                                                                                  #                FCADR   ROUTINE
059045,000043:                                                                                                  #        IN A JOB WITHOUT INTERRUPT INHIBITED
059046,000044:                                                                                                  #                INHINT
059047,000045:                                                                                                  #                TC      IBNKCALL
059048,000046:                                                                                                  #                FCADR   ROUTINE
059049,000047:                                                                                                  #                RELINT
059050,000048: 
059051,000049:                                                                                                  #  OUTPUT
059052,000050:                                                                                                  #        SEE INDIVIDUAL ROUTINES BELOW
059053,000051: 
059054,000052:                                                                                                  #  DEBRIS
059055,000053:                                                                                                  #        A, L, AND SOMETIMES MDUETEMP                                    ODE     NOT IN PULSES MODE
059056,000054: 

Page 1399

059058,000056:                                                                                                  #  SUBROUTINE NAMES:
059059,000057:                                                                                                  #        SETMAXDB, SETMINDB, RESTORDB, PFLITEDB
059060,000058:                                                                                                  #  MODIFIED:     30 JANUARY 1968 BY P S WEISSMAN TO CREATE RESTORDB.
059061,000059:                                                                                                  #  MODIFIED:     1 MARCH 1968 BY P S WEISSMAN TO SAVE EBANK AND CREATE PFLITEDB
059062,000060: 
059063,000061:                                                                                                  #  FUNCTIONAL DESCRIPTION:
059064,000062:                                                                                                  #        SETMAXDB - SET DEADBAND TO 5.0 DEGREES
059065,000063:                                                                                                  #        SETMINDB - SET DEADBAND TO 0.3 DEGREE
059066,000064:                                                                                                  #        RESTORDB - SET DEADBAND TO .3, 1, OR 5 ACCORDING TO BITS 4 AND 5 OF DAPBOOLS
059067,000065:                                                                                                  #        PFLITEDB - SET DEADBAND TO 1.0 DEGREE AND ZERO THE COMMANDED ATTITUDE CHANGE AND COMMANDED RATE
059068,000066: 
059069,000067:                                                                                                  #        ALL ENTRIES SET UP A NOVAC JOB TO DO 1/ACCS SO THAT THE TJETLAW SWITCH CURVES ARE POSITIONED TO
059070,000068:                                                                                                  #        REFLECT THE NEW DEADBAND.  IT SHOULD BE NOTED THAT THE DEADBAND REFERS TO THE ATTITUDE IN THE P-, U-, AND V-AXES.
059071,000069: 
059072,000070:                                                                                                  #  SUBROUTINE CALLED:    NOVAC
059073,000071: 
059074,000072:                                                                                                  #  CALLING SEQUENCE:     SAME AS ABOVE
059075,000073:                                                                                                  #                        OR      TC RESTORDB +1    FROM ALLCOAST
059076,000074: 
059077,000075:                                                                                                  #  DEBRIS:               A, L, Q, RUPTREG1, (ITEMPS IN NOVAC)
059078,000076: 
059079,000077: 20,2115           30111        RESTORDB           CAE      DAPBOOLS                              #  DETERMINE CREW-SELECTED DEADBAND.
059080,000078: 20,2116           74747                           MASK     DBSLECT2                              #  CHECK FOR MAX DB (5 DEG)
059081,000079: 20,2117           00006                           EXTEND                                         
059082,000080: 20,2120           12122                           BZF      +2                                    
059083,000081: 20,2121           12130                           TCF      SETMAXDB                              #  BIT5 DAPBOOLS IS SET - CREW WANTS 5 DEG
059084,000082: 20,2122           30111                           CAE      DAPBOOLS                              
059085,000083: 20,2123           74750                           MASK     DBSELECT                              #  CHECK FOR 1 DEG DEADBAND SELECTION
059086,000084: 20,2124           00006                           EXTEND                                         
059087,000085: 20,2125           12141                           BZF      SETMINDB                              
059088,000086: 
059089,000087: 20,2126           32153                           CAF      POWERDB                               #  BIT4 DAPBOOLS IS SET - CREW WANTS 1 DEG
059090,000088: 20,2127           12131                           TCF      SETMAXDB   +1                         
059091,000089: 20,2130           32152        SETMAXDB           CAF      WIDEDB                                #  SET 5 DEGREE DEADBAND.
059092,000090: 20,2131           55343                 +1        TS       DB                                    
059093,000091: 
059094,000092: 20,2132           00006                           EXTEND                                         #  SET UP JOB TO RE-POSITION SWITCH CURVES.
059095,000093: 20,2133           22070                           QXCH     RUPTREG1                              
059096,000094: 20,2134           37720        CALLACCS           CAF      PRIO27                                
059097,000095: 20,2135           05072                           TC       NOVAC                                 
059098,000096: 20,2136  E6,1536                                  EBANK=   AOSQ                                  
059099,000097: 20,2136           03652 42106                     2CADR    1/ACCJOB                              
059100,000098: 
059101,000099: 20,2140           00070                           TC       RUPTREG1                              #  RETURN TO CALLER.
059102,000100: 
059103,000101: 20,2141           32151        SETMINDB           CAF      NARROWDB                              #  SET 0.3 DEGREE DEADBAND.
059104,000102: 20,2142           12131                           TCF      SETMAXDB   +1                         
059105,000103: 

Page 1400

059107,000105: 20,2143           00006        PFLITEDB           EXTEND                                         #  THE RETURN FROM CALLACCS IS TO RUPTREG1.
059108,000106: 20,2144           22070                           QXCH     RUPTREG1                              
059109,000107: 20,2145           02154                           TC       ZATTEROR                              #  ZERO THE ERRORS AND COMMANDED RATES.
059110,000108: 20,2146           32153                           CAF      POWERDB                               #  SET DB TO 1.0 DEG.
059111,000109: 20,2147           55343                           TS       DB                                    
059112,000110: 20,2150           12134                           TCF      CALLACCS                              #  SET UP 1/ACCS AND RETURN TO CALLER.
059113,000111: 20,2151           00155        NARROWDB           OCTAL    00155                                 #  0.3 DEGREE SCALED AT 45.
059114,000112: 20,2152           03434        WIDEDB             OCTAL    03434                                 #  5.0 DEGREES SCALED AT 45.
059115,000113: 20,2153           00554        POWERDB            DEC      .02222                                #  1.0 DEGREE SCALED AT 45.
059116,000114: 
059117,000115: 20,2154           35015        ZATTEROR           CAF      EBANK6                                
059118,000116: 20,2155           56003                           XCH      EBANK                                 
059119,000117: 20,2156           54001                           TS       L                                     #  SAVE CALLERS EBANK IN L.
059120,000118: 20,2157           30032                           CAE      CDUX                                  
059121,000119: 20,2160           55634                           TS       CDUXD                                 
059122,000120: 20,2161           30033                           CAE      CDUY                                  
059123,000121: 20,2162           55635                           TS       CDUYD                                 
059124,000122: 20,2163           30034                           CAE      CDUZ                                  
059125,000123: 20,2164           55636                           TS       CDUZD                                 
059126,000124: 20,2165           12171                           TCF      STOPRATE   +3                         
059127,000125: 
059128,000126: 20,2166           35015        STOPRATE           CAF      EBANK6                                
059129,000127: 20,2167           56003                           XCH      EBANK                                 
059130,000128: 20,2170           54001                           TS       L                                     #  SAVE CALLERS EBANK IN L.
059131,000129: 20,2171           34755                 +3        CAF      ZERO                                  
059132,000130: 20,2172           55642                           TS       OMEGAPD                               
059133,000131: 20,2173           55643                           TS       OMEGAQD                               
059134,000132: 20,2174           55644                           TS       OMEGARD                               
059135,000133: 20,2175           55637                           TS       DELCDUX                               
059136,000134: 20,2176           55640                           TS       DELCDUY                               
059137,000135: 20,2177           55641                           TS       DELCDUZ                               
059138,000136: 20,2200           55274                           TS       DELPEROR                              
059139,000137: 20,2201           55275                           TS       DELQEROR                              
059140,000138: 20,2202           55276                           TS       DELREROR                              
059141,000139: 20,2203           22003                           LXCH     EBANK                                 #  RESTORE CALLERS EBANK.
059142,000140: 20,2204           00002                           TC       Q                                     
059143,000141: 
059144,000142:                                                                                                  #  SUBROUTINE NAME:      ALLCOAST
059145,000143:                                                                                                  #  WILL BE CALLED BY FRESH STARTS AND ENGINE OFF ROUTINES.               .
059146,000144: 
059147,000145:                                                                                                  #  CALLING SEQUENCE:     (SAME AS ABOVE)
059148,000146: 
059149,000147:                                                                                                  #  EXIT:                 RETURN TO Q.
059150,000148: 
059151,000149:                                                                                                  #  SUBROUTINES CALLED:   STOPRATE, RESTORDB, NOVAC
059152,000150: 
059153,000151:                                                                                                  #  ZERO:                 (FOR ALL AXES) AOS, ALPHA, AOSTERM, OMEGAD, DELCDU, DELEROR

Page 1401

059155,000153: 
059156,000154:                                                                                                  #  OUTPUT:               DRIFTBIT/DAPBOOLS, DB, JOB TO DO 1/ACCS
059157,000155: 
059158,000156:                                                                                                  #  DEBRIS:               A, L, Q, RUPTREG1, RUPTREG2, (ITEMPS IN NOVAC)
059159,000157: 
059160,000158: 20,2205           00006        ALLCOAST           EXTEND                                         #  SAVE Q FOR RETURN
059161,000159: 20,2206           22071                           QXCH     RUPTREG2                              
059162,000160: 20,2207           02166                           TC       STOPRATE                              #  CLEAR RATE INTERFACE.  RETURN WITH A=0
059163,000161: 20,2210           22003                           LXCH     EBANK                                 #  AND L=EBANK6.  SAVE CALLERS EBANK.
059164,000162: 20,2211           55536                           TS       AOSQ                                  
059165,000163: 20,2212           55537                           TS       AOSQ       +1                         
059166,000164: 20,2213           55540                           TS       AOSR                                  
059167,000165: 20,2214           55541                           TS       AOSR       +1                         
059168,000166: 20,2215           55424                           TS       ALPHAQ                                #  FOR DOWNLIST.
059169,000167: 20,2216           55425                           TS       ALPHAR                                
059170,000168: 20,2217           55544                           TS       AOSQTERM                              
059171,000169: 20,2220           55545                           TS       AOSRTERM                              
059172,000170: 20,2221           22003                           LXCH     EBANK                                 #  RESTORE EBANK (EBANK6 NO LONGER NEEDED)
059173,000171: 
059174,000172: 20,2222           40111                           CS       DAPBOOLS                              #  SET UP DRIFTBIT
059175,000173: 20,2223           74744                           MASK     DRIFTBIT                              
059176,000174: 20,2224           26111                           ADS      DAPBOOLS                              
059177,000175: 20,2225           02116                           TC       RESTORDB   +1                         #  RESTORE DEADBANK TO CREW-SELECTED VALUE.
059178,000176: 
059179,000177: 20,2226           00071                           TC       RUPTREG2                              #  RETURN.
059180,000178: 
059181,000179: 
059182,000180: 

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