Source Code

These source-code files derive from a printout of Luminary 116 (the Apollo 12 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Ron Burkey, and transcribed to source code by a team of volunteers. This colorized, syntax-highlighted form was created by assembling that transcribed source code. Note that the full page images are available on the Virtual AGC project page at archive.org, while reduced-size images are presented at the VirtualAGC project website. Report or fix any transcription errors at the Virtual AGC project code repository.

Notations on the program listing read, in part:

	GAP:  ASSEMBLE REVISION 116 OF AGC PROGRAM LUMINARY BY NASA 2021112-071
	19:09 AUG. 11,1969
Note that the date is the date of the printout, not the date of the program revision.

033251,000002:                                                                                                  ## Copyright:   Public domain.
033252,000003:                                                                                                  ## Filename:    THE_LUNAR_LANDING.agc
033253,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
033254,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
033255,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
033256,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
033257,000008:                                                                                                  ##              that the code format has been changed to conform to the
033258,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
033259,000010:                                                                                                  ##              original YUL assembler.
033260,000011:                                                                                                  ## Reference:   pp. 778-785
033261,000012:                                                                                                  ## Assembler:   yaYUL
033262,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
033263,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
033264,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
033265,000016:                                                                                                  ##              2017-03-10 HG   Transcribed
033266,000017:                                                                                                  ##              2017-03-14 RSB  Proofed comment text via 3-way diff vs
033267,000018:                                                                                                  ##                              Luminary 99 and 131.
033268,000019:                                                                                                  ##              2017-03-16 RSB  Comment-text fixes identified in 5-way
033269,000020:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
033270,000021:                                                                                                  ##              2017-03-19 HG   Fix SELOC operand  F2DPS*31 --> F2DPS*34
033271,000022: 

Page 778

033273,000024: 32,2777                                           BANK     32                                    
033274,000025: 32,2000                                           SETLOC   F2DPS*32                              
033275,000026: 32,2000                                           BANK                                           
033276,000027: 
033277,000028: 32,2777  E7,1621                                  EBANK=   E2DPS                                 
033278,000029: 
033279,000030:                                                                                                  #           ****************************************
033280,000031:                                                                                                  #           P63: THE LUNAR LANDING, BRAKING PHASE
033281,000032:                                                                                                  #           ****************************************
033282,000033: 
033283,000034: 32,2777                                           COUNT*   $$/P63                                
033284,000035: 
033285,000036: 32,2777           05353        P63LM              TC       PHASCHNG                              
033286,000037: 32,3000           04024                           OCT      04024                                 

Note: The above label (P63LM) has a box in blue pen drawn arround it The two statements above are circled with a blue pen arround them

033289,000040: 
033290,000041: 32,3001           04616                           TC       BANKCALL                              #  DO IMU STATUS CHECK ROUTINE R02
033291,000042: 32,3002           11236                           CADR     R02BOTH                               
033292,000043: 
033293,000044: 32,3003           33254                           CAF      P63ADRES                              #  INITIALIZE WHICH FOR BURNBABY
033294,000045: 32,3004           55455                           TS       WHICH                                 
033295,000046: 
033296,000047: 32,3005           32000                           CAF      DPSTHRSH                              #  INITIALIZE DVMON
033297,000048: 32,3006           55250                           TS       DVTHRUSH                              
033298,000049: 32,3007           34751                           CAF      FOUR                                  
033299,000050: 32,3010           55515                           TS       DVCNTR                                
033300,000051: 
033301,000052: 32,3011           44753                           CS       ONE                                   #  INITIALIZE WCHPHASE AND FLPASSO
033302,000053: 32,3012           55346                           TS       WCHPHASE                              
033303,000054: 
033304,000055: 32,3013           34755                           CA       ZERO                                  
033305,000056: 32,3014           55623                           TS       FLPASS0                               
033306,000057: 
033307,000058: 32,3015           44736                           CS       BIT14                                 
033308,000059: 32,3016           00006                           EXTEND                                         
033309,000060: 32,3017           03012                           WAND     CHAN12                                #  REMOVE TRACK-ENABLE DISCRETE.
033310,000061: 
033311,000062: 32,3020           06042        FLAGORGY           TC       INTPRET                               #  DIONYSIAN FLAG WAVING
033312,000063: 32,3021           43014                           CLEAR    CLEAR                                 
033313,000064: 32,3022           02663                                    NOTHROTL                              
033314,000065: 32,3023           03271                                    REDFLAG                               
033315,000066: 32,3024           43014                           CLEAR    SET                                   
033316,000067: 32,3025           05660                                    LRBYPASS                              
033317,000068: 32,3026           03067                                    MUNFLAG                               
033318,000069: 32,3027           43014                           CLEAR    CLEAR                                 
033319,000070: 32,3030           00266                                    P25FLAG                               #  TERMINATE P25 IF IT IS RUNNING.
033320,000071: 32,3031           00270                                    RNDVZFLG                              #  TERMINATE P20 IF IT IS RUNNING
033321,000072: 
033322,000073:                                                                                                  #  ****************************************
033323,000074: 
033324,000075: 32,3032           77201        IGNALG             SETPD    VLOAD                                 #  FIRST SET UP INPUTS FOR RP-TO-R:-
033325,000076: 

Page 779

033327,000078: 32,3033           00001                                    0                                     #    AT 0D LANDING SITE IN MOON FIXED FRAME
033328,000079: 32,3034           02023                                    RLS                                   #    AT 6D ESTIMATED TIME OF LANDING
033329,000080: 32,3035           41525                           PDDL     PUSH                                  #    MPAC NON-ZERO TO INDICATE LUNAR CASE
033330,000081: 32,3036           02401                                    TLAND                                 
033331,000082: 32,3037           37625                           STCALL   TPIP                                  #  ALSO SET TPIP FOR FIRST GUIDANCE PASS
033332,000083: 32,3040           55716                                    RP-TO-R                               
033333,000084: 32,3041           64312                           VSL4     MXV                                   
033334,000085: 32,3042           01734                                    REFSMMAT                              
033335,000086: 32,3043           37635                           STCALL   LAND                                  
033336,000087: 32,3044           71343                                    GUIDINIT                              #  GUIDINIT INITIALIZES WM AND /LAND/
033337,000088: 32,3045           45345                           DLOAD    DSU                                   
033338,000089: 32,3046           02401                                    TLAND                                 
033339,000090: 32,3047           25261                                    GUIDDURN                              
033340,000091: 32,3050           34041                           STCALL   TDEC1                                 #  INTEGRATE STATE FORWARD TO THAT TIME
033341,000092: 32,3051           27060                                    LEMPREC                               
033342,000093: 32,3052           77331                           SSP      VLOAD                                 
033343,000094: 32,3053           03647                                    NIGNLOOP                              
033344,000095: 32,3054           00050                                    40D                                   
033345,000096: 32,3055           06522                                    UNITX                                 
033346,000097: 32,3056           26575                           STOVL    CG                                    
033347,000098: 32,3057           06520                                    UNITY                                 
033348,000099: 32,3060           26603                           STOVL    CG         +6                         
033349,000100: 32,3061           06516                                    UNITZ                                 
033350,000101: 32,3062           16611                           STODL    CG         +14                        
033351,000102: 32,3063           25257                                    99999CON                              
033352,000103: 32,3064           27665                           STOVL    DELTAH                                #  INITIALIZE DELTAH FOR V16N68 DISPLAY
033353,000104: 32,3065           06524                                    ZEROVECS                              
033354,000105: 32,3066           17254                           STODL    UNFC/2                                #  INITIALIZE TRIM VELOCITY CORRECTION TERM
033355,000106: 32,3067           06524                                    HI6ZEROS                              
033356,000107: 32,3070           03643                           STORE    TTF/8                                 
033357,000108: 
033358,000109: 32,3071           77745        IGNALOOP           DLOAD                                          
033359,000110: 32,3072           00015                                    TAT                                   
033360,000111: 32,3073           27561                           STOVL    PIPTIME1                              
033361,000112: 32,3074           00017                                    RATT1                                 
033362,000113: 32,3075           64312                           VSL4     MXV                                   
033363,000114: 32,3076           01734                                    REFSMMAT                              
033364,000115: 32,3077           37521                           STCALL   R                                     
033365,000116: 32,3100           67067                                    MUNGRAV                               
033366,000117: 32,3101           35236                           STCALL   GDT/2                                 
033367,000118: 32,3102           62402                                    ?GUIDSUB                              #  WHICH DELIVERS N PASSES OF GUIDANCE
033368,000119: 
033369,000120:                                                                                                  #  DDUMCALC IS PROGRAMMED AS FOLLOWS:-
033370,000121: 
033371,000122:                                                                                                  #                                        2                                           -
033372,000123:                                                                                                  #             (RIGNZ - RGU )/16 + 16(RGU  )KIGNY/B8 + (RGU - RIGNX)KIGNX/B4 + (ABVAL(VGU) - VIGN)KIGNV/B4
033373,000124:                                                                                                  #                         2             1                 0
033374,000125:                                                                                                  #      DDUM = -------------------------------------------------------------------------------------------
033375,000126:                                                                                                  #                                             10
033376,000127:                                                                                                  #                                            2   (VGU - 16 VGU KIGNX/B4)
033377,000128: 

Page 780

033379,000130:                                                                                                  #                                                    2        0
033380,000131: 
033381,000132:                                                                                                  #  THE NUMERATOR IS SCALED IN METERS AT 2(28).   THE DENOMINATOR IS A VELOCITY IN UNITS OF 2(10)M/CS.
033382,000133:                                                                                                  #  THE QUOTIENT IS THUS A TIME IN UNITS OF 2(18) CENTISECONDS.   THE FINAL SHIFT RESCALES TO UNITS OF 2(28) CS.
033383,000134:                                                                                                  #  THERE IS NO DAMPING FACTOR.   THE CONSTANTS KIGNX/B4, KIGNY/B8 AND KIGNV/B4 ARE ALL NEGATIVE IN SIGN.
033384,000135: 
033385,000136: 32,3103           55646        DDUMCALC           TS       NIGNLOOP                              
033386,000137: 32,3104           06042                           TC       INTPRET                               
033387,000138: 32,3105           57345                           DLOAD    DMPR                                  #  FORM DENOMINATOR FIRST

Note: The above operator and operand are separately underlined with a black pen. The corresponding octal opcode in the resulting listing is marked with a box around it in black pen.

033390,000141: 32,3106           03627                                    VGU                                   
033391,000142: 32,3107           02501                                    KIGNX/B4                              
033392,000143: 32,3110           44232                           SL4R     BDSU                                  
033393,000144: 32,3111           03633                                    VGU        +4                         
033394,000145: 32,3112           45325                           PDDL     DSU                                   
033395,000146: 32,3113           02477                                    RIGNZ                                 
033396,000147: 32,3114           02633                                    RGU        +4                         
033397,000148: 32,3115           65222                           SR4R     PDDL                                  
033398,000149: 32,3116           02631                                    RGU        +2                         
033399,000150: 32,3117           57316                           DSQ      DMPR                                  
033400,000151: 32,3120           02503                                    KIGNY/B8                              
033401,000152: 32,3121           65232                           SL4R     PDDL                                  
033402,000153: 32,3122           02627                                    RGU                                   
033403,000154: 32,3123           57225                           DSU      DMPR                                  
033404,000155: 32,3124           02475                                    RIGNX                                 
033405,000156: 32,3125           02501                                    KIGNX/B4                              
033406,000157: 32,3126           51515                           PDVL     ABVAL                                 
033407,000158: 32,3127           03627                                    VGU                                   
033408,000159: 32,3130           57225                           DSU      DMPR                                  
033409,000160: 32,3131           02473                                    VIGN                                  
033410,000161: 32,3132           02505                                    KIGNV/B4                              
033411,000162: 32,3133           43215                           DAD      DAD                                   
033412,000163: 32,3134           56215                           DAD      DDV                                   
033413,000164: 32,3135           77661                           SRR                                            
033414,000165: 32,3136           21613                                    10D                                   
033415,000166: 
033416,000167: 32,3137           43206                           PUSH     DAD                                   
033417,000168: 32,3140           03561                                    PIPTIME1                              
033418,000169: 32,3141           14041                           STODL    TDEC1                                 #  STORE NEW GUESS FOR NEXT INTEGRATION
033419,000170: 32,3142           45246                           ABS      DSU                                   
033420,000171: 32,3143           25263                                    DDUMCRIT                              
033421,000172: 32,3144           45040                           BMN      CALL                                  
033422,000173: 32,3145           65164                                    DDUMGOOD                              
033423,000174: 32,3146           27412                                    INTSTALL                              
033424,000175: 32,3147           43014                           SET      SET                                   
033425,000176: 32,3150           01473                                    INTYPFLG                              
033426,000177: 32,3151           00063                                    MOONFLAG                              
033427,000178: 32,3152           77745                           DLOAD                                          
033428,000179: 32,3153           03561                                    PIPTIME1                              
033429,000180: 32,3154           25517                           STOVL    TET                                   #  HOPEFULLY ?GUIDSUB DID NOT
033430,000181: 32,3155           00017                                    RATT1                                 #    CLOBBER RATT1 AND VATT1
033431,000182: 

Page 781

033433,000184: 32,3156           25535                           STOVL    RCV                                   
033434,000185: 32,3157           00025                                    VATT1                                 
033435,000186: 32,3160           35543                           STCALL   VCV                                   
033436,000187: 32,3161           27110                                    INTEGRVS                              
033437,000188: 32,3162           77650                           GOTO                                           
033438,000189: 32,3163           65071                                    IGNALOOP                              
033439,000190: 
033440,000191: 32,3164           54335        DDUMGOOD           SLOAD    SR                                    
033441,000192: 32,3165           03423                                    ZOOMTIME                              
033442,000193: 32,3166           20617                                    14D                                   
033443,000194: 32,3167           77621                           BDSU                                           
033444,000195: 32,3170           00041                                    TDEC1                                 
033445,000196: 32,3171           27442                           STOVL    TIG                                   #  COMPUTE DISTANCE LANDING SITE WILL BE
033446,000197: 32,3172           03527                                    V                                     #    OUT OF LM'S ORBITAL PLANE AT IGNITION:
033447,000198: 32,3173           53435                           VXV      UNIT                                  #    SIGN IS + IF LANDING SITE IS TO THE
033448,000199: 32,3174           03521                                    R                                     #    RIGHT, NORTH; - IF TO THE LEFT, SOUTH.
033449,000200: 32,3175           72441                           DOT      SL1                                   
033450,000201: 32,3176           03635                                    LAND                                  
033451,000202: 32,3177           26617        R60INIT            STOVL    OUTOFPLN                              #  INITIALIZATION FOR CALCMANU
033452,000203: 32,3200           03254                                    UNFC/2                                
033453,000204: 32,3201           02621                           STORE    R60VSAVE                              #  STORE UNFC/2 TEMPORARILY IN R60SAVE
033454,000205: 32,3202           77776                           EXIT                                           
033455,000206:                                                                                                  #  ****************************************
033456,000207: 
033457,000208: 32,3203           05353        IGNALGRT           TC       PHASCHNG                              #  PREVENT REPEATING IGNALG
033458,000209: 32,3204           04024                           OCT      04024                                 
033459,000210: 
033460,000211: 32,3205           44362        ASTNCLOK           CS       ASTNDEX                               
033461,000212: 32,3206           04616                           TC       BANKCALL                              
033462,000213: 32,3207           74670                           CADR     STCLOK2                               
033463,000214: 32,3210           15155                           TCF      ENDOFJOB                              #  RETURN IN NEW JOB AND IN EBANK FIVE
033464,000215: 
033465,000216: 32,3211           06042        ASTNRET            TC       INTPRET                               
033466,000217: 32,3212           47131                           SSP      RTB                                   #  GO PICK UP DISPLAY AT END OF R51:
033467,000218: 32,3213           02747                                    QMAJ                                  #    "PROCEED" WILL DO A FINE ALIGNMENT
033468,000219: 32,3214           65216                           FCADR    P63SPOT2                              #    "ENTER" WILL RETURN TO P63SPOT2
033469,000220: 32,3215           31127                                    R51P63                                
033470,000221: 32,3216           53575        P63SPOT2           VLOAD    UNIT                                  #  INITIALIZE KALCMANU FOR BURN ATTITUDE
033471,000222: 32,3217           02621                                    R60VSAVE                              
033472,000223: 32,3220           27773                           STOVL    POINTVSM                              
033473,000224: 32,3221           06522                                    UNITX                                 
033474,000225: 32,3222           03765                           STORE    SCAXIS                                
033475,000226: 32,3223           77776                           EXIT                                           
033476,000227: 
033477,000228: 32,3224           35016                           CAF      EBANK7                                
033478,000229: 32,3225           54003                           TS       EBANK                                 
033479,000230: 
033480,000231: 32,3226           00004                           INHINT                                         
033481,000232: 32,3227           04674                           TC       IBNKCALL                              
033482,000233: 32,3230           40143                           CADR     PFLITEDB                              
033483,000234: 

Page 782

033485,000236: 32,3231           00003                           RELINT                                         
033486,000237: 
033487,000238: 32,3232           04616                           TC       BANKCALL                              
033488,000239: 32,3233           54123                           CADR     R60LEM                                
033489,000240: 
033490,000241: 32,3234           05353                           TC       PHASCHNG                              #  PREVENT RECALLING R60
033491,000242: 32,3235           04024                           OCT      04024                                 
033492,000243: 
033493,000244: 32,3236           34746        P63SPOT3           CA       BIT6                                  #  IS THE LR ANTENNA IN POSITION 1 YET
033494,000245: 32,3237           00006                           EXTEND                                         
033495,000246: 32,3240           02033                           RAND     CHAN33                                
033496,000247: 32,3241           00006                           EXTEND                                         
033497,000248: 32,3242           13250                           BZF      P63SPOT4                              #  BRANCH IF ANTENNA ALREADY IN POSITION 1
033498,000249: 
033499,000250: 32,3243           33255                           CAF      CODE500                               #  ASTRONAUT: PLEASE CRANK THE
033500,000251: 32,3244           04616                           TC       BANKCALL                              #             SILLY THING AROUND
033501,000252: 32,3245           20624                           CADR     GOPERF1                               
033502,000253: 32,3246           16001                           TCF      GOTOPOOH                              #  TERMINATE
033503,000254: 32,3247           13236                           TCF      P63SPOT3                              #  PROCEED    SEE IF HE'S LYING
033504,000255: 
033505,000256: 32,3250           04616        P63SPOT4           TC       BANKCALL                              #  ENTER      INITIALIZE LANDING RADAR
033506,000257: 32,3251           67703                           CADR     SETPOS1                               
033507,000258: 
033508,000259: 32,3252           04635                           TC       POSTJUMP                              #  OFF TO SEE THE WIZARD...
033509,000260: 32,3253           74130                           CADR     BURNBABY                              
033510,000261: 
033511,000262: 
033512,000263:                                                                                                  #                ---------------------------------------
033513,000264: 
033514,000265:                                                                                                  #                       CONSTANTS FOR P63LM AND IGNALG
033515,000266: 
033516,000267: 
033517,000268: 32,3254           02100        P63ADRES           GENADR   P63TABLE                              
033518,000269: 
033519,000270: 
033520,000271: 32,3255     4362               ASTNDEX            =        MD1                                   #  OCT 25;  INDEX FOR CLOKTASK
033521,000272: 
033522,000273: 32,3255           00500        CODE500            OCT      00500                                 
033523,000274: 
033524,000275: 
033525,000276: 32,3256           00035 30373  99999CON           2DEC     30479.7    B-24                       
033526,000277: 32,3260           00004 01610  GUIDDURN           2DEC     +66440     B-28                       #          GUIDDURN +6.64400314 E+2
033527,000278: 32,3262           00000 00010  DDUMCRIT           2DEC     +8         B-28                       #  CRITERION FOR IGNALG CONVERGENCE
033528,000279: 

Page 783

033530,000281:                                                                                                  #                ----------------------------------------
033531,000282: 

Page 784

033533,000284:                                                                                                  #                ****************************************
033534,000285:                                                                                                  #                P68: LANDING CONFIRMATION
033535,000286:                                                                                                  #                ****************************************
033536,000287: 
033537,000288: 34,3271                                           BANK     34                                    
033538,000289: 34,2000                                           SETLOC   F2DPS*34                              
033539,000290: 34,2000                                           BANK                                           
033540,000291: 
033541,000292: 34,3271                                           COUNT*   $$/P6567                              
033542,000293: 
033543,000294: 34,3271           05353        LANDJUNK           TC       PHASCHNG                              
033544,000295: 34,3272           04024                           OCT      04024                                 
033545,000296: 
033546,000297: 34,3273           00004                           INHINT                                         
033547,000298: 34,3274           04616                           TC       BANKCALL                              #  ZERO ATTITUDE ERROR
033548,000299: 34,3275           40154                           CADR     ZATTEROR                              
033549,000300: 
033550,000301: 34,3276           06042                           TC       INTPRET                               #  TO INTERPRETIVE AS TIME IS NOT CRITICAL
033551,000302: 34,3277           77614                           SET                                            #  PREVENT RCS JET FIRINGS IF MODE CONT IS
033552,000303: 34,3300           06460                                    PULSEFLG                              #  IN ATT HOLD
033553,000304: 34,3301           43014                           SET      CLEAR                                 
033554,000305: 34,3302           04067                                    SURFFLAG                              
033555,000306: 34,3303           04666                                    LETABORT                              
033556,000307: 34,3304           77214                           SET      VLOAD                                 
033557,000308: 34,3305           05062                                    APSFLAG                               
033558,000309: 34,3306           01220                                    RN                                    
033559,000310: 34,3307           16032                           STODL    ALPHAV                                
033560,000311: 34,3310           01234                                    PIPTIME                               
033561,000312: 34,3311           45014                           SET      CALL                                  
033562,000313: 34,3312           01463                                    LUNAFLAG                              
033563,000314: 34,3313           26351                                    LAT-LONG                              
033564,000315: 34,3314           77201                           SETPD    VLOAD                                 #  COMPUTE RLS AND STORE IT AWAY
033565,000316: 34,3315           00001                                    0                                     
033566,000317: 34,3316           01220                                    RN                                    
033567,000318: 34,3317           65352                           VSL2     PDDL                                  
033568,000319: 34,3320           01234                                    PIPTIME                               
033569,000320: 34,3321           45006                           PUSH     CALL                                  
033570,000321: 34,3322           51677                                    R-TO-RP                               
033571,000322: 34,3323           02023                           STORE    RLS                                   
033572,000323: 34,3324           77776                           EXIT                                           
033573,000324: 34,3325           33342                           CAF      V06N43*                               #  ASTRONAUT: NOW LOOK WHERE YOU ENDED UP
033574,000325: 34,3326           04616                           TC       BANKCALL                              
033575,000326: 34,3327           20477                           CADR     GOFLASH                               
033576,000327: 34,3330           16001                           TCF      GOTOPOOH                              #  TERMINATE
033577,000328: 34,3331           13333                           TCF      +2                                    #  PROCEED
033578,000329: 34,3332           13325                           TCF      -5                                    #  RECYCLE
033579,000330: 
033580,000331: 
033581,000332: 34,3333           06042                           TC       INTPRET                               
033582,000333: 34,3334           77775                           VLOAD                                          #  INITIALIZE GSAV AND (USING REFMF)
033583,000334: 

Page 785

033585,000336: 34,3335           06522                                    UNITX                                 #  YNBSAV, ZNBSAV AND ATTFLAG FOR P57
033586,000337: 34,3336           36231                           STCALL   GSAV                                  
033587,000338: 34,3337           33471                                    REFMF                                 
033588,000339: 34,3340           77776                           EXIT                                           
033589,000340: 
033590,000341: 34,3341           16001                           TCF      GOTOPOOH                              #  ASTRONAUT: PLEASE SELECT P57
033591,000342: 
033592,000343: 
033593,000344: 34,3342           01453        V06N43*            VN       0643                                  

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