Source Code

These source code files are a reconstruction of Sundance, the Apollo 9 LM (Lunar Module) AGC (Apollo Guidance Computer) flight software, created from binary dumps of original core rope program modules, as follows:
  • B1 — Revision 292
  • B2 — Revision 302
  • B3 — Revision 302
  • B4 — Revision 302
  • B5 — Revision 292
  • B6 — Revision 306
This means that source code does not represent a specific historical revision of Sundance, but rather a mixture of the three released versions. Nonetheless, it is capable of flying the whole Apollo 9 mission. This source code matches the binary dumps, as closely as feasible, but 100% match is not possible, due mostly to changes in memory addresses at which code and variables were allocated in different revisions of Sundance. Refer to this list of explanations for each binary mismatch.

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

038940,000002:                                                                                                  ## Copyright:   Public domain.
038941,000003:                                                                                                  ## Filename:    INTER-BANK_COMMUNICATION.agc
038942,000004:                                                                                                  ## Purpose:     A section of a reconstructed, mixed version of Sundance
038943,000005:                                                                                                  ##              It is part of the reconstructed source code for the Lunar
038944,000006:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
038945,000007:                                                                                                  ##              No original listings of this program are available;
038946,000008:                                                                                                  ##              instead, this file was created via disassembly of dumps
038947,000009:                                                                                                  ##              of various revisions of Sundance core rope modules.
038948,000010:                                                                                                  ## Assembler:   yaYUL
038949,000011:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
038950,000012:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
038951,000013:                                                                                                  ## Mod history: 2020-06-17 MAS  Created from Luminary 69.
038952,000014:                                                                                                  ##              2021-05-30 ABS  ISWCALLL -> ISWCALL
038953,000015: 
038954,000016:                                                                                                  ## Sundance 292
038955,000017: 
038956,000018:                                                                                                  #           THE FOLLOWING ROUTINE CAN BE USED TO CALL A SUBROUTINE IN ANOTHER BANK. IN THE BANKCALL VERSION, THE
038957,000019:                                                                                                  #  CADR OF THE SUBROUTINE IMMEDIATELY FOLLOWS THE TC BANKCALL INSTRUCTION, WITH C(A) AND C(L) PRESERVED.
038958,000020: 
038959,000021:    4655                                           BLOCK    02                                    
038960,000022:    4655                                           COUNT*   $$/BANK                               
038961,000023:    4655           52134        BANKCALL           DXCH     BUF2                                  #  SAVE INCOMING A,L.
038962,000024:    4656           50002                           INDEX    Q                                     #  PICK UP CADR.
038963,000025:    4657           30000                           CA       0                                     
038964,000026:    4660           24002                           INCR     Q                                     #  SO WE RETURN TO THE LOC. AFTER THE CADR.
038965,000027: 
038966,000028:                                                                                                  #            SWCALL IS IDENTICAL TO BANKCALL, EXCEPT THAT THE CADR ARRIVES IN A.
038967,000029: 
038968,000030:    4661           54001        SWCALL             TS       L                                     
038969,000031:    4662           22004                           LXCH     FBANK                                 #  SWITCH BANKS, SAVING RETURN.
038970,000032:    4663           75062                           MASK     LOW10                                 #  GET SUB-ADDRESS OF CADR.
038971,000033:    4664           56002                           XCH      Q                                     #  A,L NOW CONTAINS DP RETURN.
038972,000034:    4665           52134                           DXCH     BUF2                                  #  RESTORING INPUTS IF THIS IS A BANKCALL.
038973,000035:    4666           50002                           INDEX    Q                                     
038974,000036:    4667           02000                           TC       10000                                 #  SETTING Q TO SWRETURN.
038975,000037: 
038976,000038:    4670           56134        SWRETURN           XCH      BUF2       +1                         #  COMES HERE TO RETURN TO CALLER. C(A,L)
038977,000039:    4671           56004                           XCH      FBANK                                 #  ARE PRESERVED FOR RETURN.
038978,000040:    4672           56134                           XCH      BUF2       +1                         
038979,000041:    4673           00133                           TC       BUF2                                  
038980,000042: 
038981,000043:                                                                                                  #           THE FOLLOWING ROUTINE CAN BE USED AS A UNILATERAL JUMP WITH C(A,L) PRESERVED AND THE CADR IMMEDIATELY
038982,000044:                                                                                                  #  FOLLOWING THE TC POSTJUMP INSTRUCTION.
038983,000045: 
038984,000046:    4674           56002        POSTJUMP           XCH      Q                                     #  SAVE INCOMING C(A).
038985,000047:    4675           50000                           INDEX    A                                     #  GET CADR.
038986,000048:    4676           30000                           CA       0                                     
038987,000049: 
038988,000050:                                                                                                  #            BANKJUMP IS THE SAME AS POSTJUMP, EXCEPT THAT THE CADR ARRIVES IN A.
038989,000051: 
038990,000052:    4677           54004        BANKJUMP           TS       FBANK                                 
038991,000053:    4700           75062                           MASK     LOW10                                 
038992,000054:    4701           56002                           XCH      Q                                     #  RESTORING INPUT C(A) IF THIS WAS A
038993,000055:    4702           50002        Q+10000            INDEX    Q                                     #  POSTJUMP.
038994,000056:    4703           12000        PRIO12             TCF      10000                                 #  PRIO12 = TCF  10000 = 12000
038995,000057: 
038996,000058:                                                                                                  #            THE FOLLOWING ROUTINE GETS THE RETURN CADR SAVED BY SWCALL OR BANKCALL AND LEAVES IT IN A.
038997,000059: 
038998,000060:    4704           35062        MAKECADR           CAF      LOW10                                 
038999,000061:    4705           70133                           MASK     BUF2                                  
039000,000062:    4706           60134                           AD       BUF2       +1                         
039001,000063:    4707           00002                           TC       Q                                     
039002,000064: 
039003,000065:                                                                                                  #           THE FOLLOWING ROUTINE OBTAINS THE ONE WORD AT THE ADDRESS ARRIVING IN A, AND LEAVES IT IN A.  ENTER
039004,000066:                                                                                                  #  WITH THE CADR IN A, AT DATACALL WITH JUNK IN L IF NOT SWITCHING SUPERBANKS, OTHERWISE AT SUPDACAL WITH SUPERBANK
039005,000067:                                                                                                  #  BITS IN BITS 7-5 IN L (BITS 15-8 AND 4-1 MAY BE JUNK).  DEBRIS = MTEMP.  INHINTS FOR ABOUT 165 MUSEC.
039006,000068: 
039007,000069:    4710           54001        DATACALL           TS       L                                     #  SAVE CADR (SOLE INPUT HERE).
039008,000070:    4711           00006                           EXTEND                                         
039009,000071:    4712           00007                           READ     SUPERBNK                              #  THIS PROLOGUE MAKES SUPERSWITCH VACUOUS.
039010,000072:    4713           56001                           XCH      L                                     #  CADR IN A, SUPERBITS IN L.
039011,000073: 
039012,000074:    4714           54135        SUPDACAL           TS       MPTEMP                                
039013,000075:    4715           56004                           XCH      FBANK                                 #  SET FBANK FOR DATA.
039014,000076:    4716           00006                           EXTEND                                         
039015,000077:    4717           04007                           ROR      SUPERBNK                              #  SAVE FBANK IN BITS 15-11, AND
039016,000078:    4720           56135                           XCH      MPTEMP                                #   SUPERBANK IN BITS 7-5.
039017,000079:    4721           75062                           MASK     LOW10                                 
039018,000080:    4722           56001                           XCH      L                                     #  SAVE REL. ADR. IN BANK, FETCH SUPERBITS.
039019,000081:    4723           00004                           INHINT                                         #  BECAUSE RUPT DOES NOT SAVE SUPERBANK.
039020,000082:    4724           00006                           EXTEND                                         
039021,000083:    4725           01007                           WRITE    SUPERBNK                              #  SET SUPERBANK FOR DATA.
039022,000084:    4726           50001                           INDEX    L                                     
039023,000085:    4727           32000                           CA       10000                                 #  PINBALL (FIX MEM DISP) PREVENTS DCA HERE
039024,000086:    4730           56135                           XCH      MPTEMP                                #  SAVE 1ST WD, FETCH OLD FBANK AND SBANK.
039025,000087:    4731           00006                           EXTEND                                         
039026,000088:    4732           01007                           WRITE    SUPERBNK                              #  RESTORE SUPERBANK.
039027,000089:    4733           00003                           RELINT                                         
039028,000090:    4734           54004                           TS       FBANK                                 #  RESTORE FBANK.
039029,000091:    4735           30135                           CA       MPTEMP                                #  RECOVER FIRST WORD OF DATA.
039030,000092:    4736           00002                           RETURN                                         #  24 WDS. DATACALL 516 MU, SUPDACAL 432 MU
039031,000093: 
039032,000094:                                                                                                  #           THE FOLLOWING ROUTINES ARE IDENTICAL TO BANKCALL AND SWCALL EXCEPT THAT THEY ARE USED IN INTERRUPT.
039033,000095: 
039034,000096:    4737           52073        IBNKCALL           DXCH     RUPTREG3                              #  USES RUPTREG3,4 FOR DP RETURN ADDRESS.
039035,000097:    4740           50002                           INDEX    Q                                     
039036,000098:    4741           30000                           CAF      0                                     
039037,000099:    4742           24002                           INCR     Q                                     
039038,000100: 
039039,000101:    4743           54001        ISWCALL            TS       L                                     
039040,000102:    4744           22004                           LXCH     FBANK                                 
039041,000103:    4745           75062                           MASK     LOW10                                 
039042,000104:    4746           56002                           XCH      Q                                     
039043,000105:    4747           52073                           DXCH     RUPTREG3                              
039044,000106:    4750           50002                           INDEX    Q                                     
039045,000107:    4751           02000                           TC       10000                                 
039046,000108: 
039047,000109:    4752           56073        ISWRETRN           XCH      RUPTREG4                              
039048,000110:    4753           56004                           XCH      FBANK                                 
039049,000111:    4754           56073                           XCH      RUPTREG4                              
039050,000112:    4755           00072                           TC       RUPTREG3                              
039051,000113: 
039052,000114:                                                                                                  #           THE FOLLOWING SUBROUTINES PROVIDE TO THE BASIC PROGRAMMER ENTRY INTO AND RETURN FROM ANY INTERPRETIVE
039053,000115:                                                                                                  #  CODING WHICH DOES NOT USE THE ENTERING CONTENTS OF Q AND WHICH RETURNS VIA DANZIG. C(A) AND C(L) ARE SAVED.
039054,000116: 
039055,000117:                                                                                                  #  USER'S RESPONSIBILITY TO FILL IN ADVANCE THE APPROPRIATE OPERAND AND ADDRESS REGISTERS USED BY THE
039056,000118:                                                                                                  #  INTERPRETIVE CODING SUCH AS MPAC, BUF, ADDRWD, ETC.; AND TO CONFIRM THAT THE INTERPRETIVE CODING MEETS THE
039057,000119:                                                                                                  #  ABOVE RESTRICTIONS WITH RESPECT TO Q AND DANZIG.
039058,000120: 
039059,000121:                                                                                                  #  USEPRET AND USPRCADR MUST NOT BE USED IN INTERRUPT.
039060,000122: 
039061,000123:                                                                                                  #  1. USEPRET ACCESSES INTERPRETIVE CODING WHICH CAN BE ENTERED WITHOUT CHANGING FBANK.
039062,000124:                                                                                                  #     THE CALLING SEQUENCE IS AS FOLLOWS:
039063,000125: 
039064,000126:                                                                                                  #                                          L         TC     USEPRET
039065,000127:                                                                                                  #                                          L+1       TC,TCF INTPRETX       TC,TCF MEANS TC OR TCF
039066,000128:                                                                                                  #                                                                          INTPRETX IS THE INTERPRETIVE CODING
039067,000129:                                                                                                  #                                                                          RETURN IS TO L+2
039068,000130: 
039069,000131:                                                                                                  #  2. USPRCADR ACCESSES INTERPRETIVE CODING IN OTHER THAN THE USER'S FBANK.  THE CALLING SEQUENCE IS AS FOLLOWS:
039070,000132:                                                                                                  #        L       TC      USPRCADR
039071,000133:                                                                                                  #        L+1     CADR    INTPRETX        INTPRETX IS THE INTERPRETIVE CODING
039072,000134:                                                                                                  #                                        RETURN IS TO L+2
039073,000135: 
039074,000136:    4756           56002        USEPRET            XCH      Q                                     #  FETCH Q, SAVING A
039075,000137:    4757           54164                           TS       LOC                                   #  L+1 TO LOC
039076,000138:    4760           30006                           CA       BBANK                                 
039077,000139:    4761           54165                           TS       BANKSET                               #  USER'S BBANK TO BANKSET
039078,000140:    4762           35017                           CA       BIT8                                  
039079,000141:    4763           54023                           TS       EDOP                                  #  EXIT INSTRUCTION TO EDOP
039080,000142:    4764           30002                           CA       Q                                     #  RETRIEVE ORIGINAL A
039081,000143:    4765           00164                           TC       LOC                                   
039082,000144: 
039083,000145:    4766           54164        USPRCADR           TS       LOC                                   #  SAVE A
039084,000146:    4767           35017                           CA       BIT8                                  
039085,000147:    4770           54023                           TS       EDOP                                  #  EXIT INSTRUCTION TO EDOP
039086,000148:    4771           30006                           CA       BBANK                                 
039087,000149:    4772           54165                           TS       BANKSET                               #  USER'S BBANK TO BANKSET
039088,000150:    4773           50002                           INDEX    Q                                     
039089,000151:    4774           30000                           CA       0                                     
039090,000152:    4775           54004                           TS       FBANK                                 #  INTERPRETIVE BANK TO FBANK
039091,000153:    4776           75062                           MASK     LOW10                                 #  YIELDS INTERPRETIVE RELATIVE ADDRESS
039092,000154:    4777           56002                           XCH      Q                                     #  INTERPRETIVE ADDRESS TO Q, FETCHING L+1
039093,000155:    5000           56164                           XCH      LOC                                   #  L+1 TO LOC, RETRIEVING ORIGINAL A
039094,000156:    5001           14702                           TCF      Q+10000                               
039095,000157: 
039096,000158:                                                                                                  #  THERE ARE FOUR POSSIBLE SETTINGS FOR CHANNEL 07.  (CHANNEL 07 CONTAINS THE SUPERBANK SETTING.)
039097,000159: 
039098,000160:                                                                                                  #                                        PSEUDO-FIXED      OCTAL PSEUDO
039099,000161:                                                                                                  #  SUPERBANK     SETTING S-REG. VALUE    BANK NUMBERS      ADDRESSES
039100,000162:                                                                                                  #  ----------    ------- ------------     ------------      ------------
039101,000163:                                                                                                  #  SUPERBANK 3     0XX    2000 - 3777       30 - 37       70000 - 107777         (WHERE XX CAN BE ANYTHING AND
039102,000164:                                                                                                  #                                                                                WILL USUALLY BE SEEN AS 11)
039103,000165:                                                                                                  #  SUPERBANK 4     100    2000 - 3777       40 - 47      110000 - 127777         (AS FAR AS IT CAN BE SEEN,
039104,000166:                                                                                                  #                                                                                ONLY BANKS 40-43 WILL EVER BE
039105,000167:                                                                                                  #                                                                                AND ARE PRESENTLY AVAILABLE)
039106,000168:                                                                                                  #  SUPERBANK 5     101    2000 - 3777       50 - 57      130000 - 147777         (PRESENTLY NOT AVAILABLE TO
039107,000169:                                                                                                  #                                                                                THE USER)
039108,000170:                                                                                                  #  SUPERBANK 6     110    2000 - 3777       60 - 67      150000 - 167777         (PRESENTLY NOT AVAILABLE TO
039109,000171:                                                                                                  #                                                                                THE USER)
039110,000172:                                                                                                  #  *** THIS ROUTINE MAY BE CALLED BY ANY PROGRAM LOCATED IN BANKS 00 - 27.  I.E., NO PROGRAM LIVING IN ANY
039111,000173:                                                                                                  #  SUPERBANK SHOULD USE SUPERSW. ***
039112,000174: 
039113,000175:                                                                                                  #  SUPERSW MAY BE CALLED IN THIS FASHION:
039114,000176:                                                                                                  #        CAF     ABBCON          WHERE   -- ABBCON   BBCON  SOMETHIN  --
039115,000177:                                                                                                  #        TCR     SUPERSW         (THE SUPERBNK BITS ARE IN THE BBCON)
039116,000178:                                                                                                  #        ...       ...
039117,000179:                                                                                                  #         .         .
039118,000180:                                                                                                  #         .         .
039119,000181:                                                                                                  #  OR IN THIS FASHION:
039120,000182:                                                                                                  #        CAF     SUPERSET        WHERE SUPERSET IS ONE OF THE FOUR AVAILABLE
039121,000183:                                                                                                  #        TCR     SUPERSW         SUPERBANK BIT CONSTANTS:
039122,000184:                                                                                                  #        ...       ...                                   SUPER011 OCTAL  60
039123,000185:                                                                                                  #         .         .                                    SUPER100 OCTAL 100
039124,000186:                                                                                                  #         .         .                                    SUPER101 OCTAL 120
039125,000187:                                                                                                  #                                                        SUPER110 OCTAL 140
039126,000188: 
039127,000189:    5002           00006        SUPERSW            EXTEND                                         
039128,000190:    5003           01007                           WRITE    SUPERBNK                              #  WRITE BITS 7-6-5 OF THE ACCUMULATOR INTO
039129,000191:                                                                                                  #  CHANNEL 07
039130,000192:    5004           00002                           TC       Q                                     #  TC TO INSTRUCTION FOLLOWING
039131,000193:                                                                                                  #   TC SUPERSW
039132,000194: 

End of include-file INTER-BANK_COMMUNICATION.agc.  Parent file is MAIN.agc