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
	20'35 OCT. 28,1968
Note that the date is the date of the printout, not the date of the program revision.

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

Page 703

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

Page 704

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

Page 705

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

Page 706

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

Page 707

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

Page 708
This page is empty.

030435,000272: 

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