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.

035803,000002:                                                                                                  ## Copyright:   Public domain.
035804,000003:                                                                                                  ## Filename:    P12.agc
035805,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
035806,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM) 
035807,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
035808,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
035809,000008:                                                                                                  ##              that the code format has been changed to conform to the
035810,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
035811,000010:                                                                                                  ##              original YUL assembler.
035812,000011:                                                                                                  ## Reference:   pp. 831-835
035813,000012:                                                                                                  ## Assembler:   yaYUL
035814,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
035815,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
035816,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
035817,000016:                                                                                                  ##              2017-01-28 RSB  Proofed comment text using octopus/prooferComments
035818,000017:                                                                                                  ##                              and fixed errors found.
035819,000018:                                                                                                  ##              2017-03-09 HG   Transcribed
035820,000019:                                                                                                  ##              2017-03-13 RSB  Proofed comment text via 3-way diff vs
035821,000020:                                                                                                  ##                              Luminary 99 and 131.
035822,000021:                                                                                                  ##              2017-08-26 MAS  Fixed a comment-text error found while transcribing
035823,000022:                                                                                                  ##                              Zerlina 56.
035824,000023: 

Page 831

035826,000025: 24,3677                                           BANK     24                                    
035827,000026: 30,2000                                           SETLOC   P12                                   
035828,000027: 30,2000                                           BANK                                           
035829,000028: 
035830,000029: 30,2061  E7,1515                                  EBANK=   DVCNTR                                
035831,000030: 30,2061                                           COUNT*   $$/P12                                
035832,000031: 
035833,000032: 30,2061           05353        P12LM              TC       PHASCHNG                              
035834,000033: 30,2062           04024                           OCT      04024                                 
035835,000034: 
035836,000035: 30,2063           04616                           TC       BANKCALL                              
035837,000036: 30,2064           11236                           CADR     R02BOTH                               #  CHECK THE STATUS OF THE IMU.
035838,000037: 
035839,000038: 30,2065           06011                           TC       CLRADMOD                              #  INITIALIZE RADMODES FOR R29.
035840,000039: 
035841,000040: 30,2066           36000                           CAF      THRESH2                               #  INITIALIZE DVMON
035842,000041: 30,2067           55250                           TS       DVTHRUSH                              
035843,000042: 30,2070           34751                           CAF      FOUR                                  
035844,000043: 30,2071           55515                           TS       DVCNTR                                
035845,000044: 
035846,000045: 30,2072           34755                           CA       ZERO                                  
035847,000046: 30,2073           55462                           TS       TRKMKCNT                              #  SHOW THAT R29 DOWNLINK DATA IS NOT READY
035848,000047: 
035849,000048: 30,2074           33022                           CAF      V06N33A                               
035850,000049: 30,2075           04616                           TC       BANKCALL                              #  FLASH TIG
035851,000050: 30,2076           20477                           CADR     GOFLASH                               
035852,000051: 30,2077           16001                           TCF      GOTOPOOH                              
035853,000052: 30,2100           12102                           TCF      +2                                    #  PROCEED
035854,000053: 30,2101           12074                           TCF      -5                                    #  ENTER
035855,000054: 
035856,000055: 30,2102           05353                           TC       PHASCHNG                              
035857,000056: 30,2103           04024                           OCT      04024                                 
035858,000057: 
035859,000058: 30,2104           06042                           TC       INTPRET                               
035860,000059: 30,2105           43014                           SET      SET                                   
035861,000060: 30,2106           03067                                    MUNFLAG                               
035862,000061: 30,2107           06464                                    ACC4-2FL                              
035863,000062: 30,2110           43014                           SET      CLEAR                                 
035864,000063: 30,2111           00075                                    R10FLAG                               
035865,000064: 30,2112           00270                                    RNDVZFLG                              
035866,000065: 30,2113           43014                           SET      SET                                   
035867,000066: 30,2114           04464                                    FLPI                                  
035868,000067: 30,2115           04461                                    FLVR                                  
035869,000068: 30,2116           77624                           CALL                                           #  INITIALIZE WM AND /LAND/
035870,000069: 30,2117           71343                                    GUIDINIT                              
035871,000070: 30,2120           77624                           CALL                                           
035872,000071: 30,2121           60251                                    P12INIT                               
035873,000072: 30,2122           77745        P12LMB             DLOAD                                          
035874,000073: 30,2123           25753                                    (TGO)A                                #  SET TGO TO AN INITIAL NOMINAL VALUE.
035875,000074: 30,2124           17517                           STODL    TGO                                   
035876,000075: 

Page 832

035878,000077: 30,2125           03442                                    TIG                                   
035879,000078: 30,2126           34041                           STCALL   TDEC1                                 
035880,000079: 30,2127           27060                                    LEMPREC                               #  ROTATE THE STATE VECTORS TO THE
035881,000080: 30,2130           64375                           VLOAD    MXV                                   #  IGNITION TIME.
035882,000081: 30,2131           00007                                    VATT                                  
035883,000082: 30,2132           01734                                    REFSMMAT                              
035884,000083: 30,2133           77772                           VSL1                                           
035885,000084: 30,2134           27601                           STOVL    V1S                                   #  COMPUTE V1S = VEL(TIG)*2(-7) M/CS.
035886,000085: 30,2135           00001                                    RATT                                  
035887,000086: 30,2136           52521                           MXV      VSL6                                  
035888,000087: 30,2137           01734                                    REFSMMAT                              
035889,000088: 30,2140           37521                           STCALL   R                                     #  COMPUTE R = POS(TIG)*2(-24)M.
035890,000089: 30,2141           67067                                    MUNGRAV                               #  COMPUTE GDT1/2(TIG)*2(-7)M/CS.
035891,000090: 30,2142           53575                           VLOAD    UNIT                                  
035892,000091: 30,2143           03521                                    R                                     
035893,000092: 30,2144           37537                           STCALL   UNIT/R/                               #  COMPUTE UNIT/R/ FOR YCOMP.
035894,000093: 30,2145           57312                                    YCOMP                                 
035895,000094: 30,2146           57461                           SR       DCOMP                                 
035896,000095: 30,2147           20606                                    5D                                    
035897,000096: 30,2150           17643                           STODL    XRANGE                                #  INITIALIZE XRANGE FOR NOUN 76.
035898,000097: 30,2151           31367                                    VINJNOM                               
035899,000098: 30,2152           16277                           STODL    ZDOTD                                 
035900,000099: 30,2153           31371                                    RDOTDNOM                              
035901,000100: 30,2154           02273                           STORE    RDOTD                                 
035902,000101: 30,2155           77776                           EXIT                                           
035903,000102: 
035904,000103: 30,2156           05353                           TC       PHASCHNG                              
035905,000104: 30,2157           04024                           OCT      04024                                 
035906,000105: 
035907,000106: 30,2160           33021        NEWLOAD            CAF      V06N76                                #  FLASH CROSS-RANGE AND APOLUNE VALUES.
035908,000107: 30,2161           04616                           TC       BANKCALL                              
035909,000108: 30,2162           20477                           CADR     GOFLASH                               
035910,000109: 30,2163           16001                           TCF      GOTOPOOH                              
035911,000110: 30,2164           12166                           TCF      +2                                    #  PROCEED
035912,000111: 30,2165           12160                           TCF      NEWLOAD                               #  ENTER NEW DATA.
035913,000112: 
035914,000113: 30,2166           32314                           CAF      P12ADRES                              
035915,000114: 30,2167           55455                           TS       WHICH                                 
035916,000115: 
035917,000116: 30,2170           05353                           TC       PHASCHNG                              
035918,000117: 30,2171           04024                           OCT      04024                                 
035919,000118: 
035920,000119: 30,2172           06042                           TC       INTPRET                               
035921,000120: 30,2173           54345                           DLOAD    SL                                    
035922,000121: 30,2174           03643                                    XRANGE                                
035923,000122: 30,2175           20206                                    5D                                    
035924,000123: 30,2176           77615                           DAD                                            
035925,000124: 30,2177           02335                                    Y                                     
035926,000125: 30,2200           27633                           STOVL    YCO                                   
035927,000126: 30,2201           03537                                    UNIT/R/                               
035928,000127: 

Page 833

035930,000129: 30,2202           53361                           VXSC     VAD                                   
035931,000130: 30,2203           31365                                    49FPS                                 
035932,000131: 30,2204           03601                                    V1S                                   
035933,000132: 30,2205           03527                           STORE    V                                     #  V(TIPOVER) = V(IGN) + 57FPS (UNIT/R/)
035934,000133: 30,2206           72441                           DOT      SL1                                   
035935,000134: 30,2207           03537                                    UNIT/R/                               
035936,000135: 30,2210           27474                           STOVL    RDOT                                  #  RDOT * 2(-7)
035937,000136: 30,2211           03537                                    UNIT/R/                               
035938,000137: 30,2212           53435                           VXV      UNIT                                  
035939,000138: 30,2213           03720                                    QAXIS                                 
035940,000139: 30,2214           37726                           STCALL   ZAXIS1                                
035941,000140: 30,2215           60315                                    ASCENT                                
035942,000141: 30,2216           77745        P12RET             DLOAD                                          
035943,000142: 30,2217           02361                                    ATP                                   #  ATP(2)*2(18)
035944,000143: 30,2220           65316                           DSQ      PDDL                                  
035945,000144: 30,2221           02355                                    ATY                                   #  ATY(2)*2(18)
035946,000145: 30,2222           43316                           DSQ      DAD                                   
035947,000146: 30,2223           75454                           BZE      SQRT                                  
035948,000147: 30,2224           60230                                    YAWDUN                                
035949,000148: 30,2225           55352                           SL1      BDDV                                  
035950,000149: 30,2226           02355                                    ATY                                   
035951,000150: 30,2227           77736                           ARCSIN                                         
035952,000151: 30,2230           26363        YAWDUN             STOVL    YAW                                   
035953,000152: 30,2231           03254                                    UNFC/2                                
035954,000153: 30,2232           50256                           UNIT     DOT                                   
035955,000154: 30,2233           03537                                    UNIT/R/                               
035956,000155: 30,2234           65552                           SL1      ARCCOS                                
035957,000156: 30,2235           77676                           DCOMP                                          
035958,000157: 30,2236           02365                           STORE    PITCH                                 
035959,000158: 30,2237           77776                           EXIT                                           
035960,000159: 30,2240           05353                           TC       PHASCHNG                              
035961,000160: 30,2241           04024                           OCT      04024                                 
035962,000161: 
035963,000162: 30,2242           00004                           INHINT                                         
035964,000163: 30,2243           04674                           TC       IBNKCALL                              
035965,000164: 30,2244           40143                           CADR     PFLITEDB                              
035966,000165: 30,2245           05516                           TC       DOWNFLAG                              
035967,000166: 30,2246           00213                           ADRES    FLPI                                  
035968,000167: 
035969,000168: 30,2247           04635                           TC       POSTJUMP                              
035970,000169: 30,2250           74130                           CADR     BURNBABY                              
035971,000170: 
035972,000171: 30,2251           77745        P12INIT            DLOAD                                          #  INITIALIZE ENGINE DATA. USED FOR P12 AND
035973,000172: 30,2252           16013                                    (1/DV)A                               #  P71.
035974,000173: 30,2253           03641                           STORE    1/DV3                                 
035975,000174: 30,2254           03637                           STORE    1/DV2                                 
035976,000175: 30,2255           17635                           STODL    1/DV1                                 
035977,000176: 30,2256           16017                                    (AT)A                                 
035978,000177: 30,2257           16263                           STODL    AT                                    
035979,000178: 30,2260           16021                                    (TBUP)A                               
035980,000179: 

Page 834

035982,000181: 30,2261           16271                           STODL    TBUP                                  
035983,000182: 30,2262           34013                                    ATDECAY                               
035984,000183: 30,2263           54276                           DCOMP    SL                                    
035985,000184: 30,2264           20214                                    11D                                   
035986,000185: 30,2265           02267                           STORE    TTO                                   
035987,000186: 30,2266           57535                           SLOAD    DCOMP                                 
035988,000187: 30,2267           26001                                    APSVEX                                
035989,000188: 30,2270           77702                           SR2                                            
035990,000189: 30,2271           02265                           STORE    VE                                    
035991,000190: 30,2272           43414                           BOFF     RVQ                                   
035992,000191: 30,2273           04747                                    FLAP                                  
035993,000192: 30,2274           60275                                    COMMINIT                              
035994,000193: 30,2275           43345        COMMINIT           DLOAD    DAD                                   #  INITIALIZE TARGET DATA.  USED BY P12, P70
035995,000194: 30,2276           25751                                    HINJECT                               #  AND P71 IF IT DOES NOT FOLLOW P70.
035996,000195: 30,2277           02333                                    /LAND/                                
035997,000196: 30,2300           17631                           STODL    RCO                                   
035998,000197: 30,2301           06524                                    HI6ZEROS                              
035999,000198: 30,2302           03654                           STORE    TXO                                   
036000,000199: 30,2303           03633                           STORE    YCO                                   
036001,000200: 30,2304           26275                           STOVL    YDOTD                                 
036002,000201: 30,2305           01563                                    VRECTCSM                              
036003,000202: 30,2306           64235                           VXV      MXV                                   
036004,000203: 30,2307           01555                                    RRECTCSM                              
036005,000204: 30,2310           01734                                    REFSMMAT                              
036006,000205: 30,2311           77656                           UNIT                                           
036007,000206: 30,2312           03720                           STORE    QAXIS                                 
036008,000207: 30,2313           77616                           RVQ                                            
036009,000208: 
036010,000209: 30,2314           02024        P12ADRES           REMADR   P12TABLE                              
036011,000210: 
036012,000211: 34,2000                                           SETLOC   ASENT8                                
036013,000212: 34,2000                                           BANK                                           
036014,000213: 34,3343                                           COUNT*   $$/P12                                
036015,000214: 
036016,000215: 34,3343           40220        GUIDINIT           STQ      SETPD                                 
036017,000216: 34,3344           01163                                    TEMPR60                               
036018,000217: 34,3345           00001                                    0D                                    
036019,000218: 34,3346           41575                           VLOAD    PUSH                                  
036020,000219: 34,3347           06516                                    UNITZ                                 
036021,000220: 34,3350           41434                           RTB      PUSH                                  
036022,000221: 34,3351           21574                                    LOADTIME                              
036023,000222: 34,3352           77624                           CALL                                           
036024,000223: 34,3353           55716                                    RP-TO-R                               
036025,000224: 34,3354           74321                           MXV      VXSC                                  
036026,000225: 34,3355           01734                                    REFSMMAT                              
036027,000226: 34,3356           16027                                    MOONRATE                              
036028,000227: 34,3357           26325                           STOVL    WM                                    
036029,000228: 34,3360           02023                                    RLS                                   
036030,000229: 34,3361           52446                           ABVAL    SL3                                   
036031,000230: 34,3362           36333                           STCALL   /LAND/                                
036032,000231: 

Page 835

036034,000233: 34,3363           01163                                    TEMPR60                               
036035,000234: 
036036,000235: 34,3364           00046 07374  49FPS              2DEC     .149352    B-6                        #  EXPECTED RDOT AT TIPOVER
036037,000236: 34,3366           04145 15527  VINJNOM            2DEC     16.7924    B-7                        #  5509.5 FPS(APO=30NM WITH RDOT=19.5FPS)
036038,000237: 34,3370           00007 23346  RDOTDNOM           2DEC     .059436    B-7                        #  19.5 FPS
036039,000238: 
036040,000239: 

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