Source Code

These source-code files were from the printout at the MIT Museum, with many thanks to Deborah Douglas, the Museum's Curator of Science and Technology, for releasing it to us. The printout was digitally photographed by Paul Fjeld. A team of volunteers transcribed the source code manually from these images or, where appropriate, modified already-transcribed but similar source Luminary 131 (Apollo 13) source code to agree with the images from the printout. Note that the page images presented online are of reduced quality, and that higher-quality images are available. Report any conversion errors or legibility problems in page images to info@sandroid.org. Notations on the program listing read, in part:

	GAP:  ASSEMBLE REVISION 001 OF AGC PROGRAM LMY99 BY NASA 2021112-061
	16:27 JULY 14,1969
Note that the date is the date of the printout, not the date of the program revision.

030177,000002:                                                                                                  ## Copyright:   Public domain.
030178,000003:                                                                                                  ## Filename:    R31.agc
030179,000004:                                                                                                  ## Purpose:     Part of the source code for Luminary 1A build 099.
030180,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
030181,000006:                                                                                                  ##              Apollo Guidance Computer (AGC), for Apollo 11.
030182,000007:                                                                                                  ## Assembler:   yaYUL
030183,000008:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
030184,000009:                                                                                                  ## Website:     www.ibiblio.org/apollo.
030185,000010:                                                                                                  ## Pages:       703-708
030186,000011:                                                                                                  ## Mod history: 2009-05-19 RSB  Adapted from the corresponding 
030187,000012:                                                                                                  ##                              Luminary131 file, using page 
030188,000013:                                                                                                  ##                              images from Luminary 1A.
030189,000014:                                                                                                  ##              2016-12-14 RSB  Proofed text comments with octopus/ProoferComments
030190,000015:                                                                                                  ##                              and corrected the errors found.
030191,000016:                                                                                                  ##              2017-03-09 RSB  Comment-text fixes noted in proofing Luminary 116.
030192,000017: 
030193,000018:                                                                                                  ## This source code has been transcribed or otherwise adapted from
030194,000019:                                                                                                  ## digitized images of a hardcopy from the MIT Museum.  The digitization
030195,000020:                                                                                                  ## was performed by Paul Fjeld, and arranged for by Deborah Douglas of
030196,000021:                                                                                                  ## the Museum.  Many thanks to both.  The images (with suitable reduction
030197,000022:                                                                                                  ## in storage size and consequent reduction in image quality as well) are
030198,000023:                                                                                                  ## available online at www.ibiblio.org/apollo.  If for some reason you
030199,000024:                                                                                                  ## find that the images are illegible, contact me at info@sandroid.org
030200,000025:                                                                                                  ## about getting access to the (much) higher-quality images which Paul
030201,000026:                                                                                                  ## actually created.
030202,000027:                                                                                                  ##
030203,000028:                                                                                                  ## Notations on the hardcopy document read, in part:
030204,000029:                                                                                                  ##
030205,000030:                                                                                                  ##      Assemble revision 001 of AGC program LMY99 by NASA 2021112-61
030206,000031:                                                                                                  ##      16:27 JULY 14, 1969 
030207,000032: 

Page 703

030209,000034: 40,3674                                           BANK     40                                    
030210,000035: 40,2000                                           SETLOC   R31LOC                                
030211,000036: 40,2000                                           BANK                                           
030212,000037: 
030213,000038: 40,3674                                           COUNT*   $$/R31                                
030214,000039: 
030215,000040: 40,3674           35015        R31CALL            CAF      PRIO3                                 
030216,000041: 40,3675           05105                           TC       FINDVAC                               
030217,000042: 40,3676  E7,1470                                  EBANK=   SUBEXIT                               
030218,000043: 40,3676           03121 76067                     2CADR    V83CALL                               
030219,000044: 
030220,000045: 40,3700           05221        DSPDELAY           TC       FIXDELAY                              
030221,000046: 40,3701           00144                           DEC      100        B-14                       
030222,000047: 40,3702           31044                           CA       EXTVBACT                              
030223,000048: 40,3703           74740                           MASK     BIT12                                 
030224,000049: 40,3704           00006                           EXTEND                                         
030225,000050: 40,3705           13700                           BZF      DSPDELAY                              
030226,000051: 
030227,000052: 40,3706           35017                           CAF      PRIO5                                 
030228,000053: 40,3707           05072                           TC       NOVAC                                 
030229,000054: 40,3710  E7,1611                                  EBANK=   TSTRT                                 
030230,000055: 40,3710           03113 76067                     2CADR    DISPN5X                               
030231,000056: 
030232,000057: 40,3712           15261                           TCF      TASKOVER                              
030233,000058: 
030234,000059: 37,3113                                           BANK     37                                    
030235,000060: 37,2000                                           SETLOC   R31                                   
030236,000061: 37,2000                                           BANK                                           
030237,000062: 37,3113                                           COUNT*   $$/R31                                
030238,000063: 
030239,000064: 37,3113           33407        DISPN5X            CAF      V16N54                                
030240,000065: 37,3114           04616                           TC       BANKCALL                              
030241,000066: 37,3115           20334                           CADR     GOMARKF                               
030242,000067: 37,3116           05563                           TC       B5OFF                                 
030243,000068: 37,3117           05563                           TC       B5OFF                                 
030244,000069: 37,3120           13113                           TCF      DISPN5X                               
030245,000070: 
030246,000071: 37,3121           40103        V83CALL            CS       FLAGWRD7                              #  TEST AVERAGE G FLAG
030247,000072: 37,3122           74747                           MASK     AVEGFBIT                              
030248,000073: 37,3123           00006                           EXTEND                                         
030249,000074: 37,3124           13377                           BZF      MUNG?                                 #  ON - TEST MUNFLAG
030250,000075: 
030251,000076: 37,3125           40104                           CS       FLAGWRD8                              
030252,000077: 37,3126           74744                           MASK     SURFFBIT                              
030253,000078: 37,3127           00006                           EXTEND                                         
030254,000079: 37,3130           13403                           BZF      ONEBASE                               #  ON SURFACE - BYPASS LEMPREC
030255,000080: 
030256,000081: 37,3131           06037                           TC       INTPRET                               #  EXTRAPOLATE BOTH STATE VECTORS
030257,000082: 37,3132           77634                           RTB                                            

Page 704

030259,000084: 37,3133           21573                                    LOADTIME                              
030260,000085: 37,3134           34041                           STCALL   TDEC1                                 
030261,000086: 37,3135           27057                                    LEMPREC                               #  PRECISION BASE VECTOR FOR LM
030262,000087: 37,3136           77775                           VLOAD                                          
030263,000088: 37,3137           00017                                    RATT1                                 
030264,000089: 37,3140           26170                           STOVL    BASETHP                               
030265,000090: 37,3141           00025                                    VATT1                                 
030266,000091: 37,3142           16105                           STODL    BASETHV                               
030267,000092: 37,3143           00015                                    TAT                                   
030268,000093: 37,3144           02114        DOCMBASE           STORE    BASETIME                              #  PRECISION BASE VECTOR FOR CM
030269,000094: 37,3145           34041                           STCALL   TDEC1                                 
030270,000095: 37,3146           27043                                    CSMPREC                               
030271,000096: 37,3147           77775                           VLOAD                                          
030272,000097: 37,3150           00017                                    RATT1                                 
030273,000098: 37,3151           26140                           STOVL    BASEOTP                               
030274,000099: 37,3152           00025                                    VATT1                                 
030275,000100: 37,3153           02120                           STORE    BASEOTV                               
030276,000101: 37,3154           77776                           EXIT                                           
030277,000102: 
030278,000103: 37,3155           40103        REV83              CS       FLAGWRD7                              
030279,000104: 37,3156           74747                           MASK     AVEGFBIT                              
030280,000105: 37,3157           00006                           EXTEND                                         
030281,000106: 37,3160           13326                           BZF      GETRVN                                #  IF AVEGFLAG SET, USE RN,VN
030282,000107: 
030283,000108: 37,3161           40104                           CS       FLAGWRD8                              
030284,000109: 37,3162           74744                           MASK     SURFFBIT                              
030285,000110: 37,3163           00006                           EXTEND                                         
030286,000111: 37,3164           13370                           BZF      R31SURF                               #  IF ON SURFACE, USE LEMAREC
030287,000112: 
030288,000113: 37,3165           06037                           TC       INTPRET                               #  DO CONIC EXTRAPOLATION FOR BOTH VEHICLES
030289,000114: 37,3166           77634                           RTB                                            
030290,000115: 37,3167           21573                                    LOADTIME                              
030291,000116: 37,3170           34041                           STCALL   TDEC1                                 
030292,000117: 37,3171           27414                                    INTSTALL                              
030293,000118: 37,3172           43175                           VLOAD    CLEAR                                 
030294,000119: 37,3173           02170                                    BASETHP                               
030295,000120: 37,3174           00263                                    MOONFLAG                              
030296,000121: 37,3175           25535                           STOVL    RCV                                   
030297,000122: 37,3176           02105                                    BASETHV                               
030298,000123: 37,3177           15543                           STODL    VCV                                   
030299,000124: 37,3200           02114                                    BASETIME                              
030300,000125: 37,3201           43014                           BOF      SET                                   #  GET APPROPRIATE MOONFLAG SETTING
030301,000126: 37,3202           04344                                    MOONTHIS                              
030302,000127: 37,3203           77205                                    +2                                    
030303,000128: 37,3204           00063                                    MOONFLAG                              
030304,000129: 37,3205           77614                           SET                                            
030305,000130: 37,3206           01473                                    INTYPFLG                              #  CONIC EXTRAP.
030306,000131: 37,3207           35517                           STCALL   TET                                   
030307,000132: 37,3210           27107                                    INTEGRVS                              #  INTEGRATION --- AT LAST ---
030308,000133: 37,3211           77775        OTHCONIC           VLOAD                                          

Page 705

030310,000135: 37,3212           00001                                    RATT                                  
030311,000136: 37,3213           26207                           STOVL    RONE                                  
030312,000137: 37,3214           00007                                    VATT                                  
030313,000138: 37,3215           36215                           STCALL   VONE                                  #  GET SET FOR CONIC EXTRAP., OTHER.
030314,000139: 37,3216           27414                                    INTSTALL                              
030315,000140: 37,3217           71214                           SET      DLOAD                                 
030316,000141: 37,3220           01473                                    INTYPFLG                              
030317,000142: 37,3221           00015                                    TAT                                   
030318,000143: 37,3222           00041        OTHINT             STORE    TDEC1                                 
030319,000144: 37,3223           43175                           VLOAD    CLEAR                                 
030320,000145: 37,3224           02140                                    BASEOTP                               
030321,000146: 37,3225           00263                                    MOONFLAG                              
030322,000147: 37,3226           25535                           STOVL    RCV                                   
030323,000148: 37,3227           02120                                    BASEOTV                               
030324,000149: 37,3230           15543                           STODL    VCV                                   
030325,000150: 37,3231           02114                                    BASETIME                              
030326,000151: 37,3232           43014                           BOF      SET                                   
030327,000152: 37,3233           04344                                    MOONTHIS                              
030328,000153: 37,3234           77236                                    +2                                    
030329,000154: 37,3235           00063                                    MOONFLAG                              
030330,000155: 37,3236           35517                           STCALL   TET                                   
030331,000156: 37,3237           27107                                    INTEGRVS                              
030332,000157: 37,3240           52375        COMPDISP           VLOAD    VSU                                   
030333,000158: 37,3241           00001                                    RATT                                  
030334,000159: 37,3242           02207                                    RONE                                  
030335,000160: 37,3243           65234                           RTB      PDDL                                  
030336,000161: 37,3244           21724                                    NORMUNX1                              #  UNIT(RANGE) TO PD 0-5
030337,000162: 37,3245           00045                                    36D                                   
030338,000163: 37,3246           77657                           SL*                                            #  RESCALE AFTER NORMUNIT
030339,000164: 37,3247           20201                                    0,1                                   
030340,000165: 37,3250           26201                           STOVL    RANGE                                 #  SCALED 2(29)M
030341,000166: 37,3251           00007                                    VATT                                  
030342,000167: 37,3252           50251                           VSU      DOT                                   #  (VCM-VLM).UNIT(LOS), PD=0
030343,000168: 37,3253           02215                                    VONE                                  
030344,000169: 37,3254           77752                           SL1                                            #  SCALED 2(7)M/CS
030345,000170: 37,3255           26203                           STOVL    RRATE                                 
030346,000171: 37,3256           02207                                    RONE                                  
030347,000172: 37,3257           63256                           UNIT     PDVL                                  #  UNIT(R) TO PD 0-5
030348,000173: 37,3260           06514                                    UNITZ                                 
030349,000174: 37,3261           77624                           CALL                                           
030350,000175: 37,3262           47661                                    CDU*NBSM                              
030351,000176: 37,3263           41505                           VXM      PUSH                                  #  UNIT(Z)/4 TO PD 6-11
030352,000177: 37,3264           01734                                    REFSMMAT                              
030353,000178: 37,3265           72431                           VPROJ    VSL2                                  #  UNIT(P)=UNIT(UZ-(UZ)PROJ(UR))
030354,000179: 37,3266           00001                                    0D                                    
030355,000180: 37,3267           53445                           BVSU     UNIT                                  
030356,000181: 37,3270           00007                                    6D                                    
030357,000182: 37,3271           47315                           PDVL     VXV                                   #  UNIT(P) TO PD 12-17
030358,000183: 37,3272           00001                                    0D                                    #  UNIT(RL)
030359,000184: 37,3273           02215                                    VONE                                  

Page 706

030361,000186: 37,3274           50235                           VXV      DOT                                   #  (UR * VL) * UR . U(P)
030362,000187: 37,3275           00001                                    0D                                    
030363,000188: 37,3276           00015                                    12D                                   
030364,000189: 37,3277           77715                           PDVL                                           #  SIGN TO 12-13, LOAD U(P)
030365,000190: 37,3300           75241                           DOT      SIGN                                  
030366,000191: 37,3301           00007                                    6D                                    
030367,000192: 37,3302           00015                                    12D                                   
030368,000193: 37,3303           65512                           SL2      ACOS                                  #  ARCCOS(UP.UZ(SIGN))
030369,000194: 37,3304           26205                           STOVL    RTHETA                                
030370,000195: 37,3305           00001                                    0D                                    
030371,000196: 37,3306           51041                           DOT      BPL                                   #  IF UR.UZ NEG,
030372,000197: 37,3307           00007                                    6D                                    #        RTHETA = 1 - RTHETA
030373,000198: 37,3310           77315                                    +5                                    
030374,000199: 37,3311           45345                           DLOAD    DSU                                   
030375,000200: 37,3312           06530                                    DPPOSMAX                              
030376,000201: 37,3313           02205                                    RTHETA                                
030377,000202: 37,3314           02205                           STORE    RTHETA                                
030378,000203: 37,3315           77776                           EXIT                                           
030379,000204: 
030380,000205: 37,3316           34747                           CA       BIT5                                  
030381,000206: 37,3317           71044                           MASK     EXTVBACT                              
030382,000207: 37,3320           00006                           EXTEND                                         #  IF ANSWERED,
030383,000208: 37,3321           15472                           BZF      ENDEXT                                #        TERMINATE
030384,000209: 
030385,000210: 37,3322           41044                           CS       EXTVBACT                              
030386,000211: 37,3323           74740                           MASK     BIT12                                 
030387,000212: 37,3324           27044                           ADS      EXTVBACT                              #  SET BIT 12
030388,000213: 37,3325           13155                           TCF      REV83                                 #  AND START AGAIN.
030389,000214: 
030390,000215: 37,3326           37710        GETRVN             CA       PRIO22                                #  INHIBIT SERVICER
030391,000216: 37,3327           05146                           TC       PRIOCHNG                              
030392,000217: 37,3330           06037                           TC       INTPRET                               
030393,000218: 37,3331           40375                           VLOAD    SETPD                                 
030394,000219: 37,3332           01221                                    RN                                    #  LM STATE VECTOR IN RN,VN
030395,000220: 37,3333           00001                                    0                                     
030396,000221: 37,3334           26207                           STOVL    RONE                                  
030397,000222: 37,3335           01227                                    VN                                    
030398,000223: 37,3336           26215                           STOVL    VONE                                  #  LOAD R(CSM),V(CSM) IN CASE MUNFLAG SET
030399,000224: 37,3337           01726                                    V(CSM)                                #  (TO INSURE TIME COMPATABILITY)
030400,000225: 37,3340           65315                           PDVL     PDDL                                  
030401,000226: 37,3341           01720                                    R(CSM)                                
030402,000227: 37,3342           01235                                    PIPTIME                               
030403,000228: 37,3343           77776                           EXIT                                           
030404,000229: 37,3344           35015                           CA       PRIO3                                 
030405,000230: 37,3345           05146                           TC       PRIOCHNG                              
030406,000231: 37,3346           06037                           TC       INTPRET                               
030407,000232: 37,3347           77214                           BOFF     VLOAD                                 
030408,000233: 37,3350           03347                                    MUNFLAG                               
030409,000234: 37,3351           77363                                    GETRVN2                               #  IF MUNFLAG RESET, DO CM DELTA PRECISION

Page 707

030411,000236: 37,3352           60505                           VXM      VSR4                                  #  CHANGE TO REFERENCE SYSTEM AND RESCALE
030412,000237: 37,3353           01734                                    REFSMMAT                              
030413,000238: 37,3354           77715                           PDVL                                           #  R TO PD 0-5
030414,000239: 37,3355           76505                           VXM      VSL1                                  
030415,000240: 37,3356           01734                                    REFSMMAT                              
030416,000241: 37,3357           40206                           PUSH     SETPD                                 #  V TO PD 5-11
030417,000242: 37,3360           00001                                    0                                     
030418,000243: 37,3361           77650                           GOTO                                           
030419,000244: 37,3362           77240                                    COMPDISP                              
030420,000245: 
030421,000246: 37,3363           77624        GETRVN2            CALL                                           
030422,000247: 37,3364           27414                                    INTSTALL                              
030423,000248: 37,3365           52014                           CLEAR    GOTO                                  
030424,000249: 37,3366           01673                                    INTYPFLG                              #  PREC EXTRAP FOR OTHER
030425,000250: 37,3367           77222                                    OTHINT                                
030426,000251: 37,3370           06037        R31SURF            TC       INTPRET                               
030427,000252: 37,3371           77634                           RTB                                            #  LM IS ON SURFACE, SO PRECISION
030428,000253: 37,3372           21573                                    LOADTIME                              #  INTEGRATION USES PLANETARY INERTIAL
030429,000254: 37,3373           34041                           STCALL   TDEC1                                 #  ORIENTATION SUBROUTINE
030430,000255: 37,3374           27057                                    LEMPREC                               
030431,000256: 37,3375           77650                           GOTO                                           #  DO CSM CONIC
030432,000257: 37,3376           77211                                    OTHCONIC                              
030433,000258: 37,3377           40102        MUNG?              CS       FLAGWRD6                              
030434,000259: 37,3400           74744                           MASK     MUNFLBIT                              
030435,000260: 37,3401           00006                           EXTEND                                         
030436,000261: 37,3402           13326                           BZF      GETRVN                                #  IF MUNFLAG SET, CSM BASE NOT NEEDED
030437,000262: 
030438,000263: 37,3403           06037        ONEBASE            TC       INTPRET                               #  GET CSM BASE VECTOR
030439,000264: 37,3404           52034                           RTB      GOTO                                  
030440,000265: 37,3405           21573                                    LOADTIME                              
030441,000266: 37,3406           77144                                    DOCMBASE                              
030442,000267: 
030443,000268: 37,3407           04066        V16N54             VN       1654                                  
030444,000269: 

Page 708
This page is empty.

030447,000272: 

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