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.

025234,000002:                                                                                                  ## Copyright:   Public domain.
025235,000003:                                                                                                  ## Filename:    GENERAL_LAMBERT_AIMPOINT_GUIDANCE.agc
025236,000004:                                                                                                  ## Purpose:     A section of a reconstructed, mixed version of Sundance
025237,000005:                                                                                                  ##              It is part of the reconstructed source code for the Lunar
025238,000006:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
025239,000007:                                                                                                  ##              No original listings of this program are available;
025240,000008:                                                                                                  ##              instead, this file was created via disassembly of dumps
025241,000009:                                                                                                  ##              of various revisions of Sundance core rope modules.
025242,000010:                                                                                                  ## Assembler:   yaYUL
025243,000011:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
025244,000012:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
025245,000013:                                                                                                  ## Mod history: 2020-06-17 MAS  Created from Luminary 69.
025246,000014: 
025247,000015:                                                                                                  ## Sundance 292
025248,000016: 
025249,000017:                                                                                                  #  GENERAL LAMBERT AIMPOINT GUIDANCE **
025250,000018:                                                                                                  #  WRITTEN BY RAMA M AIYAWAR
025251,000019: 
025252,000020:                                                                                                  #  PROGRAM P-31 DESCRIPTION **
025253,000021: 
025254,000022:                                                                                                  #  1.    TO ACCEPT TARGETING PARAMETERS OBTAINED FROM A SOURCE EXTERNAL
025255,000023:                                                                                                  #        TO THE LEM AND COMPUTE THERE FROM THE REQUIRED-VELOCITY AND
025256,000024:                                                                                                  #        OTHER INITIAL CONDITIONS REQUIRED BY LM FOR DESIRED MANEUVER.
025257,000025:                                                                                                  #        THE TARGETING PARAMETERS ARE TIG (TIME OF IGNITION), TARGET 
025258,000026:                                                                                                  #        VECTOR (RTARG), AND THE TIME FROM TIG UNTIL THE TARGET IS
025259,000027:                                                                                                  #        REACHED(DELLT4), DESIRED TIME OF FLIGHT FROM RINIT TO RTARG..
025260,000028: 
025261,000029:                                                                                                  #  ASSUMPTIONS **
025262,000030: 
025263,000031:                                                                                                  #  1.    THE TARGET PARAMETERS MAY HAVE BEEN LOADED PRIOR TO THE
025264,000032:                                                                                                  #        EXECUTION OF THIS PROGRAM.
025265,000033:                                                                                                  #  2.    THIS PROGRAM IS APPLICABLE IN EITHER EARTH OR LUNAR ORBIT.
025266,000034:                                                                                                  #  3.    THIS PROGRAM IS DESIGNED FOR ONE-MAN OPERATION, AND SHOULD
025267,000035:                                                                                                  #        BE SELECTED BY THE ASTRONAUT BY DSKY ENTRY V37 E31.
025268,000036: 
025269,000037:                                                                                                  #  SUBROUTINES USED **
025270,000038:                                                                                                  #  
025271,000039:                                                                                                  #  MANUPARM, TTG/N35, R02BOTH, MIDGIM, DISPMGA, FLAGDOWN, BANKCALL,
025272,000040:                                                                                                  #  GOTOPOOH, ENDOFJOB, PHASCHNG, GOFLASHR, GOFLASH.
025273,000041: 
025274,000042:                                                                                                  #  MANUPARM      CALCULATES APOGEE, PERIGEE ALTITUDES AND DELTAV DESIRED
025275,000043:                                                                                                  #                FOR THE MANEUVER.
025276,000044: 
025277,000045:                                                                                                  #  TTG/N35       CLOCKTASK - UPDATES CLOCK.
025278,000046: 
025279,000047:                                                                                                  #  MIDGIM        CALCULATES MIDDLE GIMBAL ANGLE FOR DISPLAY.
025280,000048: 
025281,000049:                                                                                                  #  R02BOTH       IMU - STATUS CHECK ROUTINE.
025282,000050: 
025283,000051:                                                                                                  #  DISPLAYS USED IN P-31LM **
025284,000052: 
025285,000053:                                                                                                  #  V06N33        DISPLAY SOTRED TIG (IN HRS. MINS. SECS)
025286,000054:                                                                                                  #  V06N42        DISPLAY APOGEE, PERIGEE, DELTAV.
025287,000055:                                                                                                  #  V16N35        DISPLAY TIME FROM TIG.
025288,000056:                                                                                                  #  V06N45        TIME FROM IGNITION AND MIDDLE GIMBAL ANGLE.
025289,000057: 
025290,000058:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED **
025291,000059: 
025292,000060:                                                                                                  #  TIG           TIME OF IGNITION                DP      (B+28) CS.
025293,000061: 
025294,000062:                                                                                                  #  DELLT4        DESIRED TIME OF FLIGHT          DP      (B+28) CS
025295,000063:                                                                                                  #                FROM RINIT TO RTARG.
025296,000064:                                                                                                  #  RTARG         RADIUS VECTOR OF TARGET POSITION VECTOR
025297,000065:                                                                                                  #                RADIUS VECTOR   SCALED TO  (B+29)METERS IF EARTH ORBIT
025298,000066:                                                                                                  #                RADIUS VECTOR SCALED TO    (B+27)METERS IF MOON ORBIT
025299,000067: 
025300,000068:                                                                                                  #  OUTPUT **
025301,000069: 
025302,000070:                                                                                                  #  HAPO          APOGEE ALTITUDE
025303,000071:                                                                                                  #  HPER          PERIGEE ALTITUDE
025304,000072:                                                                                                  #  VGDISP        MAG.OF DELTAV FOR DISPLAY ,SCALING      B+7 M/CS EARTH
025305,000073:                                                                                                  #                MAG.OF DELTAV FOR DISPLAY, SCALING      B+5 M/CS MOON
025306,000074:                                                                                                  #  MIDGIM        MIDDLE GIMBAL ANGLE
025307,000075:                                                                                                  #  XDELVFLG      RESETS XDELVFLG FOR LAMBERT VG COMPUTATIONS
025308,000076: 
025309,000077:                                                                                                  #  ALARMS OR ABORTS      NONE **
025310,000078: 
025311,000079:                                                                                                  #  RESTARTS ARE VIA GROUP 4 **
025312,000080: 
025313,000081: 34,2000                                           SETLOC   GLM                                   
025314,000082: 34,2000                                           BANK                                           
025315,000083: 
025316,000084: 34,3254  E7,1455                                  EBANK=   SUBEXIT                               
025317,000085: 
025318,000086: 34,3254                                           COUNT*   $$/P31                                
025319,000087: 34,3254           05413        P31LM              TC       PHASCHNG                              
025320,000088: 34,3255           05024                           OCT      05024                                 
025321,000089: 34,3256           13000                           OCT      13000                                 
025322,000090: 
025323,000091: 34,3257           33342                           CAF      V06N33*                               #  TIG
025324,000092: 34,3260           04655                           TC       BANKCALL                              
025325,000093: 34,3261           20406                           CADR     GOFLASH                               
025326,000094: 34,3262           14106                           TCF      GOTOPOOH                              
025327,000095: 34,3263           13265                           TCF      +2                                    
025328,000096: 34,3264           13257                           TCF      -5                                    
025329,000097: 
025330,000098: 34,3265           06014                           TC       INTPRET                               
025331,000099: 34,3266           77624                           CALL                                           
025332,000100: 34,3267           71345                                    P31INT                                
025333,000101: 34,3270           77776                           EXIT                                           
025334,000102: 
025335,000103: 34,3271           33343                           CAF      V06N42*                               #  HAPO, HPER, VGDISP
025336,000104: 34,3272           04655                           TC       BANKCALL                              
025337,000105: 34,3273           20544                           CADR     GOFLASHR                              
025338,000106: 34,3274           14106                           TCF      GOTOPOOH                              
025339,000107: 34,3275           13302                           TCF      +5                                    
025340,000108: 34,3276           13271                           TCF      -5                                    
025341,000109: 34,3277           05413                           TC       PHASCHNG                              
025342,000110: 34,3300           00014                           OCT      00014                                 
025343,000111: 34,3301           05225                           TC       ENDOFJOB                              
025344,000112: 
025345,000113: 34,3302           04655                           TC       BANKCALL                              
025346,000114: 34,3303           72465                           CADR     COMPTGO                               
025347,000115: 34,3304           33344                           CAF      V16N35                                
025348,000116: 34,3305           03311                           TC       VNPOOH2                               
025349,000117: 34,3306           35006                           CAF      POSMAX                                
025350,000118: 34,3307           55175                           TS       DISPDEX                               
025351,000119: 34,3310           03325                           TC       P31EXIT                               
025352,000120: 
025353,000121: 34,3311           00006        VNPOOH2            EXTEND                                         
025354,000122: 34,3312           23452                           QXCH     RTRN                                  
025355,000123: 34,3313           55602                           TS       VERBNOUN                              
025356,000124: 34,3314           31602                           CA       VERBNOUN                              
025357,000125: 34,3315           04655                           TCR      BANKCALL                              
025358,000126: 34,3316           20544                           CADR     GOFLASHR                              
025359,000127: 34,3317           04106                           TC       GOTOPOOH                              
025360,000128: 34,3320           01452                           TC       RTRN                                  
025361,000129: 34,3321           13314                           TCF      -5                                    
025362,000130: 34,3322           05413                           TC       PHASCHNG                              
025363,000131: 34,3323           00014                           OCT      00014                                 
025364,000132: 34,3324           05225                           TC       ENDOFJOB                              
025365,000133: 
025366,000134: 34,3325           04655        P31EXIT            TC       BANKCALL                              
025367,000135: 34,3326           11064                           CADR     R02BOTH                               
025368,000136: 34,3327           06014                           TC       INTPRET                               
025369,000137: 34,3330           41575                           VLOAD    PUSH                                  
025370,000138: 34,3331           03363                                    DELVEET3                              
025371,000139: 34,3332           77624                           CALL                                           
025372,000140: 34,3333           20002                                    MIDGIM                                
025373,000141: 34,3334           77624                           CALL                                           
025374,000142: 34,3335           72000                                    REVN1645                              
025375,000143: 34,3336           77776                           EXIT                                           
025376,000144: 34,3337           05575                           TC       DOWNFLAG                              
025377,000145: 34,3340           00045                           ADRES    XDELVFLG                              
025378,000146: 34,3341           04106                           TC       GOTOPOOH                              
025379,000147: 
025380,000148: 34,3342           01441        V06N33*            VN       0633                                  
025381,000149: 34,3343           01452        V06N42*            VN       0642                                  
025382,000150: 34,3344           04043        V16N35             VN       1635                                  
025383,000151: 
025384,000152: 34,3345           71220        P31INT             STQ      DLOAD                                 
025385,000153: 34,3346           03617                                    QTEMP                                 
025386,000154: 34,3347           03425                                    TIG                                   
025387,000155: 34,3350           34041                           STCALL   TDEC1                                 #  INTEGRATE STATE VECTORS TO TIG
025388,000156: 34,3351           27030                                    LEMPREC                               
025389,000157: 34,3352           77330                           SXA,1    VLOAD                                 
025390,000158: 34,3353           02773                                    P30EXIT                               
025391,000159: 34,3354           00025                                    VATT1                                 
025392,000160: 34,3355           26347                           STOVL    VINIT                                 
025393,000161: 34,3356           00017                                    RATT1                                 
025394,000162: 34,3357           02341                           STORE    RINIT                                 
025395,000163: 34,3360           67201                           SETPD    SLOAD                                 
025396,000164: 34,3361           00001                                    0D                                    
025397,000165: 34,3362           14423                                    P31ZERO                               
025398,000166: 34,3363           41525                           PDDL     PUSH                                  #  E4 AND NUMIT = 0
025399,000167: 34,3364           31410                                    P31ANGLE                              
025400,000168: 34,3365           77624                           CALL                                           
025401,000169: 34,3366           22022                                    INITVEL                               
025402,000170: 34,3367           77350                           LXA,1    VLOAD                                 
025403,000171: 34,3370           02773                                    P30EXIT                               
025404,000172: 34,3371           03363                                    DELVEET3                              
025405,000173: 34,3372           77646                           ABVAL                                          
025406,000174: 34,3373           27651                           STOVL    VGDISP                                
025407,000175: 34,3374           02357                                    VIPRIME                               
025408,000176: 34,3375           26744                           STOVL    VVEC                                  
025409,000177: 34,3376           02341                                    RINIT                                 
025410,000178: 34,3377           36655                           STCALL   RVEC                                  
025411,000179: 34,3400           46116                                    PERIAPO                               
025412,000180: 34,3401           77745                           DLOAD                                          
025413,000181: 34,3402           00005                                    4D                                    
025414,000182: 34,3403           16261                           STODL    HAPO                                  
025415,000183: 34,3404           00011                                    8D                                    
025416,000184: 34,3405           36263                           STCALL   HPER                                  
025417,000185: 34,3406           03617                                    QTEMP                                 
025418,000186: 
025419,000187: 34,3407           01616 07071  P31ANGLE           2DEC     .0555555555                            
025420,000188: 34,3411  26,2422               P31ZERO            =        1BITDP                                
025421,000189: 
025422,000190: 
025423,000191: 

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