Source Code

These source code files are a reconstruction of Sundance, the Apollo 9 LM (Lunar Module) AGC (Apollo Guidance Computer) flight software, created from binary dumps of original core rope program modules, as follows:
  • B1 — Revision 292
  • B2 — Revision 302
  • B3 — Revision 302
  • B4 — Revision 302
  • B5 — Revision 292
  • B6 — Revision 306
This means that source code does not represent a specific historical revision of Sundance, but rather a mixture of the three released versions. Nonetheless, it is capable of flying the whole Apollo 9 mission. This source code matches the binary dumps, as closely as feasible, but 100% match is not possible, due mostly to changes in memory addresses at which code and variables were allocated in different revisions of Sundance. Refer to this list of explanations for each binary mismatch.

Since only binary dumps (rather than listings) of Sundance are available as source material, all comments and labels are approximate. They have been taken from other AGC programs where possible, or, in some places, written from scratch to match what we believe would have been in the original listing.

027256,000002:                                                                                                  ## Copyright:   Public domain.
027257,000003:                                                                                                  ## Filename:    R31.agc
027258,000004:                                                                                                  ## Purpose:     A section of a reconstructed, mixed version of Sundance
027259,000005:                                                                                                  ##              It is part of the reconstructed source code for the Lunar
027260,000006:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
027261,000007:                                                                                                  ##              No original listings of this program are available;
027262,000008:                                                                                                  ##              instead, this file was created via disassembly of dumps
027263,000009:                                                                                                  ##              of various revisions of Sundance core rope modules.
027264,000010:                                                                                                  ## Assembler:   yaYUL
027265,000011:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
027266,000012:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
027267,000013:                                                                                                  ## Mod history: 2020-06-17 MAS  Created from Luminary 69.
027268,000014:                                                                                                  ##              2021-05-30 ABS  Aligned IAW to field boundary.
027269,000015: 
027270,000016:                                                                                                  ## Sundance 306
027271,000017: 
027272,000018: 34,3411                                           BANK     34                                    
027273,000019: 37,2000                                           SETLOC   R31                                   
027274,000020: 37,2000                                           BANK                                           
027275,000021: 
027276,000022: 37,3237                                           COUNT*   $$/R31                                
027277,000023: 
027278,000024: 37,3237           30105        DISPN5X            CA       FLAGWRD9                              #  TEST R31FLAG (IN SUNDANCE R31FLAG WILL
027279,000025: 37,3240           75023                           MASK     BIT4                                  #      ALWAYS BE SET AS R34 DOES NOT EXIST)
027280,000026: 37,3241           00006                           EXTEND                                         
027281,000027: 37,3242           13245                           BZF      +3                                    
027282,000028: 37,3243           33366                           CAF      V06N54                                #  R31    USE NOUN 54
027283,000029: 37,3244           03246                           TC       +2                                    
027284,000030: 37,3245           33367                           CAF      V06N53                                #  R34    USE NOUN 53
027285,000031: 37,3246           04655                           TC       BANKCALL                              
027286,000032: 37,3247           20245                           CADR     GOMARKFR                              
027287,000033: 37,3250           05642                           TC       B5OFF                                 
027288,000034: 37,3251           05642                           TC       B5OFF                                 
027289,000035: 37,3252           05225                           TC       ENDOFJOB                              
027290,000036: 
027291,000037: 37,3253           35013                           CAF      PRIO4                                 
027292,000038: 37,3254           05216                           TC       PRIOCHNG                              
027293,000039: 37,3255           35044                           CAF      .5SEC                                 
027294,000040: 37,3256           04655                           TC       BANKCALL                              
027295,000041: 37,3257           01730                           CADR     DELAYJOB                              
027296,000042: 
027297,000043: 37,3260           06014        V83                TC       INTPRET                               
027298,000044: 37,3261           77624                           CALL                                           
027299,000045: 37,3262           77504                                    REDOEXTP                              
027300,000046: 37,3263           77650                           GOTO                                           
027301,000047: 37,3264           77270                                    COMPDISP                              
027302,000048: 37,3265           06014        V83CALL            TC       INTPRET                               
027303,000049: 37,3266           77624                           CALL                                           
027304,000050: 37,3267           77370                                    STATEXTP                              #  EXTRAPOLATE STATE VECTORS
027305,000051: 37,3270           52375        COMPDISP           VLOAD    VSU                                   
027306,000052: 37,3271           00001                                    RATT                                  
027307,000053: 37,3272           02215                                    RONE                                  
027308,000054: 37,3273           51406                           PUSH     ABVAL                                 #  RATT-RONE TO 0D               PD = 6
027309,000055: 37,3274           02207                           STORE    RANGE                                 #  METERS B-29
027310,000056: 37,3275           77301                           NORM     VLOAD                                 
027311,000057: 37,3276           00047                                    X1                                    #  RATT-RONE                     PD = 0
027312,000058: 37,3277           53457                           VSL*     UNIT                                  
027313,000059: 37,3300           20201                                    0,1                                   
027314,000060: 37,3301           52315                           PDVL     VSU                                   #  UNIT(LOS) TO 0D              PD = 6
027315,000061: 37,3302           00007                                    VATT                                  
027316,000062: 37,3303           02223                                    VONE                                  
027317,000063: 37,3304           77641                           DOT                                            #  (VATT-VONE).UNIT(LOS)        PD = 0
027318,000064: 37,3305           77752                           SL1                                            
027319,000065: 37,3306           36211                           STCALL   RRATE                                 #  RANGE RATE M/CS B-7
027320,000066: 37,3307           47251                                    CDUTRIG                               #  TO INITIALIZE FOR *NBSM*
027321,000067: 37,3310           53575        R34ANG             VLOAD    UNIT                                  
027322,000068: 37,3311           02215                                    RONE                                  
027323,000069: 37,3312           77715                           PDVL                                           #  UR TO 0D                    PD= 6
027324,000070: 37,3313           06225                                    THISAXIS                              #  UNITX FOR CM, UNITZ FOR LM
027325,000071: 37,3314           77214                           BON      VLOAD                                 #  CHK R31FLAG. ON=R31 THETA, OFF=R34 PHI
027326,000072: 37,3315           04713                                    R31FLAG                               
027327,000073: 37,3316           77320                                    +2                                    #      R31-THETA
027328,000074: 37,3317           06225                                    THISAXIS                              
027329,000075: 37,3320           77624                           CALL                                           
027330,000076: 37,3321           47415                                    *NBSM*                                
027331,000077: 37,3322           41505                           VXM      PUSH                                  #  UXORZ TO 6D                  PD=12D
027332,000078: 37,3323           01736                                    REFSMMAT                              
027333,000079: 37,3324           72431                           VPROJ    VSL2                                  
027334,000080: 37,3325           00001                                    0D                                    
027335,000081: 37,3326           53445                           BVSU     UNIT                                  
027336,000082: 37,3327           00007                                    6D                                    
027337,000083: 37,3330           47315                           PDVL     VXV                                   #  UP/2 TO 12D                  PD=18D
027338,000084: 37,3331           02215                                    RONE                                  
027339,000085: 37,3332           02223                                    VONE                                  
027340,000086: 37,3333           47256                           UNIT     VXV                                   
027341,000087: 37,3334           02215                                    RONE                                  
027342,000088: 37,3335           63241                           DOT      PDVL                                  #  SIGN TO 12D, UP/2 TO MPAC    PD=18D
027343,000089: 37,3336           00015                                    12D                                   
027344,000090: 37,3337           50372                           VSL1     DOT                                   #  UP.UXORZ
027345,000091: 37,3340           00007                                    6D                                    
027346,000092: 37,3341           72565                           SIGN     SL1                                   
027347,000093: 37,3342           00015                                    12D                                   
027348,000094: 37,3343           77726                           ACOS                                           
027349,000095: 37,3344           26213                           STOVL    RTHETA                                
027350,000096: 37,3345           02215                                    RONE                                  
027351,000097: 37,3346           51041                           DOT      BPL                                   
027352,000098: 37,3347           00007                                    6D                                    
027353,000099: 37,3350           77355                                    +5                                    
027354,000100: 37,3351           44345                           DLOAD    BDSU                                  #  IF UXORZ.R NEG, RTHETA = 1 - RTHETA
027355,000101: 37,3352           02213                                    RTHETA                                
027356,000102: 37,3353           06241                                    DPPOSMAX                              
027357,000103: 37,3354           02213                           STORE    RTHETA                                #  RTHETA BETWEEN 0 AND 1 REV.
027358,000104: 37,3355           77776                           EXIT                                           
027359,000105: 37,3356           35022                           CAF      BIT5                                  #  HAVE WE BEEN ANSWERED
027360,000106: 37,3357           71045                           MASK     EXTVBACT                              
027361,000107: 37,3360           00006                           EXTEND                                         
027362,000108: 37,3361           15561                           BZF      ENDEXT                                #  YES, DIE
027363,000109: 
027364,000110: 37,3362           06716                           TC       UNK7766                               
027365,000111: 37,3363           04655                           TC       BANKCALL                              
027366,000112: 37,3364           20271                           CADR     MARKBRAN                              
027367,000113: 
027368,000114: 37,3365           13237                           TCF      DISPN5X                               
027369,000115: 37,3366           01466        V06N54             VN       0654                                  
027370,000116: 37,3367           01465        V06N53             VN       0653                                  
027371,000117: 
027372,000118:                                                                                                  #  THE STATEXTP SUBROUTINE DOES A PRECISION EXTRAPOLATION OF BOTH VEHICLES
027373,000119:                                                                                                  #  STATE VECTORS TO PRESENT TIME AND SAVES THEM AS BASE VECTORS.
027374,000120:                                                                                                  #  IF SERVICER IS OFF ---
027375,000121:                                                                                                  #                  THIS VEHICLES BASE VECTOR IS CONIC EXTRAPOLATED TO
027376,000122:                                                                                                  #                  PRESENT TIME AND SAVED AS RONE, VONE.
027377,000123:                                                                                                  #                  THE OTHER VEHICLES BASE VECTOR IS CONIC EXTRAPOLATED
027378,000124:                                                                                                  #                  TO THE SAME TIME, THE OUTPUT BEING LEFT IN RATT, VATT.
027379,000125:                                                                                                  #  IF SERVICER IS ON ---
027380,000126:                                                                                                  #                  RONE, VONE ARE SET EQUAL TO RN, VN AND THE OTHER
027381,000127:                                                                                                  #                  VEHICLES STATE VECTOR IS PREC. EXTRAPOLATED TO PIPTIME.
027382,000128: 
027383,000129: 37,3370           47020        STATEXTP           STQ      RTB                                   
027384,000130: 37,3371           02120                                    STATEXIT                              
027385,000131: 37,3372           21454                                    LOADTIME                              
027386,000132: 37,3373           34041                           STCALL   TDEC1                                 
027387,000133: 37,3374           27014                                    OTHPREC                               #  GET BASE VECTORS
027388,000134: 37,3375           77775                           VLOAD                                          
027389,000135: 37,3376           00017                                    RATT1                                 
027390,000136: 37,3377           26142                           STOVL    BASEOTP                               #  OTHER POS.
027391,000137: 37,3400           00025                                    VATT1                                 
027392,000138: 37,3401           16122                           STODL    BASEOTV                               #  OTHER VEL.
027393,000139: 37,3402           00015                                    TAT                                   
027394,000140: 37,3403           02116                           STORE    BASETIME                              
027395,000141: 37,3404           34041                           STCALL   TDEC1                                 
027396,000142: 37,3405           27030                                    THISPREC                              
027397,000143: 37,3406           77775                           VLOAD                                          
027398,000144: 37,3407           00017                                    RATT1                                 
027399,000145: 37,3410           26172                           STOVL    BASETHP                               #  THIS POS.
027400,000146: 37,3411           00025                                    VATT1                                 
027401,000147: 37,3412           02107                           STORE    BASETHV                               #  THIS VEL
027402,000148: 37,3413           47014        HAVEBASE           BON      RTB                                   
027403,000149: 37,3414           03711                                    V37FLAG                               
027404,000150: 37,3415           77471                                    GETRVN                                #  IF AVG ON ,GET RN ETC.
027405,000151: 37,3416           21454                                    LOADTIME                              
027406,000152: 37,3417           34041                           STCALL   TDEC1                                 #  BEGIN SET UP FOR CONIC EXTRAP. FOR THIS.
027407,000153: 37,3420           27362                                    INTSTALL                              
027408,000154: 37,3421           43175                           VLOAD    CLEAR                                 
027409,000155: 37,3422           02172                                    BASETHP                               
027410,000156: 37,3423           00263                                    MOONFLAG                              
027411,000157: 37,3424           25535                           STOVL    RCV                                   
027412,000158: 37,3425           02107                                    BASETHV                               
027413,000159: 37,3426           15543                           STODL    VCV                                   
027414,000160: 37,3427           02116                                    BASETIME                              
027415,000161: 37,3430           43014                           BOF      SET                                   #  GET APPROPRIATE MOONFLAG SETTING
027416,000162: 37,3431           04344                                    MOONTHIS                              
027417,000163: 37,3432           77434                                    +2                                    
027418,000164: 37,3433           00063                                    MOONFLAG                              
027419,000165: 37,3434           77614                           SET                                            
027420,000166: 37,3435           01473                                    INTYPFLG                              #  CONIC EXTRAP.
027421,000167: 37,3436           35517                           STCALL   TET                                   
027422,000168: 37,3437           27060                                    INTEGRVS                              #  INTEGRATION --- AT LAST---
027423,000169: 37,3440           77775        OTHCONIC           VLOAD                                          
027424,000170: 37,3441           00001                                    RATT                                  
027425,000171: 37,3442           26215                           STOVL    RONE                                  
027426,000172: 37,3443           00007                                    VATT                                  
027427,000173: 37,3444           36223                           STCALL   VONE                                  #  GET SET FOR CONIC EXTRAP.,OTHER.
027428,000174: 37,3445           27362                                    INTSTALL                              
027429,000175: 37,3446           71214                           SET      DLOAD                                 
027430,000176: 37,3447           01473                                    INTYPFLG                              
027431,000177: 37,3450           00015                                    TAT                                   
027432,000178: 37,3451           00041        OTHINT             STORE    TDEC1                                 
027433,000179: 37,3452           43175                           VLOAD    CLEAR                                 
027434,000180: 37,3453           02142                                    BASEOTP                               
027435,000181: 37,3454           00263                                    MOONFLAG                              
027436,000182: 37,3455           25535                           STOVL    RCV                                   
027437,000183: 37,3456           02122                                    BASEOTV                               
027438,000184: 37,3457           15543                           STODL    VCV                                   
027439,000185: 37,3460           02116                                    BASETIME                              
027440,000186: 37,3461           43014                           BOF      SET                                   
027441,000187: 37,3462           04344                                    MOONTHIS                              
027442,000188: 37,3463           77465                                    +2                                    
027443,000189: 37,3464           00063                                    MOONFLAG                              
027444,000190: 37,3465           35517                           STCALL   TET                                   
027445,000191: 37,3466           27060                                    INTEGRVS                              
027446,000192: 37,3467           77650                           GOTO                                           
027447,000193: 37,3470           02120                                    STATEXIT                              #  THIS VEHICLES POS.,VEL. IN PUSHLIST.
027448,000194: 37,3471           77775        GETRVN             VLOAD                                          
027449,000195: 37,3472           01220                                    RN                                    
027450,000196: 37,3473           26215                           STOVL    RONE                                  
027451,000197: 37,3474           01226                                    VN                                    
027452,000198: 37,3475           16223                           STODL    VONE                                  
027453,000199: 37,3476           01234                                    PIPTIME                               
027454,000200: 37,3477           77624                           CALL                                           
027455,000201: 37,3500           27362                                    INTSTALL                              
027456,000202: 37,3501           52014                           CLEAR    GOTO                                  
027457,000203: 37,3502           01673                                    INTYPFLG                              #  PREC EXTRAP FOR OTHER
027458,000204: 37,3503           77451                                    OTHINT                                
027459,000205: 37,3504           52020        REDOEXTP           STQ      GOTO                                  
027460,000206: 37,3505           02120                                    STATEXIT                              
027461,000207: 37,3506           77413                                    HAVEBASE                              
027462,000208: 

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