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.

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

Page 703

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

Page 704

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

Page 705

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

Page 706

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

Page 707

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

Page 708
This page is empty.

030445,000272: 

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