Source Code

These source-code files are part of a reconstructed copy of Skylark 048, the Block II Command Module (CM) Apollo Guidance Computer (AGC) software for the Skylab-2, Skylab-3, Skylab-4, and Apollo-Soyuz Test Project missions.

They have been created via disassembly of binary dumps of the original core rope memory modules actually flown on Skylab-2, part numbers 2010802-541, 2010802-551, 2010802-561, 2010802-571, 2010802-581, and 2010802-591. Access to these modules was provided by the New Mexico Museum of Space History, who we are much indebted to.

The source code for the Apollo 15, 16, and 17 software, Artemis 072, was used as a starting point. Heavy use was made of TRW 4900.5-244, Programmed Guidance Equations for Skylark Command Module Earth Orbital Program, dated 14 February 1972. This document contains pseudocode of essentially all of Skylark, using original program labels which have been copied for this source reconstruction.

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

049923,000002:                                                                                                  ## Copyright:   Public domain.
049924,000003:                                                                                                  ## Filename:    LATITUDE_LONGITUDE_SUBROUTINES.agc
049925,000004:                                                                                                  ## Purpose:     A section of Skylark revision 048.
049926,000005:                                                                                                  ##              It is part of the source code for the Apollo Guidance Computer (AGC)
049927,000006:                                                                                                  ##              for Skylab-2, Skylab-3, Skylab-4, and ASTP. No original listings of
049928,000007:                                                                                                  ##              this software are available; instead, this file was created via
049929,000008:                                                                                                  ##              disassembly of dumps of the core rope modules actually flown on
049930,000009:                                                                                                  ##              Skylab-2. Access to these modules was provided by the New Mexico
049931,000010:                                                                                                  ##              Museum of Space History.
049932,000011:                                                                                                  ## Assembler:   yaYUL
049933,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
049934,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
049935,000014:                                                                                                  ## Mod history: 2023-09-04 MAS  Created from Artemis 072.
049936,000015:                                                                                                  ##              2024-03-04 MAS  Updated for Skylark 48.
049937,000016: 
049938,000017:                                                                                                  #  SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
049939,000018: 
049940,000019:                                                                                                  #  CALLING SEQUENCE
049941,000020: 
049942,000021:                                                                                                  #        L-1     CALL
049943,000022:                                                                                                  #        L               LAT-LONG
049944,000023: 
049945,000024:                                                                                                  #  SUBROUTINES USED
049946,000025: 
049947,000026:                                                                                                  #        R-TO-RP, ARCTAN, SETGAMMA, SETRE
049948,000027: 
049949,000028:                                                                                                  #  ERASABLE INIT. REQ.
049950,000029: 
049951,000030:                                                                                                  #        AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
049952,000031:                                                                                                  #        ALPHAV = POSITION VECTOR METERS B-29
049953,000032:                                                                                                  #        MPAC -- TIME (CSECS B-28)
049954,000033:                                                                                                  #        ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
049955,000034: 
049956,000035:                                                                                                  #  OUTPUT
049957,000036: 
049958,000037:                                                                                                  #        LATITUDE IN LAT         (REVS. B-0)
049959,000038:                                                                                                  #        LONGITUDE IN LONG       (REVS. B-0)
049960,000039:                                                                                                  #        ALTITUDE IN ALT METERS B-29
049961,000040: 
049962,000041: 11,2000                                           SETLOC   LATLONG                               
049963,000042: 11,2000                                           BANK                                           
049964,000043: 
049965,000044: 11,2461                                           COUNT*   $$/LT-LG                              
049966,000045: 11,2461  E4,1453                                  EBANK=   ALPHAV                                
049967,000046: 11,2461           40220        LAT-LONG           STQ      SETPD                                 
049968,000047: 11,2462           02143                                    INCORPEX                              
049969,000048: 11,2463           00001                                    0D                                    
049970,000049: 11,2464           24007                           STOVL    6D                                    #  SAVE TIME IN 6-7D FOR R-TO-RP
049971,000050: 11,2465           02054                                    ALPHAV                                
049972,000051: 11,2466           51406                           PUSH     ABVAL                                 #  0-5D= R FOR R-TO-RP
049973,000052: 11,2467           36167                           STCALL   ALPHAM                                #  ABS. VALUE OF R FOR ALT FORMULA BELOW
049974,000053: 11,2470           55224                                    R-TO-RP                               #  RP VECTOR CONVERTED FROM R B-29
049975,000054: 11,2471           77656                           UNIT                                           #  UNIT RP B-1
049976,000055: 11,2472           36054                           STCALL   ALPHAV                                #  U2= 1/2 SINL FOR SETRE SUBR BELOW
049977,000056: 11,2473           22645                                    SETRE                                 #  CALC RE METERS B-29
049978,000057: 11,2474           63545                           DLOAD    DSQ                                   
049979,000058: 11,2475           02054                                    ALPHAV                                
049980,000059: 11,2476           63525                           PDDL     DSQ                                   
049981,000060: 11,2477           02056                                    ALPHAV     +2                         
049982,000061: 11,2500           75415                           DAD      SQRT                                  
049983,000062: 11,2501           76405                           DMP      SL1R                                  
049984,000063: 11,2502           22600                                    B2/A2                                 
049985,000064: 11,2503           14021                           STODL    COSTH                                 #  COS(LAT) B-1
049986,000065: 11,2504           02060                                    ALPHAV     +4                         
049987,000066: 11,2505           34023                           STCALL   SINTH                                 #  SIN(LAT) B-1
049988,000067: 11,2506           22605                                    ARCTAN                                
049989,000068: 11,2507           14742                           STODL    LAT                                   #  LAT B0
049990,000069: 11,2510           02054                                    ALPHAV                                
049991,000070: 11,2511           14021                           STODL    COSTH                                 #  COS(LONG) B-1
049992,000071: 11,2512           02056                                    ALPHAV     +2                         
049993,000072: 11,2513           34023                           STCALL   SINTH                                 #  SIN(LONG) B-1
049994,000073: 11,2514           22605                                    ARCTAN                                
049995,000074: 11,2515           14744                           STODL    LONG                                  #  LONG. REVS B-0 IN RANGE -1/2 TO 1/2
049996,000075: 11,2516           02167                                    ALPHAM                                
049997,000076: 11,2517           77625                           DSU                                            #  ALT= R-RE METERS B-29
049998,000077: 11,2520           02142                                    ERADM                                 
049999,000078: 11,2521           34746                           STCALL   ALT                                   #  EXIT WITH ALT METERS B-29
050000,000079: 11,2522           02143                                    INCORPEX                              
050001,000080: 
050002,000081:                                                                                                  #  SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
050003,000082: 
050004,000083:                                                                                                  #  CALLING SEQUENCE
050005,000084: 
050006,000085:                                                                                                  #        L-1     CALL
050007,000086:                                                                                                  #        L               LALOTORV
050008,000087: 
050009,000088:                                                                                                  #  SUBROUTINES USED
050010,000089: 
050011,000090:                                                                                                  #        SETGAMMA, SETRE, RP-TO-R
050012,000091: 
050013,000092:                                                                                                  #  ERASABLE INIT. REQ.
050014,000093: 
050015,000094:                                                                                                  #        AXO, AYO, AZO, TEPHEM  SET AT LAUNCH TIME
050016,000095:                                                                                                  #        LAT -- LATITUDE         (REVS B0)
050017,000096:                                                                                                  #        LONG -- LONGITUDE       (REVS B0)
050018,000097:                                                                                                  #        ALT -- ALTITUDE         (METERS) B-29
050019,000098:                                                                                                  #        MPAC -- TIME            (CSECS B-28)
050020,000099:                                                                                                  #        ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
050021,000100: 
050022,000101:                                                                                                  #  OUTPUT
050023,000102: 
050024,000103:                                                                                                  #        R-VECTOR IN ALPHAV (METERS B-29)
050025,000104: 
050026,000105: 11,2523           40220        LALOTORV           STQ      SETPD                                 #  LAT,LONG,ALT TO R VECTOR
050027,000106: 11,2524           02143                                    INCORPEX                              
050028,000107: 11,2525           00001                                    0D                                    
050029,000108: 11,2526           00007                           STORE    6D                                    #  6-7D = TIME FOR RP-TO-R
050030,000109: 11,2527           73545                           DLOAD    SIN                                   #                   COS(LONG)COS(LAT) IN MPAC
050031,000110: 11,2530           00742                                    LAT                                   #        UNIT  RP = SIN(LONG)COS(LAT)    2-3D
050032,000111: 11,2531           65275                           DMPR     PDDL                                  #  PD 2             GAMMA*SIN(LAT)       0-1D
050033,000112: 11,2532           22600                                    B2/A2                                 
050034,000113: 11,2533           00742                                    LAT                                   #            0-1D = GAMMA*SIN(LAT) B-2
050035,000114: 11,2534           65346                           COS      PDDL                                  #  PD4       2-3D = COS(LAT) B-1 TEMPORARILY
050036,000115: 11,2535           00744                                    LONG                                  
050037,000116: 11,2536           57356                           SIN      DMPR                                  #  PD 2
050038,000117: 11,2537           71525                           PDDL     COS                                   #  PD 4      2-3D = SIN(LONG)COS(LAT) B-2
050039,000118: 11,2540           00742                                    LAT                                   
050040,000119: 11,2541           71525                           PDDL     COS                                   #  PD 6      4-5D = COS(LAT) B-1 TEMPORARILY
050041,000120: 11,2542           00744                                    LONG                                  
050042,000121: 11,2543           55475                           DMPR     VDEF                                  #  PD4       MPAC = COS(LONG)COS(LAT) B-2
050043,000122: 11,2544           41456                           UNIT     PUSH                                  #  0-5D = UNIT RP FOR RP-TO-R SUBR.
050044,000123: 11,2545           36054                           STCALL   ALPHAV                                #  ALPHAV +4= SINL FOR SETRE SUBR.
050045,000124: 11,2546           22645                                    SETRE                                 #  RE METERS B-29
050046,000125: 11,2547           77624        CALLRPRT           CALL                                           
050047,000126: 11,2550           55213                                    RP-TO-R                               #  EXIT WITH UNIT R VECTOR IN MPAC
050048,000127: 11,2551           16054                           STODL    ALPHAV                                
050049,000128: 11,2552           02142                                    ERADM                                 
050050,000129: 11,2553           74215                           DAD      VXSC                                  #  (RE + ALT)(UNIT R) METERS B-30
050051,000130: 11,2554           00746                                    ALT                                   
050052,000131: 11,2555           02054                                    ALPHAV                                
050053,000132: 11,2556           77772                           VSL1                                           #  R METERS B-29
050054,000133: 11,2557           36054                           STCALL   ALPHAV                                #  EXIT WITH R IN METERS B-29
050055,000134: 11,2560           02143                                    INCORPEX                              
050056,000135: 
050057,000136:                                                                                                  #  SUBROUTINE TO COMPUTE EARTH RADIUS
050058,000137: 
050059,000138:                                                                                                  #  INPUT
050060,000139: 
050061,000140:                                                                                                  #        1/2 SIN LAT IN ALPHAV +4
050062,000141: 
050063,000142:                                                                                                  #  OUTPUT
050064,000143: 
050065,000144:                                                                                                  #        EARTH RADIUS IN ERADM AND MPAC  (METERS B-29)
050066,000145: 
050067,000146: 11,2561           63545        GETERAD            DLOAD    DSQ                                   
050068,000147: 11,2562           02060                                    ALPHAV     +4                         #  SIN**2(L)
050069,000148: 11,2563           44352                           SL1      BDSU                                  
050070,000149: 11,2564           15724                                    DP1/2                                 #  COS**2(L)
050071,000150: 11,2565           44275                           DMPR     BDSU                                  
050072,000151: 11,2566           22602                                    EE                                    
050073,000152: 11,2567           15724                                    DP1/2                                 
050074,000153: 11,2570           75465                           BDDV     SQRT                                  
050075,000154: 11,2571           22576                                    B2XSC                                 
050076,000155: 11,2572           77622                           SR4R                                           
050077,000156: 11,2573           02142                           STORE    ERADM                                 
050078,000157: 11,2574           77616                           RVQ                                            
050079,000158: 
050080,000159:                                                                                                  #  THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
050081,000160:                                                                                                  #  B2XSC = B**2 SCALED B-51
050082,000161:                                                                                                  #  B2/A2 = B**2/A**2  SCALED B-1
050083,000162:                                                                                                  #  EE = (1-B**2/A**2) SCALED B-0
050084,000163: 
050085,000164: 11,2575           00446 00305  B2XSC              2DEC     .0179450689                            #  B**2 SCALED B-51
050086,000165: 11,2577  06,3723               DP1/2              =        XUNIT                                 
050087,000166: 11,2577           17711 05254  B2/A2              2DEC     .9933064884 B-1                        #  GAMMA= B**2/A**2 B-1
050088,000167: 11,2601           00155 25250  EE                 2DEC     6.6935116  E-3                        #  (1-B**2/A**2) B-0
050089,000168: 11,2603           00302 17755  ERAD               2DEC     6373338    B-29                       #  PAD RADIUS
050090,000169: 
050091,000170:                                                                                                  #  ARCTAN SUBROUTINE
050092,000171: 
050093,000172:                                                                                                  #  CALLING SEQUENCE
050094,000173: 
050095,000174:                                                                                                  #        SIN THETA IN SINTH B-1
050096,000175:                                                                                                  #        COS THETA IN COSTH B-1
050097,000176:                                                                                                  #        CALL ARCTAN
050098,000177: 
050099,000178:                                                                                                  #  OUTPUT
050100,000179:                                                                                                  #        ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
050101,000180: 
050102,000181: 11,2605           77600        ARCTAN             BOV                                            
050103,000182: 11,2606           22607                                    CLROVFLW                              
050104,000183: 11,2607           63545        CLROVFLW           DLOAD    DSQ                                   
050105,000184: 11,2610           00023                                    SINTH                                 
050106,000185: 11,2611           63525                           PDDL     DSQ                                   
050107,000186: 11,2612           00021                                    COSTH                                 
050108,000187: 11,2613           77615                           DAD                                            
050109,000188: 11,2614           75454                           BZE      SQRT                                  
050110,000189: 11,2615           22633                                    ARCTANXX                              #  ATAN=0/0  SET THETA=0
050111,000190: 11,2616           40065                           BDDV     BOV                                   
050112,000191: 11,2617           00023                                    SINTH                                 
050113,000192: 11,2620           22640                                    ATAN=90                               
050114,000193: 11,2621           67542                           SR1      ASIN                                  
050115,000194: 11,2622           00025                           STORE    THETA                                 
050116,000195: 11,2623           50125                           PDDL     BMN                                   
050117,000196: 11,2624           00021                                    COSTH                                 
050118,000197: 11,2625           22627                                    NEGCOS                                
050119,000198: 11,2626           43545                           DLOAD    RVQ                                   
050120,000199: 11,2627           57545        NEGCOS             DLOAD    DCOMP                                 
050121,000200: 11,2630           43244                           BPL      DAD                                   
050122,000201: 11,2631           22635                                    NEGOUT                                
050123,000202: 11,2632           15724                                    DP1/2                                 
050124,000203: 11,2633           00025        ARCTANXX           STORE    THETA                                 
050125,000204: 11,2634           77616                           RVQ                                            
050126,000205: 
050127,000206: 11,2635           52025        NEGOUT             DSU      GOTO                                  
050128,000207: 11,2636           15724                                    DP1/2                                 
050129,000208: 11,2637           22633                                    ARCTANXX                              
050130,000209: 11,2640           75345        ATAN=90            DLOAD    SIGN                                  
050131,000210: 11,2641           33412                                    LODP1/4                               
050132,000211: 11,2642           00023                                    SINTH                                 
050133,000212: 11,2643           00025                           STORE    THETA                                 
050134,000213: 11,2644           77616                           RVQ                                            
050135,000214: 
050136,000215: 11,2645  06,3725               2DZERO             =        DPZERO                                
050137,000216: 
050138,000217: 
050139,000218:                                                                                                  #  ..... SETRE SUBROUTINE .....
050140,000219:                                                                                                  #  SUBROUTINE TO SET RE (EARTH RADIUS)
050141,000220: 
050142,000221:                                                                                                  #   RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
050143,000222: 
050144,000223:                                                                                                  #  CALLING SEQUENCE
050145,000224:                                                                                                  #   L    CALL
050146,000225:                                                                                                  #   L+1          SETRE
050147,000226: 
050148,000227:                                                                                                  #  SUBROUTINES USED
050149,000228:                                                                                                  #   GETERAD
050150,000229: 
050151,000230:                                                                                                  #  INPUT
050152,000231:                                                                                                  #   ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
050153,000232:                                                                                                  #   ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
050154,000233: 
050155,000234:                                                                                                  #  OUTPUT
050156,000235:                                                                                                  #   ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
050157,000236: 
050158,000237: 11,2645           71220        SETRE              STQ      DLOAD                                 
050159,000238: 11,2646           00051                                    SETREX                                
050160,000239: 11,2647           22604                                    ERAD                                  
050161,000240: 11,2650           45014                           BOFF     CALL                                  #  ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
050162,000241: 11,2651           00742                                    ERADFLAG                              
050163,000242: 11,2652           22654                                    SETRXX                                
050164,000243: 11,2653           22561                                    GETERAD                               
050165,000244: 11,2654           36142        SETRXX             STCALL   ERADM                                 #  EXIT WITH RE OR RM METERS B-29
050166,000245: 11,2655           00051                                    SETREX                                
050167,000246: 11,2656  0000051               SETREX             =        S2                                    

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