forked from chrislgarry/Apollo-11
-
Notifications
You must be signed in to change notification settings - Fork 3
/
LATITUDE_LONGITUDE_SUBROUTINES.s
318 lines (294 loc) · 7.05 KB
/
LATITUDE_LONGITUDE_SUBROUTINES.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# Copyright: Public domain.
# Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
# Purpose: Part of the source code for Colossus 2A, AKA Comanche 055.
# It is part of the source code for the Command Module's (CM)
# Apollo Guidance Computer (AGC), for Apollo 11.
# Assembler: yaYUL
# Contact: Ron Burkey <info@sandroid.org>.
# Website: www.ibiblio.org/apollo.
# Pages: 1236-1242
# Mod history: 2009-05-14 RSB Adapted from the Colossus249/ file of the
# same name, using Comanche055 page images.
#
# This source code has been transcribed or otherwise adapted from digitized
# images of a hardcopy from the MIT Museum. The digitization was performed
# by Paul Fjeld, and arranged for by Deborah Douglas of the Museum. Many
# thanks to both. The images (with suitable reduction in storage size and
# consequent reduction in image quality as well) are available online at
# www.ibiblio.org/apollo. If for some reason you find that the images are
# illegible, contact me at info@sandroid.org about getting access to the
# (much) higher-quality images which Paul actually created.
#
# Notations on the hardcopy document read, in part:
#
# Assemble revision 055 of AGC program Comanche by NASA
# 2021113-051. 10:28 APR. 1, 1969
#
# This AGC program shall also be referred to as
# Colossus 2A
# Page 1236
# SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
#
# CALLING SEQUENCE
# L-1 CALL
# L LAT-LONG
#
# SUBROUTINES USED
# R-TO-RP, ARCTAN, SETGAMMA, SETRE
#
# ERASABLE INIT. REQ.
# AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
# ALPHAV = POSITION VECTOR METERS B-29
# MPAC -- TIME (CSECS B-28)
# ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
# LUNAFLAG=0 FOR EARTH, 1 FOR MOON
#
# OUTPUT
# LATITUDE IN LAT (REVS. B-0)
# LONGITUDE IN LONG (REVS. B-0)
# ALTITUDE IN ALT METERS B-29
BANK 30
SETLOC LATLONG
BANK
COUNT 13/LT-LG
EBANK= ALPHAV
LAT-LONG STQ SETPD
INCORPEX
0D
STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
ALPHAV
PUSH ABVAL # 0-5D= R FOR R-TO-RP
STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
LUNAFLAG # 0=EARTH, 1=MOON
CALLRTRP
CALLRTRP CALL
R-TO-RP # RP VECTOR CONVERTED FROM R B-29
UNIT # UNIT RP B-1
STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
SETGAMMA # SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
CALL # SCALED B-1.
SETRE # CALC RE METERS B-29
DLOAD DSQ
ALPHAV
PDDL DSQ
ALPHAV +2
# Page 1237
DAD SQRT
DMP SL1R
GAMRP
STODL COSTH # COS(LAT) B-1
ALPHAV +4
STCALL SINTH # SIN(LAT) B-1
ARCTAN
STODL LAT # LAT B0
ALPHAV
STODL COSTH # COS(LONG) B-1
ALPHAV +2
STCALL SINTH # SIN(LONG) B-1
ARCTAN
STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
ALPHAM
DSU # ALT= R-RE METERS B-29
ERADM
STCALL ALT # EXIT WITH ALT METERS B-29
INCORPEX
# Page 1238
# SUBROUTINE TO CONVERT LAT,LONG.ALT AT GIVEN TIME TO RADIUS VECTOR
#
# CALLING SEQUENCE
# L-1 CALL
# L LALOTORV
#
# SUBROUTINES USED
# SETGAMMA, SETRE, RP-TO-R
#
# ERASABLE INIT. REQ.
# AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
# LAT -- LATITUDE (REVS B0)
# LONG -- LONGITUDE (REVS B0)
# ALT -- ALTITUDE (METERS) B-29
# MPAC -- TIME (CSECS B-28)
# ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
# LUNAFLAG=0 FOR EARTH, 1 FOR MOON
#
# OUTPUT
# R-VECTOR IN ALPHAV (METERS B-29)
LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
INCORPEX
0D
STCALL 6D # 6-7D = TIME FOR RP-TO-R
SETGAMMA # GAMMA = B2/A2 FOR EARTH, 1 FOR MOON B-1
DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
LAT # UNIT RP = SIN(LONG)COS(LAT) 2-3D
DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
GAMRP
LAT # 0-1D = GAMMA*SIN(LAT) B-2
COS PDDL # PD4 2-3D= COS(LAT) B-1 TEMPORARILY
LONG
SIN DMPR # PD 2
PDDL COS # PD 4 2-3D= SIN(LONG)COS(LAT) B-2
LAT
PDDL COS # PD 6 4-5D= COS(LAT) B-1 TEMPORARILY
LONG
DMPR VDEF # PD4 MPAC = COS(LONG)COS(LAT) B-2
UNIT PUSH # 0-5D = UNIT RP FOR RP-TO-R SUBR.
STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
SETRE # RE METERS B-29
DLOAD BOFF # SET MPAC = 0 FOR EARTH, NON-ZERO FOR MOON
ZEROVEC
LUNAFLAG
CALLRPRT
COS # USE COS(0) TO GET NON-ZERO IN MPAC
CALLRPRT CALL
RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
STODL ALPHAV
ERADM
# Page 1239
DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
ALT
ALPHAV
VSL1 # R METERS B-29
STCALL ALPHAV # EXIT WITH R IN METERS B-29
INCORPEX
# SUBROUTINE TO COMPUTE EARTH RADIUS
#
# INPUT
# 1/2 SIN LAT IN ALPHAV +4
#
# OUTPUT
# EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
GETERAD DLOAD DSQ
ALPHAV +4 # SIN**2(L)
SL1 BDSU
DP1/2 # COS**2(L)
DMPR BDSU
EE
DP1/2
BDDV SQRT
B2XSC
SR4R
STORE ERADM
RVQ
# THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
# B2XSC = B**2 SCALED B-51
# B2/A2 = B**2/A**2 SCALED B-1
# EE = (1-B**2/A**2) SCALED B-0
B2XSC 2DEC .0179450689 # B**2 SCALED B-51
DP1/2 = XUNIT
B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
ERAD 2DEC 6373338 B-29 # PAD RADIUS
# Page 1240
# ARCTAN SUBROUTINE
#
# CALLING SEQUENCE
# SIN THETA IN SINTH B-1
# COS THETA IN COSTH B-1
# CALL ARCTAN
#
# OUTPUT
# ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
ARCTAN BOV
CLROVFLW
CLROVFLW DLOAD DSQ
SINTH
PDDL DSQ
COSTH
DAD
BZE SQRT
ARCTANXX # ATAN=0/0. SET THETA=0
BDDV BOV
SINTH
ATAN=90
SR1 ASIN
STORE THETA
PDDL BMN
COSTH
NEGCOS
DLOAD RVQ
NEGCOS DLOAD DCOMP
BPL DAD
NEGOUT
DP1/2
ARCTANXX STORE THETA
RVQ
NEGOUT DSU GOTO
DP1/2
ARCTANXX
ATAN=90 DLOAD SIGN
LODP1/4
SINTH
STORE THETA
RVQ
2DZERO = DPZERO
# Page 1241
# ***** SETGAMMA SUBROUTINE *****
# SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
#
# GAMMA = B**2/A**2 FOR EARTH (B-1)
# GAMMA = 1 FOR MOON (B-1)
#
# CALLING SEQUENCE
# L CALL
# L+1 SETGAMMA
#
# INPUT
# LUNAFLAG=0 FOR EARTH, =1 FOR MOON
#
# OUTPUT
# GAMMA IN GAMRP (B-1)
SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
B2/A2 # EARTH GAMMA
LUNAFLAG
SETGMEX
SLOAD
1B1 # MOON GAMMA
SETGMEX STORE GAMRP
RVQ
GAMRP = 8D
# Page 1242
# ***** SETRE SUBROUTINE *****
# SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
#
# RE = RM FOR MOON
# RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
#
# CALLING SEQUENCE
# L CALL
# L+1 SETRE
#
# SUBROUTINES USED
# CETERAD
#
# INPUT
# ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
# ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
# LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
#
# OUTPUT
# ERADM = 504RM FOR MOON (METERS B-29)
# ERADM = ERAD OR COMPUTED RE FOR EARTH (METERS B-29)
SETRE STQ DLOAD
SETREX
504RM
BON DLOAD # BRANCH FOR MOON
LUNAFLAG
TSTRLSRM
ERAD
BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
ERADFLAG
SETRXX
GETERAD
SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
SETREX
TSTRLSRM BON VLOAD # ERADFLAG=0, SET R0=RLS
ERADFLAG # =1 R0=RM
SETRXX
RLS
ABVAL SR2R # SCALE FROM B-27 TO B-29
GOTO
SETRXX
SETREX = S2
504RM 2DEC 1738090 B-29 # METERS B-29 (MOON RADIUS)