https://github.com/virtualagc/virtualagc
Tip revision: b8b57e269c64f67bb4bbd1539da9c1d863077741 authored by Mike Stewart on 07 August 2021, 22:47:38 UTC
yaAGCb1: Updated change notes for executeOneInstruction
yaAGCb1: Updated change notes for executeOneInstruction
Tip revision: b8b57e2
Sample-AldenMinnick.obc
# The contents of this file have been placed into the Public Domain and may
# be reused in any way whatever.
#
# Filename: Sample-AldenMinnick.obc
# Purpose: This is sample Gemini OBC code, written by
# original OBC programmer Alden Minnick in 2011 "in
# "the style of the original code", for the use of
# the Gemini subset of the Virtual AGC project. It
# is intendend to partially fill the gap created by
# the situation that although we have documentation
# of the OBC instruction set, architecture,
# peripherals, etc., that (at least in 2011) there
# is no known surviving OBC source code contemporary
# to the Gemini Project. also, it serves as test
# code for the Virtual AGC project's recreation of
# the Gemini OBC assembler, yaASM.
# Website: http://www.ibiblo.org/apollo/Gemini.html
# Mod history: 2011-09-28 AWM Alden's code created, and edited
# subsequently by Gene Mertz.
# 2011-12-13 RSB Adapted for use with yaASM and
# added to Virtual AGC code base.
#
# Below this point, all comments are Alden's except where explicitly
# noted with notations like [RSB: this is an editor's comment].
# Variables. [RSB: These are declared simply by having a label (referred
# to by OBC programmers as "left-hand symbols", presumably because
# they go to the left of instruction opcodes, if any).]
ALPHA
DTHETAP
DTHETABP
E
EPSILON
G
LC2W
LC2X
LCB1
LCB2
LCM1
LCM1B
LCM4
LCN1B
MA
MP
NU
OMEGAP
OMEGAP1
P
R
RDOT
S
SINEOFE
SINOFMA
SINOFMP
TAUC
TC
TDOTC
TE
TER
TEMP1
TEMP2
TEMP3
TEMP4
THETA1
THETABP
THETAP
THETAP1
TI
TO
TRS
V
X
XC
XDOT
XDOTC
XDOTER
XER
Y
YC
YDOT
YDOTC
YDOTER
YER
Z
ZC
ZDOT
ZDOTC
ZDOTER
ZER
# CONSTANTS
K2 DEC 2
K3X10M5 DEC 0.000003
K5K DEC 5000
KG DEC 32.174
KM1 DEC -1
KP1 DEC +1
KPI DEC 3.1415926536
KSM OCT 200000000
# GEMINI CODE – THIS ENTERY POINT STARTS AT RZ124, FOR THIS EXAMPLE, TAKEN FROM SYSTEM
# MATHFLOW DIAGRAM MODULE III CATCH-UP AND RENDEZVOUS SHEET6
# This code was written by Alden Minnick, original OBC programmer, on 09/28/2011
HOP I/O
RZ601 CLA LCM1
TMI RZ603
TNZ RZ604
RZ602 CLA KP1
STO LCB1
STO LCB2
TRA RZ126 # GOTO RZ FLOW (SHEET 1 MODULE III)
RZ604 CLA LCB2
TMI RZ619
RZ647 CLA KP1
STO LCM1B # = +1
STO LCB1 # = +1
CLA KM1
STO LCB2 # = -1
TRA RZ605
RZ603 CLA LCB1
TMI RZ619
RZ645 CLA KM1
STO LCM1B # = -1
STO LCB1 # = -1
CLA KP1
STO LCB2 # = +1
RZ605 CLA LCM4
TMI RZ608
RZ607 CLA X # SET UP FROM DCS TABLE (EO)
STO XC
CLA Y
STO YC
CLA Z
STO ZC
CLA XDOT
STO XDOTC
CAL YDOT
STO YDOTC
CLA ZDOT
STO ZDOTC
CLA TE
STO TC # ELAPSED TIME STATE VECTOR
TRA RZ610
RZ608 CLA XER # SET UP FROM MODULE OR MODE VI TABLE (EOS)
STO XC
CLA YER
STO YC
CLA ZER
STO ZC
CLA XDOTER
STO XDOTC
CLA YDOTER
STO YDOTC
CLA ZDOTER
STO ZDOTC
CLA TR
STO TC # ELAPSED TIME
RZ610 CLA XDOTC
STO TEMP1
MPY TEMP1
CLA YDOTC
SPQ TEMP2 # XDOTC SQUARED IN TEMP2
STO TEMP1
MPY TEMP1
CLA ZDOTC
SPQ TEMP1 # YDOTC SQUARED IN TEMP1
CLA TEMP1
ADD TEMP2
STO TEMP1 # XDOTC SQUARED + YDOTC SQUARED IN TEMP1
STO TEMP2
MPY ZDOTC
CLA TEMP2
SPQ TEMP1 # YDOTC SQUARED IN TEMP1
ADD TEMP2 # ZDOTC SQUARED + YDOTC SQUARED + ZDOTC SQUARED IS IN THE ACCUMULATOR
CLA RZ610P1
HOP SQROOT
RZ610P1 STO V
CLA XC
MPY XC
CLA YC
SPQ TEMP1
MPY YC
CLA ZC
SPQ TEMP2
MPY ZC
CLA TEMP1
SPQ TEMP1
ADD TEMP2
ADD TEMP1
CLA RZ610P2
HOP SQROOT
RX610P2 STO R
CLA XC
MPY YDOTC
CLA YC
SPQ TEMP1
MPY XDOTC
CLA TEMP1
SPQ TEMP2
RSU TEMP2
MPY TEMP2
CLA XC # START SECOND FACTOR
SPQ TEMP1 # FIRST FACTOR SQUARED
MPY ZDOTC
CLA ZC
SPQ TEMP2
MPY XDOTC
CLA TEMP2
SPQ TEMP2
RSU TEMP2
CLA YC # START THIRD FACTOR
SPQ TEMP2 # SECOND FACTOR SQUARED
MPY ZDOTC
CLA ZC
SPQ TEMP3
MPY YDOTC
CLA TEMP3
SPQ TEMP3
RSU TEMP3
MPY TEMP3
CLA TEMP1
SPQ TEMP3
ADD TEMP2
ADD TEMP3
STO TEMP1
CLA KP1
DIV G
CLA TEMP1
NOP
NOP
NOP
SPQ TEMP2
MPY TEMP1
CLA XC # START FOURTH EQUATION
STO P # EQUATION THREE COMPLETE
MPY XDOTC
CLA YC
SPQ TEMP1
MPY YDOTC
CLA ZC
SPQ TEMP2
MPY ZDOTC
CLA TEMP1
SPQ TEMP1
ADD TEMP2
ADD TEMP1
CLA RZ610P3
HOP SQROOT
RZ610P3 STO RDOT
RZ611 CLA V
DIV KPI
NOP # THESE NOP INSTRUCTIONS ARE NOT EFFICIENT, BUT
NOP # THE EQUATIONS DO NOT ALLOW ANOTHER CHOICE
NOP
SPQ TEMP1
CLA TEMP1
MPY TEMP1
CLA K2
SPQ TEMP1
DIV R
CLA TEMP1
NOP
NOP
SPQ TEMP2
RSU TEMP2
STO TEMP1
CLA KM1
DIV TEMP1
NOP
NOP
NOP
SPQ ALPHA
CLA KG
CLA RZ611P1
HOP SQROOT
RZ611P1 STO TEMP1 # SQUARE ROOT OF G
CLA RZ611P2
CLA ALPHA
HOP SQROOT
RZ611P2 DIV TEMP1 # SQUARE ROOT OF ALPHA IS IN THE ACCUMULATOR
NOP
NOP
NOP
SPQ NU
CLA ALPHA
DIV P
CLA KP1
NOP
NOP
SPQ TEMP1
ADD TEMP1
CLA RZ611P3
HOP SQROOT
RZ611P3 STO EPSILON
CLA KPI
SHL 1
STO TEMP1
DIV NU
NOP
NOP
NOP
SPQ TAUC
RZ612 CLA EPSILON
SUB K3X10M5
TMI RZ619
RZ613 CLA RDOT
TMI RZ614
RZ615 CLA KP1
STO S
TRA RZ616
RZ614 CLA KM1
STO S
RZ616 CLA ALPHA
MPY EPSILON
CLA R
SPQ TEMP1 # ALPHA * EPSILON
RSU ALPHA
STO TEMP2 #ALPHA – R
CLA TEMP1
DIV TEMP2
NOP
NOP
NOP
SPQ TEMP2 # ALPHA – R/ALPHA * EPSILON
MPY TEMP3 # ALPHA – R/ALPHA * EPSILON SQUARED
CLA KP1
SPQ TEMP1
RSU TEMP3
CLA S
MPY TEMP3
CLA RZ616P1
SPQ TEMP4
HOP SQROOT
RZ616P1 STO TEMP4
CLA T3MP3
DIV TEMP2
CLA RZ616P2
NOP
NOP
SPQ TEMP1
HOP ARCTAN
RZ616P2 STO E
CLA RZ617
HOP SIN
RZ617 STO SINEOFE
RZ618 CLA NU
DIV E
NOP
NOP
NOP
SPQ TEMP1
DIV EPSILON
NOP
NOP
NOP
SPQ TEMP2
MPY SIINOFE
CLA TC
SPQ TEMP2
ADD TEMP2
SUB TEMP1
STO TO
RZ619 CLA TAUC
SUB K5K
TMI RZ126
RZ620 CLA KSM # SIGN BIT IS TO BE SET TO MINUS IN THE ACCUMULATOR
STO LC2W # TRS DATA IS TO GO TO THE OBC FROM TRS HARDWARE
# UNIT BECAUSE THE SIGN BIT HAS BEEN SET TO MINUS
STO LC2X # TE (ELAPSED TIME) GOES TO THE OBC FROM THE TRS # HW UNIT BECAUSE THE SIGN BIT IS SET TO MINUS
CLA RZ621
HOP TRS #GO TO TRS SUBROUTINE TO PROCESS TE DATA
RZ621 STO TE
CLA TO
SUB TE
TMI RZ623
RZ622 CLA TO
SUB TAUC
STO TO
TRA RZ621
RZ623 CLA TO
SUB TAUC
TMI RZ625
RZ624 CLA TO
SUB TAUC
STO TO
TRA RZ623
RZ625 TMI RZ628
RZ626 CLA TE
STO TI
CLA KM1
STO LCM1B
HOP I/O
RZ628 CLA EPSILON
SUB K3X10M5
TMI RZ629
RZ630 CLA T1
SUB TO
MPY NU
NOP
SPQ MA
TMI RZ631
RZ631 CLA KPI
MPY K2
CLA MA
SPQ EMP1
ADD TEMP1
STO MA
TRA RZ609
TMI RZ631
RZ632 CLA RZ632P1
HOP SINE
RZ632P1 STO SINOFMA
CLA EPSILON
SHL 1
MPY SINOFMA
ADD MA
SPQ THETA1
CLA TE
SUB TO
MPY NU
NOP
SPQ MP
RZ633 CLA MP
CLA RZ633P1
HOP SIN
RZ63P1 STO SINOFMP
CLA MP
ADD K2
ADD SINOFMP
STO THETAP
RZ634 CLA THETA1
ADD THETAP
STO THETAP1
TRA RZ635
RZ629 CLA TE
SUB T1
MPY NU
NOP
SPQ THETAP1
RZ635 CLA TE
SUB T1
MPY OMEGAP
CLA OMEGAP1
SPQ TEMP1
RSU TEMP1
STO DTHETABP
RZ636 SUB KPI
TMI RZ638
RZ637 CLA KPI
SHL 1
RSU DTHETAP
STO DTHETABP
TRA RZ636
RZ638 CLA DTHETABP
ADD KPI
TMI RZ639
TRA RZ640
RZ639 CLA KPI
SHL 1
ADD DTHETABP
STO DTHETABP
TRA RZ638
RZ640 CLA THETAB
SUB DTHETABP
STO THETAB
RZ641 TMI RZ642
TRA RZ643
RZ642 CLA KPI
SHL 1
STO THETAB
TRA RZ641
RZ643 CLA KPI
SHL 1
RSU THETAB
TRA RZ644
TMI CURZ1 # TO THE NEXT SHEET OF CODE (SHEET 7 OF MODULE # III)
RZ644 CLA KPI
SHL 1
STO THETAB
RSU THETAB
TRA RZ729