gallu’s blog

エンジニアでゲーマーで講師で占い師なおいちゃんのブログです。

いにしえの遺産

アポロ11号で利用されたプログラムのソースコード、公開中
http://slashdot.jp/science/09/07/29/0221202.shtml


だ、そうで。
ぬあんと!!!
面白いものである。


http://googlecode.blogspot.com/2009/07/apollo-11-missions-40th-anniversary-one.html
から〜

# Copyright: Public domain.
# Filename: CM_BODY_ATTITUDE.s
# Purpose: Part of the source code for Comanche, build 055. It
# is part of the source code for the Command Module's
# (CM) Apollo Guidance Computer (AGC), Apollo 11.
# Assembler: yaYUL
# Reference: pp. 883-889
# Contact: Ron Burkey <info@sandroid.org>
# Website: http://www.ibiblio.org/apollo.
# Mod history: 2009-05-12 RSB Adapted from Colossus249 file of the same
# name and Comanche 055 page images.
#
# The contents of the "Comanche055" files, in general, are transcribed
# from scanned documents.
#
# Assemble revision 055 of AGC program Comanche by NASA
# 2021113-051. April 1, 1969.
#
# This AGC program shall also be referred to as Colossus 2A
#
# Prepared by
# Massachussets Institute of Technology
# 75 Cambridge Parkway
# Cambridge, Massachusetts
#
# under NASA contract NAS 9-4065.
#
# Refer directly to the online document mentioned above for further
# information. Please report any errors to info@sandroid.org.

# Page 883
BANK 35

SETLOC BODYATT
BANK

COUNT 37/CMBAT

# PDL 12D - 15D SAFE.

# VALUE OF GIMBAL AND BODY ANGLES VALID AT PIP TIME ARE SAVED DURING READACCS.

EBANK= RTINIT # LET INTERPRETER SET EB

CM/POSE TC INTPRET # COME HERE VIA AVEGEXIT.

SETPD VLOAD
0
VN # KVSCALE = (12800/ .3048) /2VS
VXSC PDVL
-KVSCALE # KVSCALE = .81491944
UNITW # FULL UNIT VECTOR
VXV VXSC # VREL = V - WE*R
UNITR
KWE
VAD STADR
STORE -VREL # SAVE FOR ENTRY GUIDANCE. REF COORDS

UNIT LXA,1
36D # ABVAL( -VREL) TO X1
STORE UXA/2 # -UVREL REF COORDS

VXV VCOMP
UNITR # .5 UNIT REF COORDS
UNIT SSP # THE FOLLOWING IS TO PROVIDE A STABLE
S1 # UN FOR THE END OF THE TERMINAL PHASE.
SPVQUIT DEC .019405 # 1000/ 2 VS
TIX,1 VLOAD # IF V-VQUIT POS, BRANCH.
CM/POSE2 # SAME UYA IN OLDUYA
OLDUYA # OTHERWISE CONTINUE TO USE OLDUYA
CM/POSE2 STORE UYA/2 # REF COORDS

STORE OLDUYA # RESTORE, OR SAVE AS CASE MAY BE.

VXV VCOMP
UXA/2 # FINISH OBTAINING TRAJECTORY TRIAD.
VSL1
STORE UZA/2 # REF COORDS
# Page 884
TLOAD # PICK UP CDUX, CDUY, CDUZ CORRESPONDING
AOG/PIP # TO PIPUP TIME IN 2'S C AND SAVE.
CM/TRIO STODL 24D
25D # AIG/PIP

RTB PUSH # TO PDL0
CDULOGIC
COS
STODL UBX/2 # CI /2
# AIG/PIP FROM PDL 0
SIN DCOMP
STODL UBX/2 +4 # -SI /2
26D # AMG/PIP
RTB PUSH # TO PDL 0
CDULOGIC
SIN PDDL # XCH PDL 0. SAVE SM /2
COS PDDL # CM /2 TO PDL 2
0 # SM /2
DCOMP VXSC
UBX/2
VSL1 # NOISE WON'T OVFL
STODL UBY/2 # =(-SMCI, NOISE, SMSI)/2
2 # CM /2 REPLACES NOISE
STODL UBY/2 +2 # UBY/2=(-SMCI, CM, SMSI)/2
24D # AOG/PIP
RTB PUSH # TO PDL 4
CDULOGIC
SIN PDDL # XCH PDL 4. SAVE SO /2
COS VXSC # CO /2
UBY/2
STODL UBY/2 # UBY/2=(-COSMCI, COCM, COSMSI)/4
4D # SO /2
DMP DCOMP
UBX/2 +4 # -SI /2
DAD
UBY/2 # INCREMENT BY (SOSI /4)
STODL UBY/2
# SO /2 FROM PDL 4
DMP DAD
UBX/2 # CI /2
UBY/2 +4
STOVL UBY/2 +4 # YB/4 PLATFORM COORDS

# YB = (-COSMCI + SOSI , COCM , COSMSI + SOCI )

UBY/2
VXM VSL2
REFSMMAT # .5 UNIT
STODL UBY/2 # YB/2 DONE REF COORDS
# Page 885
# CM /2 FROM PDL 2
VXSC VSL1
UBX/2
STODL UBX/2 # =( CMCI, NOISE, -CMSI)/2
STADR # SM /2 FROM PDL 0
STOVL UBX/2 +2 # SM /2 REPLACES NOISE
UBX/2 # XB/2 PLATFORM COORDS

# XB = ( CMCI , SM , -CMSI )

VXM VSL1
REFSMMAT # .5 UNIT
STORE UBX/2 # XB/2 DONE REF COORDS

VXV VSL1
UBY/2
STOVL UBZ/2 # ZB/2 DONE REF COORDS

# EQUIVALENT TO
# ZB = ( SOSMCI + COSI , -SOCM , -SOSMSI + COCI )

UXA/2 # -UVREL/2 = -UVA/2
VXV UNIT # GET UNIT(-UVREL*UBY)/2 = UL/2
UBY/2 # YB/2
PUSH DOT # UL/2 TO PDL 0,5
UZA/2 # UNA/2
STOVL COSTH # COS(ROLL)/4
0 # UL/2

DOT
UYA/2
STCALL SINTH # -SIN(ROLL)/4
ARCTRIG
STOVL 6D # -(ROLL/180) /2
UBY/2
DOT SL1 # -UVA.UBY = -SIN(BETA)
UXA/2 # -UVREL/2
ARCSIN
STOVL 7D # -(BETA/180) /2
UBX/2 # XB/2
DOT # UL.UBX = -SIN(ALFA)
0 # UL/2
STOVL SINTH # -SIN(ALFA)/4
DOT # UL/2 FROM PDL 0
UBZ/2
STCALL COSTH # COS(ALFA)/2
ARCTRIG
STOVL 8D # -(ALFA/180) /2
UNITR # UR/2 REF COORDS
DOT SL1
# Page 886
UZA/2 # MORE ACCURATE AT LARGE ARG.
ARCCOS
STORE 10D # (-GAMA/180)/2

TLOAD EXIT # ANGLES IN MPAC IN THE ORDER
# -( (ROLL, BETA, ALFA) /180)/2
6D # THESE VALUES CORRECT AT PIPUP TIME.

# Page 887
# BASIC SUBROUTINE TO UPDATE ATTITUDE ANGLES

EBANK= AOG

CM/ATUP CA EBAOG
TS EBANK
CMTR1 INDEX FIXLOC
CS 10D # (GAMA/180)/2
XCH GAMA
TS L

INHINT
# MUST REMAIN INHINTED UNTIL UPDATE OF BODY
# ANGLES, SO THAT GAMDIFSW IS VALID FIRST PASS
# INDICATOR.

CS CM/FLAGS
MASK BIT11 # GAMDIFSW=94D BIT11 INITLY=0
EXTEND # DON'T CALC GAMA DOT UNTIL HAVE FORMD
# ONE DIFFERENCE.
BZF DOGAMDOT # IS OK, GO ON.
ADS CM/FLAGS # KNOW BIT IS 0
TC NOGAMDOT # SET GAMDOT = 0

DOGAMDOT CS L
AD GAMA # DEL GAMA/360= T GAMDOT/360
EXTEND
MP TCDU # TCDU = .1 SEC, T = 2 SEC.
TS GAMDOT # GAMA DOT TCDU / 180

EXTEND # IGNORE GAMDOT IF LEQ .5 DEG/SEC
BZMF +2
COM
AD FIVE
EXTEND
BZMF +3 # SET GAMDOT=+0 AS TAG IF TOO SMALL.

NOGAMDOT CA ZERO # COME HERE INHINTED
TS GAMDOT
# FOR NOW LEAVE IN 2'S C
# UPDATE ANGLES BY CORRECTING EULER ANG
# FOR ACCRUED INCREMENT SINCE PIPUP
# R = R EUIL + R(NOW) - R(PIPUP)
CS MPAC # GET (R EUL/180) /2
DOUBLE # POSSIBLE OVERFLOW
TC CORANGOV # CORRECT FOR OVFL IF ANY
EXTEND
SU ROLL/PIP # GET INCR SINCE PIPUP
AD ROLL/180 # ONLY SINGLE OVFL POSSIBLE.
TC CORANGOV # CORRECT FOR OVFL IF ANY
# Page 888
TS TEMPROLL

CS MPAC +2 # GET (ALFA EUL/180) /2
DOUBLE # SAME AS FOR ROLL. NEEDED FOR EXT ATM DAP
TC CORANGOV # CORRECT FOR OVFL IF ANY
EXTEND
SU ALFA/PIP
AD ALFA/180
TC CORANGOV # CORRECT FOR OVFL IF ANY
TS TEMPALFA

CS MPAC +1 # GET (BETA EUL/180) /2
CMTR2 DOUBLE
EXTEND
SU BETA/PIP
AD BETA/180
XCH TEMPBETA # OVFL NOT EXPECTED.

CA EBANK3
TS EBANK

EBANK= PHSNAME5
EXTEND
DCA REPOSADR # THIS ASSUMES THAT THE TC PHASCHNG
DXCH PHSNAME5 # IS NOT CHANGED IN OCT 10035
# SERVICER.

CA EBAOG
TS EBANK

EBANK= AOG
REDOPOSE EXTEND # RE-STARTS COME HERE
DCA TEMPROLL
DXCH ROLL/180
CA TEMPBETA
TS BETA/180

RELINT

TC INTPRET # CAN'T TC DANZIG AFTER PHASCHNG.
CM/POSE3 VLOAD ABVAL # RETURN FROM CM/ATUP. (RESTART)
VN # 2(-7) M/CS
STORE VMAGI # FOR DISPLAY ON CALL.

GOTO
POSEXIT # ENDEXIT, STARTENT, OR SCALEPOP.

CORANGOV TS L
TC Q
INDEX A
# Page 889
CA LIMITS
ADS L
TC Q # COSTS 2 MCT TO USE. SEE ANGOVCOR.

-KVSCALE 2DEC -.81491944 # -12800/(2 VS .3048)


TCDU DEC .1 # TCDU = .1 SEC.

EBANK= AOG
REPOSADR 2CADR REDOPOSE
# Copyright: Public domain.
# Filename: LUNAR_LANDING_GUIDANCE_EQUATIONS.s
# Purpose: Part of the source code for Luminary 1A build 099.
# It is part of the source code for the Lunar Module's (LM)
# Apollo Guidance Computer (AGC), for Apollo 11.
# Assembler: yaYUL
# Contact: HARTMUTH GUTSCHE <hgutsche@xplornet.com>.
# Website: www.ibiblio.org/apollo.
# Pages: 798-828
# Mod history: 2009-05-23 HG Transcribed from page images.
# 2009-06-05 RSB Fixed a goofy thing that was apparently
# legal in GAP but not in yaYUL. Eliminated
# a couple of lines of code that shouldn't
# have survived from Luminary 131 to here.
# 2009-06-07 RSB Fixed a typo.
#
# 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 001 of AGC program LMY99 by NASA 2021112-61
# 16:27 JULY 14, 1969

# Page 798
EBANK= E2DPS
COUNT* $$/F2DPS

# ********************************************************
# LUNAR LANDING FLIGHT SEQUENCE TABLES
# ********************************************************

# FLIGHT SEQUENCE TABLES ARE ARRANGED BY FUNCTION. THEY ARE REFERENCED USING AS AN INDEX THE REGISTER WCHPHASE:
# WCHPHASE = -1 ---> IGNALG
# WCHPHASE = 0 ---> BRAKQUAD
# WCHPHASE = 1 ---> APPRQUAD
# WCHPHASE = 2 ---> VERTICAL

#*********************************************************

# ROUTINES FOR STARTING NEW GUIDANCE PHASES:

TCF TTFINCR # IGNALG
NEWPHASE TCF TTFINCR # BRAKQUAD
TCF STARTP64 # APPRQUAD
TCF P65START # VERTICAL

# PRE-GUIDANCE COMPUTATIONS:

TCF CALCRGVG # IGNALG
PREGUIDE TCF RGVGCALC # BRAKQUAD
TCF REDESIG # APPRQUAD
TCF RGVGCALC # VERTICAL

# GUIDANCE EQUATIONS:

TCF TTF/8CL # IGNALG
WHATGUID TCF TTF/8CL # BRAKQUAD
TCF TTF/8CL # APPRQUAD
TCF VERTGUID # VERTICAL

# POST GUIDANCE EQUATION COMPUTATIONS:

TCF CGCALC # IGNALG
AFTRGUID TCF CGCALC # BRAKQUAD
TCF CGCALC # APPRQUAD
TCF STEER? # VERTICAL

# Page 799
# WINDOW VECTOR COMPUTATIONS:

TCF EXGSUB # IGNALG
WHATEXIT TCF EXBRAK # BRAKQUAD
TCF EXNORM # APPRQUAD

# DISPLAY ROUTINES:

WHATDISP TCF P63DISPS # BRAKQUAD
TCF P64DISPS # APPRQUAD
TCF VERTDISP # VERTICAL

# ALARM ROUTINE FOR TTF COMPUTATION:

TCF 1406P00 # IGNALG
WHATALM TCF 1406ALM # BRAKQUAD
TCF 1406ALM # APPRQUAD

# INDICES FOR REFERENCING TARGET PARAMETERS

OCT 0 # IGNALG
TARGTDEX OCT 0 # BRAKQUAD
OCT 34 # APPRQUAD

#************************************************************************
# ENTRY POINTS: ?GUIDSUB FOR THE IGNITION ALGORITHM, LUNLAND FOR SERVOUT
#************************************************************************

# IGNITION ALGORITHM ENTRY: DELIVERS N PASSES OF QUADRATIC GUIDANCE

?GUIDSUB EXIT
CAF TWO # N = 3
TS NGUIDSUB
TCF GUILDRET +2

GUIDSUB TS NGUIDSUB # ON SUCCEEDING PASSES SKIP TTFINCR
TCF CALCRGVG

# NORMAL ENTRY: CONTROL COMES HERE FROM SERVOUT

LUNLAND TC PHASCHNG
OCT 00035 # GROUP 5: RETAIN ONLY PIPA TASK
TC PHASCHNG
OCT 05023 # GROUP 3: PROTECT GUIDANCE WITH PRIO 21
OCT 21000 # JUST HIGHER THAN SERVICER'S PRIORITY

# Page 800
#*******************************************************************
# GUILDENSTERN: AUTO-MODES MONITOR (R13)
#*******************************************************************

COUNT* $$/R13

# HERE IS THE PHILOSOPHY OF GUILDENSTERN: ON EVERY APPEARANCE OR DISAPPEARANCE OF THE MANUAL THROTTLE
# DISCRETE TO SELECT P67 OR P66 RESPECTIVELY: ON EVERY APPEARANCE OF THE ATTITUDE-HOLD DISCRETE TO SELECT P66
# UNLESS THE CURRENT PROGRAM IS P67 IN WHICH CASE THERE IS NO CHANGE

GUILDEN EXTEND # IS UN-AUTO-THROTTLE DISCRETE PRESENT?
# STERN # RSB 2009: Not originally a comment.
READ CHAN30
MASK BIT5
CCS A
TCF STARTP67 # YES
P67NOW? TC CHECKMM # NO: ARE WE IN P67 NOW?
DEC 67
TCF STABL? # NO
STARTP66 TC FASTCHNG # YES
TC NEWMODEX
DEC66 DEC 66
EXTEND
DCA HDOTDISP # SET DESIRED ALTITUDE RATE = CURRENT
DXCH VDGVERT # ALTITUDE RATE.
STRTP66A TC INTPRET
SLOAD PUSH
PBIASZ
SLOAD PUSH
PBIASY
SLOAD VDEF
PBIASX
VXSC SET
BIASFACT
RODFLAG
STOVL VBIAS
TEMX
VCOMP
STOVL OLDPIPAX
ZEROVECS
STODL DELVROD
RODSCALE
STODL RODSCAL1
PIPTIME
STORE LASTTPIP
EXIT
CAF ZERO
TS FCOLD
TS FWEIGHT
TS FWEIGHT +1
VRTSTART TS WCHVERT
# Page 801
CAF TWO # WCHPHASE = 2 ---> VERTICAL: P65,P66,P67
TS WCHPHOLD
TS WCHPHASE
TC BANKCALL # TEMPORARY, I HOPE HOPE HOPE
CADR STOPRATE # TEMPORARY, I HOPE HOPE HOPE
TC DOWNFLAG # PERMIT X-AXIS OVERRIDE
ADRES XOVINFLG
TC DOWNFLAG
ADRES REDFLAG
TCF VERTGUID

STARTP67 TC NEWMODEX # NO HARM IN "STARTING" P67 OVER AND OVER
DEC 67 # SO NO NEED FOR A FASTCHNG AND NO NEED
CAF ZERO # TO SEE IF ALREADY IN P67.
TS RODCOUNT
CAF TEN
TCF VRTSTART

STABL? CAF BIT13 # IS UN-ATTITUDE-HOLD DISCRETE PRESENT?
EXTEND
RAND CHAN31
CCS A
TCF GUILDRET # YES ALL'S WELL

P66NOW? CS MODREG
AD DEC66
EXTEND
BZF RESTART?

CA RODCOUNT # NO. HAS THE ROD SWITCH BEEN "CLICKED"?
EXTEND
BZF GUILDRET # NO. CONTINUE WITH AUTOMATIC LANDING
TCF STARTP66 # YES. SWITCH INTO THE ROD MODE.


RESTART? CA FLAGWRD1 # HAS THERE BEEN A RESTART?
MASK RODFLBIT
EXTEND
BZF STRTP66A # YES. REINITIALIZE BUT LEAVE VDGVERT AS
# IS.

TCF VERTGUID # NO: CONTINUE WITH R.O.D.

# *******************************************************************************
# INITIALIZATION FOR THIS PASS
# *******************************************************************************

COUNT* $$/F2DPS

GUILDRET CAF ZERO
TS RODCOUNT

# Page 802
+2 EXTEND
DCA TPIP
DXCH TPIPOLD

TC FASTCHNG

EXTEND
DCA PIPTIME1
DXCH TPIP

EXTEND
DCA TTF/8
DXCH TTF/8TMP

CCS FLPASS0
TCF TTFINCR

BRSPOT1 INDEX WCHPHASE
TCF NEWPHASE

# ******************************************************************
# ROUTINES TO START NEW PHASES
# ******************************************************************

P65START TC NEWMODEX
DEC 65
CS TWO
TS WCHVERT
TC DOWNFLAG # PERMIT X-AXIS OVERRIDE
ADRES XOVINFLG
TCF TTFINCR

STARTP64 TC NEWMODEX
DEC 64
CA DELTTFAP # AUGMENT TTF/8
ADS TTF/8TMP
CA BIT12 # ENABLE RUPT10
EXTEND
WOR CHAN13
TC DOWNFLAG # INITIALIZE REDESIGNATION FLAG
ADRES REDFLAG


# (CONTINUE TO TTFINCR)

# *********************************************************************************
# INCREMENT TTF/8, UPDATE LAND FOR LUNAR ROTATION, DO OTHER USEFUL THINGS
# *********************************************************************************
#
# TTFINCR COMPUTATIONS ARE AS FOLLOWS --
# Page 803
# TTF/8 UPDATED FOR TIME SINCE LAST PASS:
# TTF/8 = TTF/8 + (TPIP - TPIPOLD)/8
# LANDING SITE VECTOR UPDATED FOR LUNAR ROTATION:
# ____ ____ ____ __
# LAND = /LAND/ UNIT(LAND - LAND(TPIP - TPIPOLD) * WM)
# SLANT RANGE TO LANDING SITE, FOR DISPLAY:
# ____ _
# RANGEDSP = ABVAL(LAND - R)

TTFINCR TC INTPRET
DLOAD DSU
TPIP
TPIPOLD
SLR PUSH # SHIFT SCALES DELTA TIME TO 2(17) CSECS
11D
VXSC VXV
LAND
WM
BVSU RTB
LAND
NORMUNIT
VXSC VSL1
/LAND/
STODL LANDTEMP
EXIT

DXCH MPAC
DAS TTF/8TMP # NOW HAVE INCREMENTED TTF/8 IN TTF/8TMP

TC FASTCHNG

EXTEND
DCA TTF/8TMP
DXCH TTF/8

EXTEND
DCA LANDTEMP
DXCH LAND
EXTEND
DCA LANDTEMP +2
DXCH LAND +2
EXTEND
DCA LANDTEMP +4
DXCH LAND +4

# Page 804
TC TDISPSET
TC FASTCHNG # SINCE REDESIG MAY CHANGE LANDTEMP

BRSPOT2 INDEX WCHPHASE
TCF PREGUIDE

# *********************************************************************
# LANDING SITE PERTURBATION EQUATIONS
# *********************************************************************

REDESIG CA FLAGWRD6 # IS REDFLAG SET?
MASK REDFLBIT
EXTEND
BZF RGVGCALC # NO: SKIP REDESIGNATION LOGIC

CA TREDES # YES: HAS TREDES REACHED ZERO?
EXTEND
BZF RGVGCALC # YES: SKIP REDESIGNATION LOGIC

INHINT
CA ELINCR1
TS ELINCR
CA AZINCR1
TS AZINCR
TC FASTCHNG

CA ZERO
TS ELINCR1
TS AZINCR1
TS ELINCR +1
TS AZINCR +1

CA FIXLOC # SET PD TO 0
TS PUSHLOC

TC INTPRET
VLOAD VSU
LAND
R # ____ _
RTB PUSH # PUSH DOWN UNIT (LAND - R)
NORMUNIT
VXV VSL1
YNBPIP # ___ ____ _
VXSC PDDL # PUSH DOWN - ELINCR(YNB * UNIT(LAND - R))
ELINCR
AZINCR
VXSC VSU
YNBPIP
VAD PUSH # RESULTING VECTOR IS 1/2 REAL SIZE

# Page 805

DLOAD DSU # MAKE SURE REDESIGNATION IS NOT
0 # TOO CLOSE TO THE HORIZON.
DEPRCRIT
BMN DLOAD
REDES1
DEPRCRIT
STORE 0
REDES1 DLOAD DSU
LAND
R
DDV VXSC
0
VAD UNIT
R
VXSC VSL1
/LAND/
STORE LANDTEMP
EXIT # LOOKANGL WILL BE COMPUTED AT RGVGCALC

TC FASTCHNG

EXTEND
DCA LANDTEMP
DXCH LAND
EXTEND
DCA LANDTEMP +2
DXCH LAND +2
EXTEND
DCA LANDTEMP +4
DXCH LAND +4

TCF RGVGCALC


# *********************************************************************
# COMPUTE STATE IN GUIDANCE COORDINATES
# *********************************************************************
#
# RGVGCALC COMPUTATIONS ARE AS FOLLOWS:--
# VELOCITY RELATIVE TO THE SURFACE
# _______ _ _ __
# ANGTERM = V + R * WM
# STATE IN GUIDANCE COORDINTES:
# ___ * _ ____
# RGU = CG (R - LAND)
# ___ * _ __ _
# VGU = CG (V - WM * R)
# Page 806 actually starts one line earlier but that would separate the markers from their variables
#
# HORIZONTAL VELOCITY FOR DISPLAY
#
# VHORIZ = 8 ABVAL (0, VG , VG )
# 2 1
# DEPRESSION ANGLE FOR DISPLAY:
# _ ____ ______
# LOOKANGL = ARCSIN(UNIT(R - LAND).XMBPIP)

CALCRGVG TC INTPRET # IN IGNALG, COMPUTE V FROM INTEGRATION
VLOAD MXV # OUTPUT AND TRIM CORRECTION TERM
VATT1 # COMPUTED LAST PASS AND LEFT IN UNFC/2
REFSMMAT
VSR1 VAD
UNFC/2
STORE V
EXIT

RGVGCALC TC INTPRET # ENTER HERE TO RECOMPUTE RG AND VG
VLOAD VXV
R
WM
VAD VSR2 # RESCALE TO UNITS OF 2(9) M/CS
V
STORE ANGTERM
MXV
CG # NO SHIFT SINCE ANGTERM IS DOUBLE SIZED
STORE VGU
PDDL VDEF # FORM (0,VG ,VG ) IN UNITS OF 2(10) M/CS
ZEROVECS # 2 1
ABVAL SL3
STOVL VHORIZ # VHORIZ FOR DISPLAY DURING P65.
R # _ ____
VSU PUSH # PUSH DOWN R - LAND
LAND
MXV VSL1
CG
STORE RGU
ABVAL
STOVL RANGEDSP
RTB DOT # NOW IN MPAC IS SINE(LOOKANGL)/4
NORMUNIT
XNBPIP
EXIT

CA FIXLOC # RESET PUSH DOWN POINTER
TS PUSHLOC

# Page 807
CA MPAC # COMPUTE LOOKANGLE ITSELF
DOUBLE
TC BANKCALL
CADR SPARCSIN -1
AD 1/2DEG
EXTEND
MP 180DEGS
TS LOOKANGL # LOOKANGL FOR DISPLAY DURING P64

BRSPOT3 INDEX WCHPHASE
TCF WHATGUID

# **************************************************************************
# TTF/8 COMPUTATION
# **************************************************************************

TTF/8CL TC INTPRETX
DLOAD*
JDG2TTF,1
STODL* TABLTTF +6 # A(3) = 8 JDG TO TABLTTF
ADG2TTF,1 # 2
STODL TABLTTF +4 # A(2) = 6 ADG TO TABLTTF
VGU +4 # 2
DMP DAD*
3/4DP
VDG2TTF,1
STODL* TABLTTF +2 # A(1) = (6 VGU + 18 VDG )/8 TO TABLTTF
RDG +4,1 # 2 2
DSU DMP
RGU +4
3/8DP
STORE TABLTTF # A(0) = -24 (RGU - RDG )/64 TO TABLTTF
EXIT # 2 2

CA BIT8
TS TABLTTF +10 # FRACTIONAL PRECISION FOR TTF TO TABLE

EXTEND
DCA TTF/8
DXCH MPAC # LOADS TTF/8 (INITIAL GUESS) INTO MPAC
CAF TWO # DEGREE - ONE
TS L
CAF TABLTTFL
TC ROOTPSRS # YIELDS TTF/8 IN MPAC
INDEX WCHPHASE
TCF WHATALM

EXTEND # GOOD RETURN
DCA MPAC # FETCH TTF/8 KEEPING IT IN MPAC
DXCH TTF/8 # CORRECTED TTF/8

# Page 808
TC TDISPSET

# (CONTINUE TO QUADGUID)

# *********************************************************************************
# MAIN GUIDANCE EQUATION
# *********************************************************************************
#
# AS PUBLISHED --
# ___ __ ___ __
# ___ ___ 6(VDG + VG) 12(RDG - RG)
# ACG = ADG + ----------- + ------------
# TTF (TTF)(TTF)
# AS HERE PROGRAMMED --
# ___ __
# 3 (1/4(RDG - RG) ___ __)
# - (------------- + VDG + VG)
# ___ 4 ( TTF/8 ) ___
# ACG = ---------------------------- + ADG
# TTF/8

QUADGUID CS TTF/8
AD LEADTIME # LEADTIME IS A NEGATIVE NUMBER
AD POSMAX # SAFEGUARD THE COMPUTATIONS THAT FOLLOW
TS L # BY FORCING -TTF*LEADTIME > OR = ZERO
CS L
AD L
ZL
EXTEND
DV TTF/8
TS BUF # - RATIO OF LAG-DIMINISHED TTF TO TTF
EXTEND
SQUARE
TS BUF +1
AD BUF
XCH BUF +1 # RATIO SQUARED - RATIO
AD BUF +1
TS MPAC # COEFFICIENT FOR VGU TERM
AD BUF +1
INDEX FIXLOC
TS 26D # COEFFICIENT FOR RDG-RGU TERM
AD BUF +1
INDEX FIXLOC
TS 28D # COEFFICIENT FOR VDG TERM
AD BUF
AD POSMAX
# Page 809
AD BUF +1
AD BUF +1
INDEX FIXLOC
TS 30D # COEFFICIENT FOR ADG TERM

CAF ZERO
TS MODE

TC INTPRETX
VXSC PDDL
VGU
28D
VXSC* PDVL*
VDG,1
RDG,1
VSU V/SC
RGU
TTF/8
VSR2 VXSC
26D
VAD VAD
V/SC VXSC
TTF/8
3/4DP
PDDL VXSC*
30D
ADG,1
VAD
AFCCALC1 VXM VSL1 # VERGUID COMES HERE
CG
PDVL V/SC
GDT/2
GSCALE
BVSU STADR
STORE UNFC/2 # UNFC/2 NEED NOT BE UNITIZED
ABVAL
AFCCALC2 STODL /AFC/ # MAGNITUDE OF AFC FOR THROTTLE
UNFC/2 # VERTICAL COMPONENT
DSQ PDDL
UNFC/2 +2 # OUT-OF-PLANE
DSQ PDDL
HIGHESTF
DDV DSQ
MASS # 2 2 2
DSU DSU # AMAXHORIZ = SQRT(ATOTAL - A - A )
BPL DLOAD # 1 0
AFCCALC3
ZEROVECS
AFCCALC3 SQRT DAD
UNFC/2 +4
# Page 810
BPL BDSU
AFCCLEND
UNFC/2 +4
STORE UNFC/2 +4
AFCCLEND EXIT
TC FASTCHNG


CA WCHPHASE # PREPARE FOR PHASE SWITCHING LOGIC
TS WCHPHOLD
INCR FLPASS0 # INCREMENT PASS COUNTER

BRSPOT4 INDEX WCHPHASE
TCF AFTRGUID

# ***********************************************************************
# ERECT GUIDANCE-STABLE MEMBER TRANSFORMATION MATRIX
# ***********************************************************************

CGCALC CAF EBANK5
TS EBANK
EBANK= TCGIBRAK
EXTEND
INDEX WCHPHASE
INDEX TARGTDEX
DCA TCGFBRAK
INCR BBANK
INCR BBANK
EBANK= TTF/8
AD TTF/8
XCH L
AD TTF/8
CCS A
CCS L
TCF EXTLOGIC
TCF EXTLOGIC
NOOP

TC INTPRETX
VLOAD UNIT
LAND
STODL CG
TTF/8
DMP* VXSC
GAINBRAK,1 # NUMERO MYSTERIOSO
ANGTERM
VAD
LAND
VSU RTB
R
NORMUNIT
# Page 811
VXV RTB
LAND
NORMUNIT
STOVL CG +6 # SECOND ROW
CG
VXV VSL1
CG +6
STORE CG +14
EXIT

# (CONTINUE TO EXTLOGIC)
#
# ***********************************************************************
# PREPARE TO EXIT
# ***********************************************************************
#
# DECIDE (1) HOW TO EXIT, AND (2) WHETHER TO SWITCH PHASES
#
EXTLOGIC INDEX WCHPHASE # WCHPHASE = 1 APPRQUAD
CA TENDBRAK # WCHPHASE = 0 BRAKQUAD
AD TTF/8

EXSPOT1 EXTEND
INDEX WCHPHASE
BZMF WHATEXIT

TC FASTCHNG

CA WCHPHOLD
AD ONE
TS WCHPHASE
CA ZERO
TS FLPASS0 # RESET FLPASS0

INDEX WCHPHOLD
TCF WHATEXIT

# ***********************************************************************
# ROUTINES FOR EXITING FROM LANDING GUIDANCE
# ***********************************************************************
#
# 1. EXGSUB IS THE RETURN WHEN GUIDSUB IS CALLED BY THE IGNITION ALGORITHM.
# 2. EXBRAK IN THE EXIT USED DURING THE BRAKING PHASE. IN THIS CASE UNIT(R) IS THE WINDOW POINTING VECTOR.
# 3. EXNORM IS THE EXIT USED AT OTHER TIMES DURING THE BURN.
# (EXOVFLOW IS A SUBROUTINE OF EXBRAK AND EXNORM CALLED WHEN OVERFLOW OCCURRED ANYWHERE IN GUIDANCE.)

EXGSUB TC INTPRET # COMPUTE TRIM VELOCITY CORRECTION TERM.
# Page 812
VLOAD RTB
UNFC/2
NORMUNIT
VXSC VXSC
ZOOMTIME
TRIMACCL
STORE UNFC/2
EXIT

CCS NGUIDSUB
TCF GUIDSUB
CCS NIGNLOOP
TCF +3
TC ALARM
OCT 01412

+3 TC POSTJUMP
CADR DDUMCALC

EXBRAK TC INTPRET
VLOAD
UNIT/R/
STORE UNWC/2
EXIT
TCF STEER?

EXNORM TC INTPRET
VLOAD VSU
LAND
R
RTB
NORMUNIT
STORE UNWC/2 # UNIT(LAND - R) IS TENTATIVE CHOICE
VXV DOT
XNBPIP
CG +6
EXIT # WITH PROJ IN MPAC 1/8 REAL SIZE

CS MPAC # GET COEFFICIENT FOR CG +14
AD PROJMAX
AD POSMAX
TS BUF
CS BUF
ADS BUF # RESULT IS 0 IF PROJMAX - PROJ NEGATIVE

CS PROJMIN # GET COEFFICIENT FOR UNIT(LAND - R)
AD MPAC
AD POSMAX
TS BUF +1
CS BUF +1
# Page 813
ADS BUF +1 # RESULT IS 0 IF PROJ - PROJMIN NEGATIVE

CAF FOUR
UNWCLOOP MASK SIX
TS Q
CA EBANK5
TS EBANK
EBANK= CG
CA BUF
EXTEND
INDEX Q
MP CG +14
INCR BBANK
EBANK= UNWC/2
INDEX Q
DXCH UNWC/2
EXTEND
MP BUF +1
INDEX Q
DAS UNWC/2
CCS Q
TCF UNWCLOOP

INCR BBANK
EBANK= PIF

STEER? CA FLAGWRD2 # IF STEERSW DOWN NO OUTPUTS
MASK STEERBIT
EXTEND
BZF RATESTOP

EXVERT CA OVFIND # IF OVERFLOW ANYWHERE IN GUIDANCE
EXTEND # DON'T CALL THROTTLE OR FINDCDUW
BZF +13

EXOVFLOW TC ALARM # SOUND THE ALARM NON-ABORTIVELY
OCT 01410

RATESTOP CAF BIT13 # ARE WE IN ATTITUDE-HOLD?
EXTEND
RAND CHAN31
EXTEND
BZF DISPEXIT # YES

TC BANKCALL # NO: DO A STOPRATE
CADR STOPRATE

TCF DISPEXIT

GDUMP1 TC THROTTLE
# Page 814
TC INTPRET
CALL
FINDCDUW -2
EXIT

# (CONTINUE TO DISPEXIT)


# ***********************************************************************
# GUIDANCE LOOP DISPLAYS
# ***********************************************************************

DISPEXIT EXTEND # KILL GROUP 3: DISPLAYS WILL BE
DCA NEG0 # RESTORED BY NEXT GUIDANCE CYCLE.
DXCH -PHASE3

+3 CS FLAGWRD8 # IF FLUNDISP IS SET, NO DISPLAY THIS PASS
MASK FLUNDBIT
EXTEND
BZF ENDLLJOB # TO PICK UP THE TAG

INDEX WCHPHOLD
TCF WHATDISP

-2 TC PHASCHNG # KILL GROUP 5
OCT 00035

P63DISPS CAF V06N63
DISPCOMN TC BANKCALL
CADR REGODSPR

ENDLLJOB TCF ENDOFJOB

P64DISPS CA TREDES # HAS TREDES REACHED ZERO?
EXTEND
BZF RED-OVER # YES: CLEAR REDESIGNATION FLAG

CS FLAGWRD6 # NO: IS REDFLAG SET?
MASK REDFLBIT
EXTEND
BZF REDES-OK # YES: DO STATIC DISPLAY

CAF V06N64 # OTHERWISE USE FLASHING DISPLAY
TC BANKCALL
CADR REFLASHR
TCF GOTOP00H # TERMINATE
TCF P64CEED # PROCEED PERMIT REDESIGNATIONS
TCF P64DISPS # RECYCLE
# Page 815
TCF ENDLLJOB

P64CEED CAF ZERO
TS ELINCR1
TS AZINCR1

TC UPFLAG # ENABLE REDESIGNATION LOGIC
ADRES REDFLAG

TCF ENDOFJOB

RED-OVER TC DOWNFLAG
ADRES REDFLAG
REDES-OK CAF V06N64
TCF DISPCOMN


VERTDISP CAF V06N60
TCF DISPCOMN


# **************************************************************************
# GUIDANCE FOR P65
# **************************************************************************

VERTGUID CCS WCHVERT
TCF P67VERT # POSITIVE NON-ZERO ---> P67
TCF P66VERT # +0
#
# THE P65 GUIDANCE EQUATION IS AS FOLLOWS --
# ____ ___
# V2FG - VGU
# ACG = ----------
# TAUVERT

P65VERT TC INTPRET
VLOAD VSU
V2FG
VGU
V/SC GOTO
TAUVERT
AFCCALC1
# Page 816
# **********************************************************
# GUIDANCE FOR P66
# **********************************************************

P66VERT TC POSTJUMP
CADR P66VERTA

P67VERT TC PHASCHNG # TERMINATE GROUP 3.
OCT 00003

TC INTPRET
VLOAD GOTO
V
VHORCOMP

SETLOC P66LOC
BANK
COUNT* $$/F2DPS

RODTASK CAF PRIO22
TC FINDVAC
EBANK= DVCNTR
2CADR RODCOMP

TCF TASKOVER

P66VERTA TC PHASCHNG # TERMINATE GROUP 3.
OCT 00003

CAF 1SEC
TC TWIDDLE
ADRES RODTASK

RODCOMP INHINT
CAF ZERO
XCH RODCOUNT
EXTEND
MP RODSCAL1
DAS VDGVERT # UPDATE DESIRED ALTITUDE RATE.

EXTEND # SET OLDPIPAX,Y,Z = PIPAX,Y,Z
DCA PIPAX
DXCH OLDPIPAX
DXCH RUPTREG1 # SET RUPTREG1,2,3 = OLDPIPAX,Y,Z
CA PIPAZ
XCH OLDPIPAZ
XCH RUPTREG3

EXTEND # SHAPSHOT TIME OF PIPA READING.
DCA TIME2
# Page 817
DXCH THISTPIP

CA OLDPIPAX
AD PIPATMPX
TS MPAC # MPAC(X) = PIPAX + PIPATMPX
CA OLDPIPAY
AD PIPATMPY
TS MPAC +3 # MPAC(Y) = PIPAY + PIPATMPY
CA OLDPIPAZ
AD PIPATMPZ
TS MPAC +5 # MPAC(Z) = PIPAZ + PIPATMPZ

CS OLDPIPAX
AD TEMX
AD RUPTREG1
TS DELVROD
CS OLDPIPAY
AD TEMY
AD RUPTREG2
TS DELVROD +2
CS OLDPIPAZ
AD TEMZ
AD RUPTREG3
TS DELVROD +4

CAF ZERO
TS MPAC +1 # ZERO LO-ORDER MPAC COMPONENTS
TS MPAC +4
TS MPAC +6
TS TEMX # ZERO TEMX, TEMY, AND TEMZ SO WE WILL
TS TEMY # KNOW WHEN READACCS CHANGES THEM.
TS TEMZ
CS ONE
TS MODE
TC INTPRET
ITRPNT1 VXSC PDDL # SCALE MPAC TO M/CS *2(-7) AND PUSH (6)
KPIP1
THISTPIP
DSU
PIPTIME
STORE 30D # 30-31D CONTAINS TIME IN CS SINCE PIPTIME
DDV PDVL # (8)
4SEC(28)
GDT/2
VSU VXSC # (6)
VBIAS
VSL2 VAD
V
VAD STADR # (0)
STOVL 24D # STORE UPDATED VELOCITY IN 24-29D
# Page 818
R
UNIT
STORE 14D
DOT SL1
24D
STODL HDOTDISP # UPDATE HDOTDISP RATE FOR NOUN 63.
30D
SL DMP
11D
HDOTDISP
DAD DSU
36D
/LAND/
STODL HCALC1 # UPDATE HCALC1 FOR NOUN 63.
HDOTDISP
BDSU DDV
VDGVERT
TAUROD
PDVL ABVAL # (2)
GDT/2
DDV SR2
GSCALE
STORE 20D
DAD # (0)
PDVL CALL # (2)
UNITX
CDU*NBSM
DOT
14D
STORE 22D
BDDV STADR # (0)
STOVL /AFC/
DELVROD
VXSC VAD
KPIP1
VBIAS
ABVAL PDDL # (2)
THISTPIP
DSU PDDL # (4)
LASTTPIP
THISTPIP
STODL LASTTPIP # (2)
DDV BDDV # (0)
SHFTFACT
PDDL DMP # (2)
FWEIGHT
BIT1H
DDV DDV
MASS
SCALEFAC
# Page 819
DAD PDDL # (4)
0D
20D
DDV DSU # (2)
22D
DMP DAD
LAG/TAU
/AFC/
PDDL DDV # (4)
MAXFORCE
MASS
PDDL DDV # (6)
MINFORCE
MASS
PUSH BDSU # (8)
2D
BMN DLOAD # (6)
AFCSPOT
DLOAD PUSH # (6)
BDSU BPL
2D
AFCSPOT
DLOAD # (4)
AFCSPOT DLOAD # (2), (4), OR (6)
SETPD # (2)
2D
STODL /AFC/ # (0)
ITRPNT2 EXIT
DXCH MPAC # MPAC = MEASURED ACCELARATION.
TC BANKCALL
CADR THROTTLE +3
TC INTPRET
VLOAD # PICK UP UPDATED VELOCITY VECTOR.
24D
VHORCOMP VSL2 VAD
DELVS
VSR2 PDVL
R
UNIT VXSC
HDOTDISP
VSL1 BVSU
ABVAL
STORE VHORIZ
EXIT
TC BANKCALL # PUT UP V06N60 DISPLAY BUT AVOID PHASCHNG
CADR DISPEXIT +3


BIT1H OCT 00001
SHFTFACT 2DEC 1 B-17
# Page 820
BIASFACT 2DEC 655.36 B-28

# *********************************************************************************
# REDESIGNATOR TRAP
# *********************************************************************************

BANK 11
SETLOC F2DPS*11
BANK

COUNT* $$/F2DPS

PITFALL XCH BANKRUPT
EXTEND
QXCH QRUPT

TC CHECKMM # IF NOT IN P64, NO REASON TO CONTINUE
DEC 64
TCF RESUME

EXTEND
READ CHAN31
COM
MASK ALL4BITS
TS ELVIRA
CAF TWO
TS ZERLINA
CAF FIVE
TC TWIDDLE
ADRES REDESMON
TCF RESUME

# REDESIGNATOR MONITOR (INITIATED BY PITFALL)

PREMON1 TS ZERLINA
PREMON2 CAF SEVEN
TC VARDELAY
REDESMON EXTEND
READ 31
COM
MASK ALL4BITS
XCH ELVIRA
TS L
CCS ELVIRA # DO ANY BITS APPEAR THIS PASS?
TCF PREMON2 # Y: CONTINUE MONITOR

CCS L # N: ANY LAST PASS?
TCF COUNT'EM # Y: COUNT 'EM, RESET RUPT, TERMINATE
# Page 821
CCS ZERLINA # N: HAS ZERLINA REACHED ZERO YET?
TCF PREMON1 # N: DIMINISH ZERLINA, CONTINUE
RESETRPT CAF BIT12 # Y: RESET RUPT. TERMINATE
EXTEND
WOR CHAN13
TCF TASKOVER

COUNT'EM CAF BIT13 # ARE WE IN ATTITUDE-HOLD?
EXTEND
RAND CHAN31
EXTEND
BZF RESETRPT # YES: SKIP REDESIGNATION LOGIC.

CA L # NO.
MASK -AZBIT
CCS A
-AZ CS AZEACH
ADS AZINCR1
CA L
MASK +AZBIT
CCS A
+AZ CA AZEACH
ADS AZINCR1
CA L
MASK -ELBIT
CCS A
-EL CS ELEACH
ADS ELINCR1
CA L
MASK +ELBIT
CCS A
+EL CA ELEACH
ADS ELINCR1
TCF RESETRPT

# THESE EQUIVALENCES ARE BASED ON GSOP CHAPTER 4, REVISION 16 OF P64LM

+ELBIT = BIT2 # -PITCH
-ELBIT = BIT1 # +PITCH
+AZBIT = BIT5
-AZBIT = BIT6

# Page 822
ALL4BITS OCT 00063
AZEACH DEC .03491 # 2 DEGREES
ELEACH DEC .00873 # 1/2 DEGREE

# ****************************************************************
# R.O.D. TRAP
# ****************************************************************

BANK 20
SETLOC RODTRAP
BANK
COUNT* $$/F2DPS # ************************

DESCBITS MASK BIT7 # COME HERE FROM MARKRUPT CODING WITH BIT
CCS A # 7 OR 6 OF CHANNEL 16 IN A; BIT 7 MEANS
CS TWO # - RATE INCREMENT, BIT 6 + INCREMENT.
AD ONE
ADS RODCOUNT
TCF RESUME # TRAP IS RESET WHEN SWITCH IS RELEASED

BANK 31
SETLOC F2DPS*31
BANK

COUNT* $$/F2DPS

# ***********************************************************************************
# DOUBLE PRECISION ROOT FINDER SUBROUTINE (BY ALLAN KLUMPP)
# ***********************************************************************************
#
# N N-1
# ROOTPSRS FINDS ONE ROOT OF THE POWER SERIES A X + A X + ... + A X + A
# N N-1 1 0
# USING NETON'S METHOD STARTING WITH AN INITIAL GUESS FOR THE ROOT. THE ENTERING DATA MUST BE AS FOLLOWS:
# A SP LOC-3 ADRES FOR REFERENCING PWR COF TABL
# L SP N-1 N IS THE DEGREE OF THE POWER SERIES
# MPAC DP X INITIAL GUESS FOR ROOT
#
# LOC-2N DP A(0)
# ...
# LOC DP A(N)
# LOC+2 SP PRECROOT PREC RQD OF ROOT (AS FRACT OF 1ST GUESS)
#
# Page 823
# THE DP RESULT IS LEFT IN MPAC UPON EXIT, AND A SP COUNT OF THE ITERATIONS TO CONVERGENCE IS LEFT IN MPAC+2.
# RETURN IS NORMALLY TO LOC(TC ROOTPSRS)+3. IF ROOTPSRS FAILS TO CONVERGE TO IN 8 PASSES, RETURN IS TO LOC+1 AND
# OUTPUTS ARE NOT TO BE TRUSTED.
#
# PRECAUTION: ROOTPSRS MAKES NO CHECKS FOR OVERFLOW OR FOR IMPROPER USAGE. IMPROPER USAGE COULD
# PRECLUDE CONVERGENCE OR REQUIRE EXCESSIVE ITERATIONS. AS A SPECIFIC EXAMPLE, ROOTPSRS FORMS A DERIVATIVE
# COEFFICIENT TABLE BY MULTIPLYINE EACH A(I) BY I, WHERE I RANGES FROM 1 TO N. IF AN ELEMENT OF THE DERIVATIVE
# COEFFICIENT TABLE = 1 OR >1 IN MAGNITUDE, ONLY THE EXCESS IS RETAINED. ROOTPSRS MAY CONVERGE ON THE COREECT
# ROOT NONETHELESS, BUT IT MAY TAKE AN EXCESSIVE NUMBER OF ITERATIONS. THEREFORE THE USER SHOULD RECOGNIZE:
# 1. USER'S RESPONSIBILITY TO ASSUR THAT I X A(I) < 1 IN MAGNITUDE FOR ALL I.
# 2. USER'S RESPONSIBILITY TO ASSURE OVERFLOW WILL NOT OCCUR IN EVALUTATING EITHER THE RESIDUAL OR THE DERIVATIVE
# POWER SERIES. THIS OVERFLOW WOULD BE PRODUCED BY SUBROUTINE POWRSERS, CALLED BY ROOTPSRS, AND MIGHT NOT
# PRECLUDE EVENTUAL CONVERGENCE.
# 3. AT PRESENT, ERASABLE LOCATIONS ARE RESERVED ONLY FOR N UP TO 5. AN N IN EXCESS OF 5 WILL PRODUCE CHAOS.
# ALL ERASABLES USED BY ROOTPSRS ARE UNSWITCHED LOCATED IN THE REGION FROM MPAC-33 OCT TO MPAC+7.
# 4. THE ITERATION COUNT RETURNED IN MPAC+2 MAY BE USED TO DETECT ABNORMAL PERFORMANCE.

# STORE ENTERING DATA, INITIALIZE ERASABLES
ROOTPSRS EXTEND
QXCH RETROOT # RETURN ADRES
TS PWRPTR # PWR TABLE POINTER
DXCH MPAC +3 # PWR TABLE ADRES, N-1
CA DERTABLL
TS DERPTR # DER TABL POINTER
TS MPAC +5 # DER TABL ADRES
CCS MPAC +4 # NO POWER SERIES DEGREE 1 OR LESS
TS MPAC +6 # N-2
CA ZERO # MODE USED AS ITERATION COUNTER. MODE
TS MODE # MUST BE POS SO ABS WON'T COMP MPAC+3 ETC.

# COMPUTE CRITERION TO STOP ITERATING
EXTEND
DCA MPAC # FETCH ROOT GUESS, KEEPING IT IN MPAC
DXCH ROOTPS # AND IN ROOTPS
INDEX MPAC +3 # PWR TABLE ADRES
CA 5 # PRECROOT TO A
TC SHORTMP # YIELDS DP PRODUCT IN MPAC
TC USPRCADR
CADR ABS # YIELDS ABVAL OF CRITERION ON DX IN MPAC
DXCH MPAC
DXCH DXCRIT # CRITERION

# SET UP DER COF TABL
# Page 824
EXTEND
INDEX PWRPTR
DCA 3
DXCH MPAC # A(N) TO MPAC

CA MPAC +4 # N-1 TO A

DERCLOOP TS PWRCNT # LOOP COUNTER
AD ONE
TC DMPNSUB # YIELDS DERCOF = I X A(I) IN MPAC
EXTEND
INDEX PWRPTR
DCA 1
DXCH MPAC # (I-1) TO MPAC, FETCHING DERCOF
INDEX DERPTR
DXCH 3 # DERCOF TO DER TABLE
CS TWO
ADS PWRPTR # DECREMENT PWR POINTER
CS TWO
ADS DERPTR # DECREMENT DER POINTER
CCS PWRCNT
TCF DERCLOOP


# CONVERGE ON ROOT
ROOTLOOP EXTEND
DCA ROOTPS # FETCH CURRENT ROOT
DXCH MPAC # LEAVE IN MPAC
EXTEND
DCA MPAC +5 # LOAD A, L WITH DER TABL ADRES, N-2
TC POWRSERS # YIELDS DERIVATIVE IN MPAC

EXTEND
DCA ROOTPS
DXCH MPAC # CURRENT ROOT TO MPAC, FETCHING DERIVATIVE
DXCH BUF # LEAVE DERIVATIVE IN BUF AS DIVISOR
EXTEND
DCA MPAC +3 # LOAD A, L WITH PWR TABL ADRES, N-1
TC POWRSERS # YIELDS RESIDUAL IN MPAC

TC USPRCADR
CADR DDV/BDDV # YIELDS -DX IN MPAC

EXTEND
DCS MPAC # FETCH DX, LEAVING -DX IN MPAC
DAS ROOTPS # CORRECTED ROOT NOW IN ROOTPS

TC USPRCADR
CADR ABS # YIELDS ABS(DX) IN MPAC
EXTEND
# Page 825
DCS DXCRIT
DAS MPAC # ABS(DX)-ABS(DXCRIT) IN MPAC

CA MODE
MASK BIT4 # KLUMPP SAYS GIVE UP AFTER EIGHT PASSES
CCS A
BADROOT TC RETROOT

INCR MODE # INCREMENT ITERATION COUNTER
CCS MPAC # TEST HI ORDER DX
TCF ROOTLOOP
TCF TESTLODX
TCF ROOTSTOR
TESTLODX CCS MPAC +1 # TEST LO ORDER DX
TCF ROOTLOOP
TCF ROOTSTOR
TCF ROOTSTOR
ROOTSTOR DXCH ROOTPS
DXCH MPAC
CA MODE
TS MPAC +2 # STORE SP ITERATION COUNT IN MPAC+2
INDEX RETROOT
TCF 2

DERTABLL ADRES DERCOFN -3

# ****************************************************************************
# TRASHY LITTLE SUBROUTINES
# ****************************************************************************

INTPRETX INDEX WCHPHASE # SET X1 ON THE WAY TO THE INTERPRETER
CS TARGTDEX
INDEX FIXLOC
TS X1
TCF INTPRET

TDISPSET CA TTF/8
EXTEND
MP TSCALINV
DXCH TTFDISP

CA EBANK5 # TREDES BECOMES ZERO TWO PASSES
TS EBANK # BEFORE TCGFAPPR IS REACHED
EBANK= TCGFAPPR
CA TCGFAPPR
INCR BBANK
INCR BBANK
EBANK= TTF/8
# Page 826
AD TTF/8
EXTEND
MP TREDESCL
AD -DEC103
AD NEGMAX
TS L
CS L
AD L
AD +DEC99
AD POSMAX
TS TREDES
CS TREDES
ADS TREDES
TC Q

1406P00 TC P00DOO
OCT 01406
1406ALM TC ALARM
OCT 01406
TCF RATESTOP

# *********************************************************************
# SPECIALIZED "PHASCHNG" SUBROUTINE
# *********************************************************************

EBANK= PHSNAME2
FASTCHNG CA EBANK3 # SPECIALIZED 'PHASCHNG' ROUTINE
XCH EBANK
DXCH L
TS PHSNAME3
LXCH EBANK
EBANK= E2DPS
TC A

# *************************************************************************************
# PARAMETER TABLE INDIRECT ADDRESSES
# *************************************************************************************

RDG = RBRFG
VDG = VBRFG
ADG = ABRFG
VDG2TTF = VBRFG*
ADG2TTF = ABRFG*
JDG2TTF = JBRFG*

# *************************************************************************************
# LUNAR LANDING CONSTANTS
# *************************************************************************************

# Page 827
TABLTTFL ADRES TABLTTF +3 # ADDRESS FOR REFERENCING TTF TABLE
TTFSCALE = BIT12
TSCALINV = BIT4
-DEC103 DEC -103
+DEC99 DEC +99
TREDESCL DEC -.08
180DEGS DEC +180
1/2DEG DEC +.00278
PROJMAX DEC .42262 B-3 # SIN(25')/8 TO COMPARE WITH PROJ
PROJMIN DEC .25882 B-3 # SIN(15')/8 TO COMPARE WITH PROJ
V06N63 VN 0663 # P63
V06N64 VN 0664 # P64
V06N60 VN 0660 # P65, P66, P67

BANK 22
SETLOC LANDCNST
BANK
COUNT* $$/F2DPS

HIGHESTF 2DEC 4.34546769 B-12
GSCALE 2DEC 100 B-11
3/8DP 2DEC .375
3/4DP 2DEC .750
DEPRCRIT 2DEC -.02 B-1

# Page 828
# **************************************************************************
# **************************************************************************
# Copyright: Public domain.
# Filename: FP8.s
# Purpose: This is the Apollo lunar module's firmware for the
# Abort Guidance System (AGS). This is Flight Program 8.
# Assembler: yaLEMAP
# Contact: Ron Burkey <info@sandroid.org>.
# Website: www.ibiblio.org/apollo/yaAGS.html
# Reference: http://www.ibiblio.org/apollo/Pultorak_files/FP8Listing.pdf.
# Mod history: 2005-01-15 RSB Began.
# 2005-01-17 RSB Data entry complete, but not debugged.
# 2005-01-18 RSB As of yesterday, this assembled with
# 86 fatal errors. These have all been
# repaired. Lots of other stuff fixed too.
# I know know that the addresses and
# opcodes at the ends of each page are
# correct. However, the checksums are
# still wrong, so the next step is to
# proceed with a binary comparison.
# 2005-01-18 RSB Fully debugged and ready to go.
# It has been completely proofed against
# the binary in the scanned assembly
# listing, and the checksums are correct.
# (Of course, it could always use more
# proofing if somebody wanted to do it.
# Particularly the program comments.)
# 2005-05-14 RSB Corrected website reference above.
# 2005-06-12 RSB Fixed comments on p. 117.
#
# The contents have been taken (by means of manual data entry) from
# an assembly listing of Flight Program 8 scanned by John Pultorak from
# a physical copy preserved by supplied by Davis Peticolas. (The WWW link
# for the scan is referenced above.)
#
# This file contains the entire source code for FP8. I have not split the
# source code into many smaller chunks as has been done for AGC source code.
# The page references are to the scanned PDF of the assembly listing, but
# the page markings on the physical copy match the PDF pages. In addition
# to the comments containing the page references, I've also added some
# blank lines for readability. So don't expect the line number in the
# scanned version to match the line numbers in an assembly listing created
# by processing this source file with the yaLEMAP cross-assembler.

# Page 1
# FLIGHT PROGRAM 8 -- LM AGS FP8 S03 4039 -- 12/18/70
# LM ABORT ELECTRONICS ASSEMBLY
#
# SCRATCH PAD STORAGE
ORG 0000
TS0 DEC 0
TS1 DEC 0
TS2 DEC 0
TS3 DEC 0
TS4 DEC 0
TS5 DEC 0
TS6 DEC 0
TS7 DEC 0
TS10 DEC 0
TS11 DEC 0
TS12 DEC 0
TS13 DEC 0
TS14 DEC 0
TS15 DEC 0
TS16 DEC 0
TS17 DEC 0
SREX3 DEC 0
SREX2 DEC 0
SREX1 DEC 0
SREX DEC 0
TVARBR DEC 0 # TEMP STORE FOR CK SUM.
TRA RETURN # SERV ROUT, STARTUP
#
# TAPE LOAD STARTUP CHECKSUM
#
SF OUT 6402 # DEDA INPUT SCALE FACTOR
OCTF INP 2040 # DEDA OCTAL INPUT
#
# THE NEXT 16 LOCATIONS ARE SHARED
# WITH A RR FILTER TEMPORARY MATRIX
#
U2X ALS 1 # B1 UNIT RADIAL VECTOR TO
U2Y TMI *+2 # B1 TRIAL RENDEZ PT.
U2Z TRA *-3 # B1

# Page 2
D11 EQU U2X # RADAR TEMP. MATRIX (16 LOC)
VFX EQU U2X # BRAKING VEL VECTOR AT 13.
C2 DLY *+1 # B1 RENDEZ ANGLE SINE
V1X OUT 7012 # B1 HORIZ UNIT VECTOR
V1Y INP 6200
V1Z CLZ SUM
DLSC CLA V2Z # DOWNLINK SHIFT COUNTER
W1X STO TVARBR # B1 U1 X V1
D31 EQU W1X
W1Y CLZ WRDCNT
W1Z TSQ TVARBR
SI ADZ SUM # B0 E(SIN(E0))
RD2DOT STO SUM # B7 DESIRED RADIAL ACCEL
YD2DOT CLA TVARBR # B7 DESIRED OUT-OF-PLANE ACCEL
TSEX SUB CLAFR # EXIT FROM NORTON
SIDELL TMI U1X # B1 SIN DELTA L
V6X CLZ SUM # B13 TEMP STORAGE FOR TPI QUANT
V6Y TMI *+3
V6Z SUB 1B17
DQSX EQU V6X # ACCUM VEL IN XDV
CODELL TMI EXIT40 # B1 COS DELTA L
WCX CLA 10B4 # B1 UNIT VECTOR NORMAL
WCY STO S12 # TO CSM ORBIT
WCZ OUT 6410
TMPBR TRA SINITC # TEMP BRANCH STORE
U1X CLZ WRDCNT # B1 LEM UNIT RAD VECTGOR
U1Y ADD 1B17
U1Z STO WRDCNT
BRANCH SUB 1B11 # GUIDANCE BRANCH
V2X TMI W1Z # B1 HORZ UNIT VECTOR AT
V2Y DLY W1Y # RENDEZ POINT
V2Z CLA 0206
VGX EQU V2X # VEL TO GAIN VECTOR AT L3
#
# END OF TAPE LOAD CHECKSUM PROGRAM
#
AT DEC 0B7

# Page 3
EX DEC 0B2 # ATTITUDE ERRORS.
EY DEC 0
EZ DEC 0
X3 DEC 0B0 # XFR ORB PARAM.
TR3 EQU X3 # ADDRESS OF RESULT FOR MXM
DVXM1 DEC 0B1 # BODY DELTA VS
DVYM1 DEC 0 # PREVIOUS CYCLE.
DVZM1 DEC 0
NI DEC 0B-9 # PREDICTION ANGULAR FREQUENCY
NE EQU NI # CSM PRED. ANGULAR FREQ.
TR8 EQU NI # RADAR TEMP.
VD2X DEC 0B2 # DELTA V EXP LS
VD2Y DEC 0
VD2Z DEC 0
CI DEC 0B0 # E(COS(E0))
TR1 EQU CI # ADDR. OF 1ST MATRIX FOR MXM
DRX DEC 0B14 # LRM POS REMAINDERS
DRY DEC 0
DRZ DEC 0
THEP DEC 0 # PGNS THETA IN COUNTS.
DIGX DEC 0B7 # PREDICTED CHANGE IN
DIGY DEC 0 # INTEGRATED GRAVITY.
DIGZ DEC 0
PSIP DEC 0 # PGNS PSI IN COUNTS.
GXDT DEC 0B7 # GRAVITY TIMES MAJOR
GYDT DEC 0
GZDT DEC 0
PHIP DEC 0 # PGNS PHI IN COUNTS.
DVSX DEC 0
DVSY DEC 0
DVSZ DEC 0
SIGA DEC 0B1 # SIN FDAI GAMMA.
RRX DEC 0B23 # COMPUTED LM-CSM RANGE
RRY DEC 0
RRZ DEC 0
COGA DEC 0B1 # COS FDAI GAMMA.
A11 DEC 1.0B1 # XB DIRECTION COSINES.

# Page 4
A12 DEC 0
A13 DEC 0
TS8 DEC 0
A31 DEC 0 # ZB DIRECTION COSINES
A32 DEC 0
A33 DEC 1.0B1
SUM DEC 0 # RUNNING MEMORY SUM
A21 DEC 0 # YB DIRECTION COSINES
A22 DEC 1.0B1
A23 DEC 0
X4 DEC 0B0 # XFR ORB PARAM.
VHSQ EQU X4 # 0B26 VH SQUARED
TR2 EQU X4 # ADDR. OF 2ND MATRIX FOR MXM
E1 DEC 0 # -6 OR -9 XB NORM ERROR
E3 DEC 0 # ZB NORMALITY ERROR.
E13 DEC 0 # XB,ZB ORTHOG ERROR.
DEL10 DEC 0 # TPI LOGIC FLAG
DA11 DEC 0B-5 # DIR COSINE REMAINDERS
DA12 DEC 0
DA13 DEC 0
WRDCNT DEC 0 # CKSUM WORD COUNT
DA31 DEC 0
DA32 DEC 0
DA33 DEC 0
DEL44 DEC 0 # RADAR CODE WORD RESET FLAG
A11D DEC 0B1 # XD DIRECTION COSINES.
A12D DEC 0
A13D DEC 0
DEC 0 # ** UNUSED -- INDEXED BY A11D **
A31D DEC 0B1 # ZD DIRECTION COSINES.
A32D DEC 0
A33D DEC 0
MU17 DEC 0B3 # RADAR FILTER ENTRY COUNTER
P DEC 0B23 # TRIAL SEMI-PARAMETER
ALPHA DEC 0B23 # XFR ORBIT SEMI-MAJOR AXIS
Q1 DEC 0B23 # XFR ORBIT PERILUNE
ESQ EQU Q1

# Page 5
AI DEC 0B23 # PRED. SEMI-MAJOR AXIS
AE EQU AI # CSM PRED. SEMI-MAJOR AXIS
R5X DEC 0B23 # LM PRED POS AHEAD TDEL
R5Y DEC 0
R5Z DEC 0
AL DEC 0B23 # LM PRED. SEMI-MAJOR AXIS
REX DEC 0B23 # CSM EPOCH POSITION
REY DEC 0
REZ DEC 0
RT DEC 0B23 # CSM PRED POS. MAG.
R0X DEC 0B23 # PRED EPOCH POS VECTOR
R0Y DEC 0
# SEE REAR OF LISTING FOR CHECKSUM
# Note that the CHECKSUM pseudo-op is not defined in the AGS
# programmer's manual. I have decided for the purposes of
# implementing yaLEMAT that the following syntax will be
# used. It means that the cross-assembler will compute a
# checksum of the address range 0207-1004 (octal), and will
# store it right here.
CHECKSUM RANGE 0207-1004
R0Z DEFINE 0206
R0 DEC 0B23 # PRED EPOCH POS. MAG.
C11 EQU P # RADAR TEMP. MATRIX
C12 EQU ALPHA
C13 EQU Q1
C14 EQU AI
C21 EQU R5X
C22 EQU R5Y
C23 EQU R5Z
C24 EQU AL
C31 EQU REX
C32 EQU REY
C33 EQU REZ
C34 EQU RT
C41 EQU R0X
C42 EQU R0Y
C43 EQU R0Z
C44 EQU R0
R DEC 0B23 # LM POS MAGNITUDE
Y DEC 0B23 # OUT OF PLANE POSITION
PP DEC 0B23 # P PRIME/EXIT FOR MXM
POUTFS DEC 7.684096E4B23 # MAX P DISPLAYABLE
POUT DEC 0 # DISPLAY POSITION.


# Page 6
DPOUT DEC 0 # DISPLAY POSITION INCREMENT.
2K3 DEC 1048576.B23 # QL SET ON O.F.
2K14 DEC 5.E4B23 # INITIAL P PERTURBATION
RIX DEC 0B23 # ELLIPSE PRED POS OUTPUT
RIY DEC 0
RIZ DEC 0
DELR1 EQU RIX # MEASURED MINUS COMPUTED RANGE
DELR3 EQU RIY # B23
DELR2 EQU RIZ
25J DEC 0B23 # DEDA ALTITUDE UPDATE
7J DEC 6042736B23 # TERM IN AL(O.I.)
8J DEC 2940243B23 # TERM IN AL(O.I) LOWER LIMIT
10J DEC 6046910B23 # RETARGET VALUE FOR 7J
4K5 DEC 5735200B23 # NOMINAL BURNOUT ALTITUDE
2K19 DEC 5.E5B23 # DELTA P LIMITER
5J DEC 5.697785E6B23 # LANDING SITE RADIUS
16J DEC 60000B23 # ORBIT INSERTION ALTITUDE
21J DEC 25000B23 # PITCH STEERING ALT THRESHOLD
RRSX DEC 0B23 # CALCULATED RANGE AT TIME
RRSY DEC 0 # OF RADAR RANGE MEASUREMENT.
RRSZ DEC 0
6K11 DEC 0.318310B0 # 1/PI
#
# INITIALIZE DATA FROM DOWNLINK ADDRESSES
# LOCATIONS 0240-0257 USED
1J1 DEC 0B23 # LM EPHEMERIS POS
1J2 DEC 0
1J3 DEC 0
DEC 0
2J1 DEC 0 # CSM EPHEMERIS POS
2J2 DEC 0
2J3 DEC 0
DEC 0
DEC 0
DEC 0
DEC 0
DEC 0

# Page 7
1J7 DEC 0B18 # LM EPOCH TIME
1J7LS DEC 0B1
DEC 0
DEC 0
THETAR EQU 2J3+4 # RADAR ANTENNA TRUNNION ANGLE
BETAR EQU 2J3+5 # RADAR ANTENNA SHAFT ANGLE
RM EQU 1J7 # RADAR RAW RANGE INPUT
RMDOT EQU 1J7+1 # RADAR RANGE RATE INPUT
DEL46 EQU 1J7+2 # RADAR COMPOSITE WORD
1J4 DEC 0B13 # LM EPHEMERIS VEL
1J5 DEC 0
1J6 DEC 0
VPY DEC 0B13 # OUT-OF-PLANE VELOCITY
2J4 DEC 0 # CSM EPHEMERIS VEL
2J5 DEC 0
2J6 DEC 0
5K18 DEC -.1B-2 # RD3DOT LOWER LIMIT
VY0 DEC 0B13 # LM OUT-OF-PLANE VEL
VY0FS DEC 200B13 # MAX VY0 DISPLAYABLE
2J7 DEC 0 # CSM EPOCH TIME
2J7LS DEC 0
7K1 DEC 30B18 # TIG TIME BIAS
1J DEC 0B18 # NOMINAL TPI TIME (CSI)
6K5 DEC -.73B0 # Y-POSITION FILTER WEIGHT
XI DEC 0B3 # Z-AXIS/LOCAL HORIZ ANGLE
A31BD DEC 0B1 # UNIT VECTOR (LM-CSM)
A32BD DEC 0
A33BD DEC 0
TLOS DEC 0B3 # DXFR LOS COMPUTED
THETAF EQU TLOS # LM-CSM CENTRAL ANG AT CSI/CDH
3K4 DEC .17365B1 # CENTRAL ANGLE LIMIT ON TPI
12J DEC -.299904B3 # PHASE ANGLE LIMIT FOR RETARGET
4J DEC 0B13 # TIME OF NODE PRIOR TO RENDEZ
6J DEC 2580.0B13 # DESIRED TRANSFER TIME
TDEL DEC 0B13 # TIME TIL NEXT MANEUVER
TR DEC 0B13 # TIME TIL RENDEZVOUS
3J DEC 0B13 # TARGET OFFSET TIME

# Page 8
6K12 DEC 9.38B4 # RAW RADAR AT 18 TO FT. AT 22
DELRP DEC 0B23 # DIFF. ALT. AT TIG(CSI-CDH)
QA DEC 0B23 # LM APOFOCUS ALTITUDE
18J DEC 0B22 # MEASURED RADAR RANGE
RR DEC 0B22 # COMPUTED RANGE
READP DEC 0
ENTERP DEC 0
HOLDP DEC 0
CLEARP DEC 0
HMF DEC 0
# START OF TELEMETRY LIST
RMF DEC 0 # READOUT MODE FLAG
DD DEC 0 # DEDA DATA
CMF DEC 0 # CLEAR MODE FLAG
A11T DEC 1.B1 # TM DIR COSINES
A12T DEC 0
A13T DEC 0
ADST DEC 0 # DEDA ADDRESS
A31T DEC 0
A32T DEC 0
A33T DEC 1.B1
H DEC 0B23 # ALTITUDE
RX DEC 0B23 # LM POSITION
RY DEC 0
RZ DEC 0
QL DEC 0B23 # PRESENT LM PERICYNTHION
EONS10 EQU QL # ENG ON+S10 FOR TM
RCX DEC 0B23 # CSM PRESENT POSITION
RCY DEC 0
RCZ DEC 0
RF DEC 0B23 # PREDICTED BURNOUT ALT.
DVX DEC 0B1 # BODY DELTA VS
DVY DEC 0 # THIS CYCLE.
DVZ DEC 0
TA2 DEC 0B1 # ABS TIME LS.
DAX DEC 0B-6 # DELTA ALPHAS
DAY DEC 0

# Page 9
DAZ DEC 0
TBO DEC 0B9 # TIME TO BURNOUT.
VX DEC 0B13 # LM VELOCITY
VY DEC 0
VZ DEC 0
MU8S12 DEC 0 # MU8/S12
VCX DEC 0B13 # CSM PRESENT VELOCITY
VCY DEC 0
VCZ DEC 0
HDOT DEC 0B13 # ALTITUDE RATE
VG DEC 0B13 # VELOCITY TO GAIN
VF DEC 0B13 # TRANSFER BRAKING VELOCITY
TA0 DEC 0B18 # TIME FROM CSI TO CDH
TIG DEC 0B18 # ABSOLUTE TIME OF MANEUVER
A11BD DEC 0B1 # CMD XB POINTING DIR
A12BD DEC 0
A13BD DEC 0
TA1 DEC 0B18 # ABS TIME MS.
S0 DEC 0 # AGS FUNCTION SELECTOR
DISC1C DEC 0 # DISCRETE WD 1-TRUE STATE
Q1DEDA DEC 8388500B23 # TRANS ORBIT PERICYN ALT
DELH EQU Q1DEDA # DIFF. ALT. AFTER CDH(CSI-CDH)
QLTELE DEC 0B23 # QL FOR TELE AND DEDA
VD1X DEC 0B13 # 40MS VEL ACCUMULATION
VD1Y DEC 0
VD1Z DEC 0
# END OF TELEMETRY LIST
DEL6 DEC 0 # CALIBRATE I.C. FLAG
S10 DEC 0 # GUIDANCE MODE SELECTOR
S11 DEC 0 # AUTO RADAR SWITCH
S12 DEC 0 # TEST STATUS
S13 DEC 0 # STORE LUNAR AZIMUTH
S14 DEC 0 # NAVIGATION INITIALIZE
S15 DEC 0 # RADAR GIMBAL NULL
RDOTS EQU S15 # R. R. STORED AT RADAR INPUT
S16 DEC 0 # CDH APSIDAL SELECTION
S17 DEC 0 # RADAR FILTER INIT. SWITCH

# Page 10
VEX DEC 0B13 # CSM EPOCH VEL
VEY DEC 0
VEZ DEC 0
RFDOT DEC 0B13 # DESIRED ALT RATE
V0X DEC 0B13 # PRED EPOCH VEL VECTOR
V0Y DEC 0
V0Z DEC 0
I EQU V0X # MXM INDEX
J EQU V0Y # MXM INDEX
K EQU V0Z # MXM INDEX
VH DEC 0B13 # LM HORIZONTAL VEL
# VIX,VIY,VIZ ARE SHARED WITH RR FILTER
VIX DEC 0B13 # ELLIPSE PRED VEL OUTPUT
VIY DEC 0
VIZ DEC 0
V DEC 0B13 # LM TOTAL VELOCITY
TP DEC 0B13 # TRIAL XFR ORB. TIME.
T DEC 0B13 # TIME TO RENDEZ.
RB EQU T # RF SAVED FOR ORBIT INSERT.
TB DEC 0B13 # TA-TE.
PDOTM1 DEC 0B13 # DISPLAY POS RATE(-1)
RRDOT DEC 0B13 # RANGE RATE
1000D DEC 1000B17 # RANGE MARK COUNTER INCREMENT
TI DEC 0B13 # PREDICTION TIME/RR FILTER TEMP
DPDOUT DEC 0B13 # DISPLAY POS RATE INCREMENT
PDOUT DEC 0B13 # DSP POS RATE CONV TO FPS AT 13
TCSM DEC 0B13 # CSM PERIOD (SEC)
4K25 DEC 3.402B13 # ENG CUTOFF COMP
2K18 DEC 15.B13 # PARTIAL DERIV PROTECTOR.
28J1 DEC 0B13 # DELTA V DOWNRANGE
28J2 DEC 0B13 # DELTA V CROSSRANGE
28J3 DEC 0B13 # DELTA V RADIAL
2K20 DEC 2.B13 # CONVERGENCE CHECK.
4K26 DEC 70.0B13 # VG THRESHOLD
DDF DEC 0 # DEDA DATA RECEIVED FLAG
6K4 DEC .1E3B10 # INITIAL VALUE OF P33 AND P44
6K2 DEC .1E9B30 # INIT VALUE OF P11,P22

# Page 11
V5X DEC 0B13 # TPI-PREDICTED V AT TPI TIME
V5Y DEC 0
V5Z DEC 0
TR4 EQU V5X # NO. OF COL IN MATRIX A
TR6 EQU V5Y # NO. OF ROWS IN MATRIX B
TR5 EQU V5Z # NO. OF ROWS IN MATRIX A
VHA DEC 0B13
22J DEC 50B13 # PITCH STEERING ALT RATE THRESH
23J DEC 19.5B13 # RFDOT LOWER LIMIT
5K26 DEC 15B13 # PSEUDO ATT HOLD IN STEER
PART DEC 0B14 # PARTIAL DERIVATIVE
VDX DEC 0B13 # VD1 AT NAV UPDATE
VDY DEC 0
VDZ DEC 0
4K27 DEC -8000.0B13 # OVERFLOW PROTECTION FOR VD1X
VSMGX DEC 0B13 # VD1 CUTOFF
VSMGY DEC 0
VSMGZ DEC 0
RADOT DEC 0B13 # PRED. RDOT AT TIG
DELVGX DEC 0B13 # THRUST VEL TO GAIN
DELVGY DEC 0
DELVGZ DEC 0
17J DEC 0B13 # RANGE RATE INPUT
RD3DOT DEC 0B-2 # DESIRED RADIAL JERK
YD3DOT DEC 0B-2 # DESIRED OUT-OF-PLANE JERK
4K12 DEC 5B7 # ACCEL THRESH IN O.I. STEER
S507 DEC 0B3 # ACQ STEER SEL OF PT DIR
DAXREM DEC 0B-13 # INCRE. GYRO INPUT REMAINDERS
DAYREM DEC 0
DAZREM DEC 0
C1 DEC 0B1 # RENDEZ ANGLE COSINE.
WBX DEC 0B1 # UNIT VECTOR FOR
WBY DEC 0 # GUIDANCE STEERING
WBZ DEC 0
6K14 DEC -15768B14 # RADAR RANGE RATE NULL
TE1 DEC 0B18 # CSM EPOCH TIME MS.
TL1 DEC 0B18 # LEM EPOCH TIME MS.


# Page 12
6K6 DEC -.001B-8 # Y-VELOCITY FILTER WEIGHT
5K20 DEC 0B-2 # RD3DOT LOWER LIMIT
TE2 DEC 0 # CSM EPOCH TIME LS.
TL2 DEC 0 # LEM EPOCH TIME LS.
2K11 DEC 6000B13 # VF IF OVERFLOW
4K6 DEC 80.B13 # RFDOT UPPER LIMIT
DAXA DEC 0B-6 # ALIGN INCREMENTS
DAYA DEC 0
DAZA DEC 0
DISC1 DEC 0 # DISCRETE WORD
1K18 DEC .003125B-8 # ACCEL SCALE FACTOR
1K20 DEC .003125B-8
1K22 DEC .003125B-8
1K14 DEC 0B-14 # X-AXIS MASS UNBAL COMP
1K19 DEC 0B1 # ACCEL BIAS
1K21 DEC 0B1 # COMPENSATION
1K23 DEC 0B1
DSPSC DEC 0 # DISPLAY SHIFT COUNTER
1K1 DEC 0B-13 # GYRO BIAS
1K6 DEC 0 # COMPENSATIONS
1K11 DEC 0
DDEL DEC 0B0 # LUNAR ALIGN CORRECTION
1K3 DEC 0B-7 # GYRO SCALE FACTOR
1K8 DEC 0 # COMPENSATIONS
1K13 DEC 0
HRF DEC 0 # HIGH RATE FLAG
A31S DEC 0B1 # RADAR NULL DIR COS
A32S DEC 0
A33S DEC 0
4K4 DEC .004B-7 # FACTOR IN RFDOT(OI)
5K14 DEC 0B-2 # RD3DOT UPPER LIMIT
5K16 DEC .01B-2 # YD3DOT UPPER LIMIT
DLWN DEC 0 # DOWNLINK WORD COUNTER
DEL32 DEC 0 # DOWNLINK INITIALIZE FLAG
6K8 DEC .22B10 # RANGE RATE ERROR VARIANCE
# (ADDR OF 6K8 MUST END IN 4)
6K9 DEC .3029E-4B-4 # VARIANCE OF RADAR ANGULAR ERROR

# Page 13
6K10 DEC .625E7B28 # RANGE ERROR VARIANCE
DSPF1 DEC 0 # DISPLAY FLAG1.
ID1F DEC 0 # DOWNLINK ID RECEIVED
DEL31 DEC 0 # DOWNLINK INPUT COMPLETE
FLAGT DEC 0 # MEMORY TEST
FLAG1 DEC 0 # 20MS BRANCH CONTROL
DEL2 OCT 0 # STAGED FLAG.
DEL5 OCT 0 # ATTHLD LOCK FLAG.
PI DEC 3.14159266B3
6K13 DEC -1.59286B1 # RADAR RANGE RATE TO FPS AT 13
DVGXX DEC 0B13 # VEL TO GAIN IN EXT DELTA V
DVGXY DEC 0
DVGXZ DEC 0
DEL20 DEC 0 # LOGIC FLAG FOR ENG CONTROL
DEL21 OCT 0 # LUNAR SURFACE FLAG.
2J DEC 1.9970B7 # COTAN OF DESIRED LOS AT TPI
DEL42 OCT 0 # LUNAR ALINE COMPLETE FLAG
DEL45 EQU DEL42 # RR RANGE/RANGE RT. UPDATE FLAG
K55 OCT 377777 # S.F. FOR HDOT DISPLAY
MU3 DEC 0 # P-ITER COUNTER.
RD3DTL EQU MU3 # RD3DOT LOWER LIMIT
5K17 DEC -.01B-2 # YD3DOT LOWER LIMIT
MU6 DEC 0 # STAGING COUNTER
1K37 DEC 15.B17 # ACCEL CAL DURATION
MU8 DEC 0 # ULLAGE COUNTER
MU10 DEC 0 # GYRO CALIBRATE DURATION
1K9 DEC 5.0B17 # ULLAGE COUNTER LIMIT
1K30 DEC 150.B17 # GYRO CALIBRATE DURATION
2K17 DEC 5.B17 # NO OF P-ITERATIONS-3
MU19 DEC 0 # MARK COUNTER
4K23 DEC 62.0B17 # STAGING TIME DELAY
S623 DEC 0B3 # EX SELECTION IN G. S
1K4 DEC .1B0 # DISPLAY INTERPOLATION
1K24 DEC .87E-3B1 # SINGULARITY THRESHOLD
1K26 DEC -.142857E3B8 # NEG INV OF ALIGN GAIN CONSTANT
1K27 DEC .435E-1B-4 # ALIGN CONSTANT
1K28 DEC 107.78396B7 # ALIGN CONSTANT

# Page 14
1K29 DEC .001B-4 # LUN ALIGN STOP CRITERION
1K33 DEC .08B-3 # CALIBRATE GAIN
1K34 DEC .00002B-15 # CALIBRATE GAIN
1K35 DEC .25B7 # ACCEL BIAS THRESHOLD
1K36 DEC -.66667E-3B0 # ACCEL CAL GAIN
2K1 DEC .173189E15B48 # GRAVITY CONST (LUNAR)
2K2 DEC .57740387E-14B-47 # 1/2K1
6J1 DEC .3358E-8B-14 # LUNAR ROT RATE ABOUT X-REF
6J2 DEC -.53039E-7B-14 # LUNAR ROT RATE ABOUT Y-REF
6J3 DEC .3052E-8B-14 # LUNAR ROT RATE ABOUT Z-REF
B13SF DEC .10416666B0 # .01 MIN TO SEC AT 13
SDVX DEC 0B1 # DV SUM FOR ACCEL CAL
SDVY DEC 0 # (ADDR OF SDVX MUST END IN 4)
SDVZ DEC 0
MU7 DEC 0B17 # CALIBRATION COUNTER
7K2 DEC 2B17 # NOISEIN P-MATRIX DIAGONALS
B13VSF DEC .625B0 # .1 FPS TO FPS AT 13
B3SF DEC .34971155B0 # .01 DEG TO RAD AT 3
B23RSF DEC .10533045B0 # .1 NMI TO FT AT 23
4K2 DEC -.50204E-4B-12 # FACTOR IN TB COMP
4K3 DEC .16803E-8B-25 # FACTOR IN TB COMP
B22RSF DEC .5266522B0 # .01 NMI TO FT AT 22
BACCSF DEC 0.762939B0 # .001 FT/SEC2 TO FPS/20MS AT 1
4K34 DEC 1.B7 # AT LOWER LIMIT
4K35 DEC .1B7 # ULLAGE THRESHOLD
4K10 DEC -317438.91B20 # TERM IN AL(O.I.)
SUMLIM DEC 0 # LAST CELL FOR CHECKSUM
WORDS DEC 28
B18SF DEC .333333B0 # .1 MIN TO SEC AT 18
4K21 DEC .26179938B2 # SC FACTOR FOR ATT ERR OUTPUT
M25B16 DEC -25.B16 # CYCLE COUNT TO SECONDS
DTB DEC 1.25B1 # 1 SEC + DEDA TIME BIAS
ID DEC 0 # CURRENT DOWNLIST ID CODE
DLWNL STO 1J1+15 # END OF DOWNLINK BUFFER
11J DEC -624599.84B20 # RETARGET VALUE FOR 4K10
2K4 DEC -.173189E15B48 # (-2.)(2K1) B49
KDT DEC 1.B1 # DELTA T/2 AT 1

# Page 15
BM13SF DEC .96049535B0 # .01 DEG/HR TO RAD/20MS AT -13
B23SF DEC .64B0 # 100 FT TO FT AT 23
# THE FOLLOWING 16 PARAMETERS HAVE
# VARIABLE SCALING. INITIAL SCALING IS INDICATED.
P11 DEC .1E9B30 # VARIANCE OF X-POS ERROR
P12 DEC 0B30 # COVARIANCE OF X AND Y POS ERROR
P13 DEC 0B20 # COVAR OF X-POS AND X-VEL ERROR
P14 DEC 0B20 # COVAR OF X-POS AND Z-VEL ERROR
P21 DEC 0B30 # COVAR OF X AND Z POS ERROR
P22 DEC .1E9B30 # VARIANCE OF Z-POS ERROR
P23 DEC 0B20 # COVAR OF Z-POS AND X-VEL ERROR
P24 DEC 0B20 # COVAR OF Z-POS AND Z-VEL ERROR
P31 DEC 0B20 # COVAR OF X-POS AND X-VEL ERROR
P32 DEC 0B20 # COVAR OF Z-POS AND X-VEL ERROR
P33 DEC .1E3B10 # VARIANCE OF X-VEL ERROR
P34 DEC 0B10 # COVAR OF X-VEL AND Z-VEL ERROR
P41 DEC 0B20 # COVAR OF X-POS AND Z-VEL ERROR
P42 DEC 0B20 # COVAR OF Z-POS AND Z-VEL ERROR
P43 DEC 0B10 # COVAR OF X-VEL AND Z-VEL ERROR
P44 DEC .1E3B10 # VARIANCE OF Z-VEL ERROR
VRSH STQ SREX2
LRS 0
TRA SREX2
TMID DEC 0 # TELEMETRY ID
SFLO OCT 000026
PMAXP OCT 377777 # COUNTS AT 17
ORBRET TRA DX10P # RETURN FROM NORTON IN O.I.
DEDASC DEC 0 # DEDA SHIFT COUNTER
#
#
EX36P STQ DEL10
# SAVE QUANTITIES FOR LATER USE IN
# T/B COMPUTATIONS
STO V6Z
CLA TS12
STO V6X
CLA TS13

# Page 16
STO V6Y
CLA TI
SUB 4J
TRA DXFR14-2
RREX CLA TS0 # VARIABLE ADDRESS LOAD, MULTIPLY
RREX1 MPY TS0 # AND STORE FOR MATRIX MULTIPLY
DVP 1B3 # ROUTINE (MXM) -- PERFORMS
ADZ TR8 # C(I,J)=C(I,J)+A(K,I)*B(J,K)
RREX2 STO TS0
STO TR8 # C(I,J)=C(I,J)+A(K,I)*B(J,K)
CLA RREX
ADD TR4 # INCREMENT CLA
STO RREX
CLA RREX1
ADD 1B17 # INCREMENTY MPY
STO RREX1
AXT 2,1 # INCREMENT AND TEST INDEXES
CLA I,1
ADD 1B17
STO I,1
SUB TR4,1
TMI R1+1
TIX *-5,1
CLA TR6 # REARRANGE DIMENSIONS AND
STO TR4 # ADDRESSES ON EXIT TO SAVE
CLA TR3 # STEPS IN FILTER
STO TR1
AXT 7,1
TRA PP # EXIT MXM
DIAK1 OCT 377363 # TEST FOR DEDA ENTRY INTO 415
DIAK2 OCT 377401 # TEST FOR DEDA ENTRY INTO 377
6K8S DEC .22B10 # WORKING VALUE OF 6K8
# (ADDR OF 6K8S MUST END IN 4)
6K9S DEC .3029E-4B-4 # WORKING VALUE OF 6K9
6K10S DEC .625E7B28 # WORKING VALUE OF 6K10
6K6S DEC 0 # WORKING VALUE OF 6K6
#

# Page 17
#
ORG 1000
CLADD DEC 0 # PICKUP DEDA DATA
TRA ROR
RND STQ SREX # DIRECTION COSINE ROUND
ADD 1B9
LRS 9
TRA SREX
TMCLA CLA 0324 # CLA FOR TELEM
TCLTH CLA 1005
DLSTO STO 1J1-1
IC1BR TRA IC1 # IC1 TRA.
BR1 TRA NAV1P
DEDABR TRA DEDAE # DEDA BRANCH TRA.
BR50 TRA EXEC2 # BRANCH 50 TRA.
#
# HARDWIRE ESCAPE POINTS
#
EXIT1 TRA EX1+1
EXIT2 TRA UBCOMP
EXIT3 TRA ADDMS
EXIT4 TRA EX4+1
EXIT5 TRA PGNSDE
EXIT6 TRA TME
EXIT7 TRA PGNSD1+5
EXIT8 TRA EX8+1
EXIT9 TRA TVTG
EXIT10 TSQ SOFT1
EXIT11 TSQ SOFT1 # ASCENT ENG ON
EXIT12 TRA AHE1
EXIT13 TRA EROUT+1
EXIT14 TSQ SOFT2
EXIT15 TRA LUNAL1 # GAIN CHANGE
EXIT16 TRA EX16+1
EXIT17 TRA FDAI1
EXIT18 TRA NOC
EXIT19 TRA DELAY


# Page 18
EXIT20 TRA DLDC
EXIT21 TRA TIMEA
EXIT22 TRA IDLE-1
O25C OCT 377747 # TEST FOR TM RESET
EXIT23 CLZ VD1X
CLZ VD1Y
CLZ VD1Z
TRA NAV3
EXIT24 TRA NAV2
EXIT25 TRA NAV3
SINITC CLA 4K27
STO VD1X
STO VDX
TRA EXEC1+7
EXIT26 TRA XDVS
EXIT27 TRA EX27+1
EXIT28 TRA EX28+1
STGCTR CLZ MU6 # STAGING DELAY COUNTER
ADD 1B17
STO MU6
TRA AHE
EXIT29 TRA EX29+1
CLATAB CLA SFTAB-1 # CLA FOR DEDA SF TABLE
EXIT30 TRA EX30+1
EXIT31 TRA ALTUP
EXIT32 TRA LMORB2
EXIT33 TRA EX33P
EXIT34 TRA EX34P
EXIT35 TRA EX35
EXIT36 TSQ EX36P
EXIT37 TRA EX35+1
EXIT38 TRA Q5
EXIT39 TRA EXECM
EXIT40 CLZ S0 # SOFT INITIALIZE
CLZ DEL5
CLZ FLAGT
AXT 7,1 # ZERO S SWITCHES

# Page 19
CLZ S10,1
TIX *-1,1
TRA SINITC # CONTINUE INITIALIZE
EXIT41 TRA DSP1
EXIT42 TRA DSP2CP
EXIT43 ADD O25C # CHECK FOR TM RESET
ABS
TMI TMIE1 # -- RESET TM AT 25 CYCLE
TRA EXEC1+4 # NOT 25TH CYCLE
IDAI OCT 077776 # AGS INITIALIZE DOWNLIST ID
IDRP OCT 077775 # REND./PRETHRUST DOWNLIST ID
EXIT44 TRA EX44+1
EXIT45 TRA EX45+1
EXIT46 TRA EX46+1
EXIT47 TRA DEXIT
EXIT48 TRA CLEARM+1
EXIT49 TRA SFTEST
EXIT50 TRA EX50+1
EXIT51 TSQ DIAT
EXIT52 TRA EXEC+1
EXIT53 TRA EXEC+1
DLWNLC STO 1J1+15 # DLWNL PROTECTION
ADDMS AXT 2,1
CLA TS10,1
ABS
ADD MS
TIX *-3,1
TRA EX3+1
EX34P CLZ DEL10
TMI EX33PP+1
TRA EX34+1
THEF CLA RF
LRS 1 # B24
ADZ TS3
LDQ TS4
STO TS4 # =RF+RX B24
STQ TS3 # =RZ B24

# Page 20
TSQ ARCTAE
STO TS0 # THETAF B8
SUB PI
TMI *+2
SUB 2PIB3
ADD PI
STO THETAF # THETAF B3
CLA TS0 # B3
SUB 2PIB3
MPY M1B1 # B4
DVP NI
ADD TI # B13
TRA DXFR14-2
TMIE1 TSQ TMIE2 # INITIALIZE TELEMETRY
CLA S12
ADD MU8
STO MU8S12 # SAVE MU8/S12 FOR TM
SUB 3B3 # TEST FOR SELF TEST FAILURE
TMI *+2
OUT 6410 # SET FAILURE INDICATOR
TRA DELAY # END MAJOR CYCLE
#
# DEDA SCALE FACTOR LOCATOR TABLE
# SCALE FACTORS MUST REMAIN AT LOCS IN COMMENTS
# FORMAT OF TABLE IS, BIT 0=1 TABLE EXCEEDED,
# BITS 1-9 LAST ADDRESS OF DEDA SCALE FACTOR REGION
# BIT 10=1 FOR OCTAL REGION, BITS 11-17 ADDRESS OF
# SCALE FACTOR RELATIVE TO LOCATION 636
SFTAB OCT 075200 # OCT LOC 026-172,OCT
OCT 125441 # OCT LOC 173-253,DEC,SF AT 677
OCT 127427 # OCT LOC 254-257,DEC,SF AT 665
OCT 134413 # OCT LOC 260-271,DEC,SF AT 651
OCT 137027 # OCT LOC 272-276,DEC,SF AT 665
OCT 142414 # OCT LOC 277-305,DEC,SF AT 652
OCT 145405 # OCT LOC 306-313,DEC,SF AT 643
OCT 146415 # OCT LOC 314-315,DEC,SF AT 653
OCT 147420 # OCT LOC 316-317,DEC,SF AT 656

# Page 21
OCT 157415 # OCT LOC 320-337,DEC,SF AT 653
OCT 164441 # OCT LOC 340-351,DEC,SF AT 677
OCT 174413 # OCT LOC 352-371,DEC,SF AT 651
OCT 177427 # OCT LOC 372-377,DEC,SF AT 665
OCT 200600 # OCT LOC 400-401,OCT
OCT 202415 # OCT LOC 402-405,DEC,SF AT 653
OCT 207600 # OCT LOC 406-417,OCT
OCT 241413 # OCT LOC 420-503,DEC,SF AT 651
OCT 257600 # OCT LOC 504-537,OCT
OCT 261421 # OCT LOC 540-543,DEC,SF AT 657
OCT 263040 # OCT LOC 544-546,DEC,SF AT 676
OCT 305600 # OCT LOC 547-613,OCT
OCT 311067 # OCT LOC 614-622,DEC,SF AT 725
OCT 342200 # OCT LOC 623-704,OCT
# THE ABOVE 23-PLACE TABLE MUST BE FOLLOWED
# BY A WORD WITH BIT 0 SET
#
# ORBIT ALIGN COMPUTATIONS
#
ORBLIN AXT 6,1
CLZ A11,1
CLZ DA11,1 # ZERO REMAINDERS
TIX *-2,1
CLA 1B1
STO A11
STO A33
TRA COA21-2
#
# MASS UNBALANCE COMPENSATION
#
UBCOMP MPR 1K14 # (DVX)(1K14) 1+(-14)=-13
ADZ DAXREM
STO DAXREM
#
# 20MS MODE CHECK.
#
MODCK CLA S0 # CHECK FOR ALIGNMENT

# Page 22
SUB 3B3 # SUBMODES
TMI GYCOM-2 # -- IS INERT REF
SUB 1B3
TMI ZNOC # IMU ALIGN
SUB 1B3
TMI GYCOM-2 # -- IS LUNAR ALIGN
SUB 1B3
TMI ORBLIN # ORBIT ALIGN
AXT 2,1 # CALIBRATE MODE
CALIB1 CLA DEL21
TMI *+5 # -- LM IS ON LUNAR SURFACE
CLZ SDVX,1 # SUM BODY AXIS VEL
ADD DVX,1 # INCREMENTS SINCE START OF ACC.
STO SDVX,1 # BIAS CALCULATIONS
TRA CALIB2
CLA A11,1 # LUNAR CAL., COMPENSATE COMP.
MPR 6J1,1 # OF VEH ROT. FOR LUNAR ROTATION
ADZ DAXREM # 1+(-14)=-13
STO DAXREM # A11 DOT 6J1
CLA A21,1
MPR 6J1,1
ADZ DAYREM
STO DAYREM # A21 DOT 6J1
CLA A31,1
MPR 6J1,1
ADZ DAZREM
STO DAZREM # A31 DOT 6J1
CALIB2 TIX CALIB1,1
TRA GYCOM-2
#
# DEDA MODE SELECTION
#
DEDAE CLZ CLEARP
TMI CLEARM # SET CLEAR
CLA CMF
TMI RPT # CLEAR MODE
CLA RMF

# Page 23
TMI HET # READOUT IN PROGRESS
CLA HMF
TMI RRT # HOLD IN PROGRESS
DEXIT AXT 3,1 # NORMAL EXIT
TRA *+4
CLEARM STO CMF
INP DEDA
AXT 5,1 # CLEAR EXIT
CLZ READP,1 # RESET FLAGS
TIX *-1,1
CLZ TMPBR # SET BRANCH FOR NEXT
STO BRANCH # GUIDANCE CYCLE
CLA 1B11 # INITIALIZE COUNTER
STO DEDASC
TRA DSP1 # TO DISPLAY
RPT CLZ READP # TEST FOR
TMI RME # READOUT MODE
CLZ ENTERP # OR ENTER MODE
TMI RME+1 # ENTRY.
TRA DEXIT # EXIT
HET CLZ HOLDP # READOUT TEST FOR
TMI *+2 # HOLD COMMANDED
TRA ADOUT # TO OUTPUT ROUTINE
STO HMF # SET HOLD MODE
CLZ RMF
TRA DEXIT
#
# DEDA SCALE FACTOR SELECTION
#
SFTEST SUB SFLO
TMI CLEARM+1 # -- IF OCT LOC BELOW 0026
CLA CLATAB # INITIALIZE FIRST TABLE VALUE
STO VRSH+1 # STORE CLA INSTRUCTION
CLA VRSH+1 # INCREMENT CLA INSTRUCTION
ADD 1B17 # ADDRESS
STO VRSH+1
TSQ VRSH

# Page 24
TMI CLEARM+1 # -- IF OCT LOC ABOVE 704
LRS 8 # EXAMINE BITS 1-9 OF VALUE
SUB ADST # -- IF OCT LOC ABOVE VALUE,
TMI *-7 # CHECK NEXT VALUE IN TABLE
LLS 18 # RECOVER BITS 10-17 OF THIS VAL
TMI NOTDD # -- IF OCT REGION, NO SF REQ
LRS 10 # SCALE BITS 11-17 OF VAL
ADD TBRAKE # CONSTRUCT INSTRUCTION TO OBTAIN
STO VRSH+1 # SCALE FACTOR FOR THIS REGION
TSQ VRSH # OBTAIN SF FOR THIS REGION
STO SF # SET SCALE FACTOR
TRA DDIN # TO INPUT ROUTINE
DIAT AXT 1,1 # IMMEDIATE ACTION TEST
CLA ADST # IMMED. ACTION IF
ADD DIAK1,1 # ACCUMULATOR = 400000
ABS
TMI *+4
TIX DIAT+1,1
STQ DDF
TRA DEXIT
TIX ATI,1
LDQ *-2 # SET RETURN TO DEXIT
AXT 2,1
CLA RRX,1 # SAVE RANGE FOR FILTER
STO RRSX,1
CLA A31,1 # STORE DIRECTION COSINES
STO A31S,1
TIX *-4,1
CLA RRDOT
STO RDOTS
TRA EXIT
#
# DOWNLINK FORMATTING
#
DLDC AXT 2,1
CLZ 0244,1 # LEM VEL
STO 1J4,1

# Page 25
CLZ 0250,1 # CSM POS
STO 2J1,1
CLZ 0254,1 # CSM VEL
STO 2J4,1
TIX DLDC+1,1
CLZ 0247
LRS 14
ADZ 0243
STO 1J7
STQ 1J7LS
STO 2J7
STQ 2J7LS
TSQ CSMPV
TRA IC1+3
#
# DELTA V ACCUMULATION AND THRUST VEL TO GAIN.
#
TVTG AXT 2,1
CLA DVX,1 # 1
LRS 1 # TO 2
ADZ VD2X,1
STO VD2X,1
CLA DVXM1,1
LRS 1 # TO 2
ADZ VD2X,1
STO VD2X,1
LRS 11 # TO 13
STO TS1
ALS 11
COM
ADZ VD2X,1
STO VD2X,1 # REMAINDER AT 2
CLA VD1X,1 # DV EXPENDED MS.
ADZ TS1
STO VD1X,1 # VD1 AT 13
COM
ADD VSMGX,1 # VSMG-VD1

# Page 26
STO DELVGX,1 # THRUST VEL TO GAIN
CLZ EX,1
TIX TVTG+1,1
TRA EX9+1
#
# SOFT 40MS COMPUTATIONS
#
SOFT1 CLA S0 # TEST MODE
SUB 3B3
STO TS1 # SAVE
TMI IR # -- IS INTERT. REF.
ZERR CLA ZERO
OUT 6007 # ZERO ATTITUDE ERRORS
CLZ DEL5 # RESET ATT HOLD INIT FLAG
CLZ TS1
TMI ENCOM1 # -- IS INERTIAL REF
SUB 1B3
TMI SOFT3
SUB 1B3
TMI LUNAL
SOFT3 OUT 7040 # RESET ENG ON
OUT 6420 # SET ENG OFF
CLA ZERO # SET ENG TM FLAG PLUS
ADD S10
STO EONS10
TRA FDAI # TO ATTITUDE DISPLAY
ENCOM1 CLA DISC1 # FOLLUP ENG. COMMANDS
LLS 5
TMI *+4 # -- DESCENT ENG ON
LLS 1
TMI *+2 # -- ASCENT ENG ON
TRA SOFT3 # ENG OFF
OUT 7020 # RESET ENG OFF
OUT 6440 # SET ENG ON
CLA MS # SET ENG TM FLAG NG
TRA SOFT3+3
IR CLA S11 # TEST FOR AUTO RADAR DATA


# Page 27
ALS 3
TMI RADCK
STO DEL44 # SET/RESET CODE WORD FLAG
IR4 CLA DISC1
ALS 3
TMI IR1 # -- IS FOLLOWUP
ALS 1
TMI IR2 # -- IS AUTOMATIC
STQ DEL20
TRA AHE # TO ATT HOLD
IR1 CLA DISC1C
ALS 4
TMI ZERR # PLUS IS AUTOMATIC
CLZ DEL5
STQ DEL20
TRA MODE
RSTE CLA S623
ALS 3
TMI *+3
CLA WCX,1
TRA *+2
CLA WBX,1
MPR A31,1
COM
ADZ EX
STO EX
TIX RSTE,1
RST1 TRA RST
IR2 ALS 4
TMI IR3 # -- IS ABORT STAGE
CLA DEL21 # IF ON LUNAR SURFACE
TMI ZERR # OUTPUT ZERO ATT ERRORS
CLA DISC1
ALS 7
TMI MODE # -- IS ABORT
TSQ IR1+4
IR3 CLA DEL21

# Page 28
TMI AHE
CLA DISC1C
ALS 6
TMI MODE
CLA MU6
SUB 4K23
TMI STGCTR # STAGING ATT HOLD
MODE CLA S0 # TEST STEERING MODE
SUB 1B3
TMI AHE # ATT HOLD
AXT 2,1
SUB 1B3
TMI RSTE # RENDEZVOUS STEERING
CLZ DEL5 # ACQUISITION STEERING
MODE1 CLA WCX,1
MPR A11,1
ADZ EZ
STO EZ
CLA S507 # ORIENT LM Z-BODY ASIX
SUB 1B3 # IN DESIRED THRUST DIR.
TMI *+3 # OR ESTIMATED CSM DIR.
CLA A11BD,1
STO A31BD,1
CLA A31BD,1
MPR A11,1 # XB
ADZ EY
STO EY
CLA A31BD,1 # ZBD
MPR A21,1 # YB
COM
ADZ EX
STO EX
TIX MODE1,1
TRA EROUT
SOFT2 CLZ DEL20 # FIRST TIME FOLLOW
TMI ENCOM1 # PREVIOUS ENGINE STATE
CLA S0 # IF NOT GUIDANCE STEERING

# Page 29
ALS 3 # TURN ENGINE OFF
TMI *+2
TRA SOFT3
CLA MU8 # TEST FOR ULLAGE
SUB 1K9
TMI SOFT3
CLA 4K25 # TEST CEL TO BE
SUB DELVGX # GAINED GREATER THAN
TMI ENCOM1+6 # SHUTDOWN THRESHOLD
CLA 4K26
SUB VG
TMI ENCOM1+6
CLZ S0 # SET ATT HOLD
TRA SOFT3
RADCK STQ DEL32 # REINITIALIZE DOWNLINK
CLA IDRP # SET DOWNLIST ID TO REND/PRETHRJ
STO ID
CLA DEL46 # IS CODE WORD RESET
ALS 1
ABS
TMI IR+3
ADD 1B12 # IS CODE WORD SET
ABS
TMI *+2 # YES IF NEGATIVE
TRA IR4
CLZ DEL44 # HAS CODE WORD BEEN RESET
TMI *+2 # PRIOR TO BEING SET
TRA IR4 # NO
TOV *+1
AXT 1,1 # IF SHAFT OR TRUNNION
CLA THETAR,1 # ANGLE IS GREATER
ALS 4 # THAN 11.2 DEG, THEN
TOV IR4 # DO NOT PROCESS
TIX *-3,1
CLZ DEL45 # ALTERNATE RANGE, RATE
TMI IR6
STQ DEL45

# Page 30
CLZ RM # RANGE ENTRY
LRS 18
CLZ DEL46 # TEST FOR HIGH SCALING
TMI *+2
LRS 3 # LOW SCALE
LLS 17
MPR 6K12 # COUNTS TO FEET AT 22
STO 18J
TRA *+5
IR6 CLZ RMDOT # RANGE RATE ENTRY
SUB 6K14 # NULL AT 17000
DVP 6K13 # COUNTS TO FT/SEC AT B13
STO 17J
TSQ DIAT+10 # SAVE REL RNG VECT, REL VEL
AXT 2,1
IR5 CLA A21,1 # B1, ADJUST Z BODY FOR SHAFT
MPR THETAR # B1+B0=B1, AND TRUNNION ANGLES
DVP 6K11 # B1-B0=B1
STO A31S,1 # B1
CLA A11,1 # B1
MPR BETAR # B1+B0=B1
DVP 6K11 # B1-B0=B1
SUZ A31S,1 # B1
ADD A31,1
STO TS14,1 # XB*BETAR/6K11-YB*THETAR/6K11+ZB
TIX IR5,1
TSQ NORMV
AXT 2,1
CLZ TS10,1 # MOVE NORMALIZED DIRECTION
STO A31S,1 # INTO ZB*
TIX *-2,1
TRA 4711 # EXIT TO DEDA DISCRETE SAMPLING
LUNAL1 CLZ DAYA # CHANGE GAIN
LRS 2 # 1/4
STO DAYA
CLZ DAZA
LRS 2

# Page 31
STO DAZA
TRA SOFT3
#
# START OF NAVIGATION
#
NAV1P CLA DEL21
TMI NAV1 # -- IS ON LUNAR SURFACE
CLA VD1X # COMPUTE THRUST ACCEL
SUB VDX # 13
ALS 5 # 1/2(VD1-VD) AT 7
TRA 5166 # TO HARD NAV
XDVS AXT 2,1
CLA DVSX,1
ADD 1B12
LRS 6
ADZ DQSX,1
STO DQSX,1
CLA VD1X,1
STO VDX,1
TIX XDVS+1,1
TRA NAV4
ALTUP TSQ EXEC
#
AXT 2,1
CLA REX,1 # SAVE REX FROM FILTER
STO VIX,1 # SCRATCH MATRIX C AREA
CLA 25J # ALTITUDE ENTRY TEST
SUB 1B17
TMI FLTR # IF NO 25J ENTRY
CLA 25J
ADD 5J
STO R # R=5J+25J
MPY U1X,1
LLS 1
STO RX,1 # NEW R COMPONENTS
#
# RANGE AND RANGE RATE COMPUTATIONS

# Page 32
#
FLTR CLA RCX,1 # RELATIVE RANGE
SUB RX,1
STO RRX,1
STO TS4,1
TIX ALTUP+2,1
CLZ 25J
TSQ DPVMAG # DP COMP OF RR MAG
ALS 1
STO RR # B22 RANGE VECTOR MAG
CLA 2K1 # 48
LRS 5 # 53
DVP R # 30
DVP R # 7
DVP R # -16
DAD STO D11 # 2K1/R**3 B-16
AXT 7,1
CLZ C11,1 # ZERO PHI,M
CLZ C31,1
TIX *-2,1
CLZ RRDOT # ZEROED FOR SUM
AXT 2,1
FLTRA CLA RRX,1
DVP RR
STO A31BD,1 # B1 UNIT POINTING VECTOR
CLA VCX,1 # B13
SUB VX,1
STO TS4,1 # B13 RANGE RATE CSM-LM
MPR A31BD,1
ALS 1
ADZ RRDOT
STO RRDOT
CLA U1X,1
MPR U1X,1 # B2
MPR 3B3
SUB 1B5
MPR D11

# Page 33
STO C31,1 # ADT,JDT AT B-7
CLA 4B17
STO TR4,1 # SET UP DIMENSION FOR MXM
TIX FLTRA,1
LDQ 1B3 # COMMON SETUP OF PHI AND M
STQ C11