INPORT:	EQU 5
OUTPORT: EQU 016
 ORG	000#000
 DATA  002 ;Course 1.0
 DATA  000
 DATA  002 ;Course 1.5
 DATA  377
 DATA  002 ;Course 2.0
 DATA  376
 DATA  001 ;Course 2.5
 DATA  376
 DATA  000 ;Course 3.0
 DATA  376
 DATA  377 ;Course 3.5
 DATA  376
 DATA  376 ;Course 4.0
 DATA  376
 DATA  376 ;Course 4.5
 DATA  377
 DATA  376 ;Course 5.0
 DATA  000
 DATA  376 ;Course 5.5
 DATA  001
 DATA  376 ;Course 6.0
 DATA  002
 DATA  377 ;Course 6.5
 DATA  002
 DATA  000 ;Course 7.0
 DATA  002
 DATA  001 ;Course 7.5
 DATA  002
 DATA  002 ;Course 8.0
 DATA  002
 DATA  002 ;Course 8.5
 DATA  001
 ORG	000#050
 DATA  000 ;Register storage
 DATA  000 ;Register storage
 DATA  000 ;Register storage
 DATA  000 ;Tern porary storage
 ORG	000#060
 DATA  000 ;Crossing flag
 DATA  000 ;Crossing indicator
 DATA  000 ;Temporary storage
 DATA  000 ;Tern porary storage
 ORG	000#100
 DATA  000 ;Random number
 DATA  000 ;Ran. num. constant
 DATA  000 ;quadrant contents
 DATA  000 ;Sec. loco of S. ship
 DATA  000 ;Sector loco of star
 DATA  000 ;Sector loco of star
 DATA  000 ;Sector loco of star
 DATA  000 ;Sector lo co of star
 DATA  000 ;Sector loco of star
 DATA  000 ;Sector loco of star
 DATA  000 ;Sector loco of star
 DATA  000 ;Sec. loco of space st.
 DATA  000 ;S. loco of A.S. No.1
 DATA  000 ;S. loc. of A.S. No.2
 DATA  000 ;S. loc. of A.S. No.3
 DATA  000 ;Main nrgy L.S. half
 DATA  000 ;Main nrgy M.S. ha lf
 DATA  000 ;Shld nrgy L.S. half
 DATA  000 ;Shld nrgy M.S. half
 DATA  000 ;A.S. 1 nrgy L.S. half
 DATA  000 ;A.S. 1 nrgy MS half
 DATA  000 ;A.S. 2 nrgy L.S. half
 DATA  000 ;A.S. 2 nrgy MS half
 DATA  000 ;A.S. 3 nrgy L.S. half
 DATA  000 ;A.S. 3 nrgy MS half
 DATA  000 ;Quad. loc. of S. ship
 DATA  000 ;Number torpedoes
 DATA  000 ;Num. space stations
 DATA  000 ;Num. alien ships
 DATA  000 ;Nurn . stardates
 DATA  000 ;Temporary storage
 DATA  000 ;Temporary storage
 DATA  000 ;Digit storage
 DATA  000 ;Digit storage
 DATA  000 ;Digit storage
 DATA  000 ;Digit storage
 DATA  000 ;Digit storage

 ORG	000#200
 DATA  215,212,261,240,240,240,240,240
 DATA  261,240,240,240,240,240,261,240
 DATA  240,240,240,240,261,240,240,240
 DATA  240,240,261,240,240,240,240,240
 DATA  261,240,240,240,240,240,261,240
 DATA  240,240,240,240,261,240,240,240
 DATA  240,240,261
;  through 377 reserved for Galaxy content table
         ORG	001#000
MSG_DYW: DATA 215,212,
         DATA "DO YOU WANT TO GO ON A SPACE VOYAGE? "
         DATA 000
MSG_YJD: DATA 215,212
         DATA "YOU MUST DESTROY  "
MSG_SPS: DATA "  ALIEN SHIPS IN  "
MSG_DTS: DATA "  STARDATES WITH "
MSG_SSS: DATA "  SPACE STATIONS"
         DATA 000
MSG_123: DATA 215,212
         DATA " -1--2--3--4-"
         DATA "-5--6--7--8-"
         DATA 000
MSG_STDT: DATA 215,212
MSG_STDT1: DATA "0"
MSG_STDT2:
         DATA "                        "
         DATA 000
MSG_STDT3:
         DATA " STARDATE  300"
MSG_SDP: DATA "0"
         DATA 000
MSG_CND: DATA " CONDITION "
MSG_GRN: DATA "GREEN"
         DATA 000
MSG_QAD: DATA " QUADRANT  "
MSG_PQD: DATA "   "
         DATA 000
MSG_SCT: DATA " SECTOR    "
MSG_SC1: DATA "   "
         DATA 000
MSG_ENR: DATA " ENERGY       "
MSG_ENP: DATA " "
         DATA 000
MSG_TRP: DATA " TORPEDOES  "
MSG_TPP: DATA " "
         DATA 000
MSG_SHD: DATA " SHIELDS      "
MSG_SHP: DATA " "
         DATA 000
MSG_CMD: DATA 215,212
         DATA "COMMAND?"
         DATA 000
MSG_CRS: DATA 215,212
         DATA "COURSE (1-8.5)? "
         DATA 000
MSG_WRP: DATA 215,212
         DATA "WARP FACTOR (0.1-7.7)? "
         DATA 000
MSG_LRS: DATA 215,212
         DATA "L.R. SCAN FOR"
         DATA 000
MSG_MSF: DATA 215,212
         DATA "MISSION FAILED, YOU HAVE RUN OUT OF STARDATES"
         DATA 000
MSG_KAB: DATA 215,212
         DATA "KA-BOOM, YOU CRASHED INTO A STAR. YOUR SHIP IS DESTROYED"
         DATA 000
MSG_YMO: DATA 215,212
         DATA "YOU MOVED OUT OF THE GALAXY, YOUR SHIP IS LOST..LOST"
         DATA 000
MSG_LOE: DATA 215,212
         DATA "LOSS OF ENERGY    "
MSG_LOP: DATA " "
         DATA 000
MSG_DSE: DATA 215,212
         DATA "DANGER-SHIELD ENERGY 000"
         DATA 000
MSG_SET: DATA 215,212
         DATA "SHIELD ENERGY TRANSFER = "
         DATA 000
MSG_NEE: DATA 215,212
         DATA "NOT ENOUGH ENERGY"
         DATA 000
MSG_TTY: DATA 215,212
         DATA "TORPEDO TRAJECTORY(1-8.5) : "
         DATA 000
MSG_ASD: DATA 215,212
         DATA "ALIEN SHIP DESTROYED"
         DATA 000
MSG_YMA: DATA 215,212
         DATA "YOU MISSED! ALIEN SHIP RETALIATES"
         DATA 000
MSG_SSD: DATA 215,212
         DATA "SPACE STATION "
MSG_DES: DATA "DESTROYED"
         DATA 000
MSG_CYH: DATA 215,212
         DATA "CONGRATULATIONS, YOU HAVE ELIMINATED ALL OF THE ALIEN SHIPS"
         DATA 000
MSG_TRG: DATA 215,212
         DATA "TRACKING: "
MSG_TRK: DATA "   "
         DATA 000
MSG_GDY: DATA 215,212
         DATA "GALAXY DISPLAY"
         DATA 000
MSG_PEF: DATA 215,212
         DATA "PHASOR ENERGY TO FIRE = "
         DATA 000
MSG_ASF: DATA 215,212
         DATA "ALIEN SHIP AT SECTOR "
MSG_SEC: DATA " , : "
         DATA 000
MSG_EGY: DATA "ENERGY =    "
MSG_DEY: DATA " "
         DATA 000
MSG_NAS: DATA 215,212
         DATA "NO ALIEN SHIPS! WASTED SHOT"
MSG_ZRO: DATA 000
MSG_NEL: DATA 215,212
         DATA "ABANDON SHIP! NO ENERGY LEFT"
         DATA 000
MSG_NTS: DATA 215,212
         DATA "NO TORPEDOES"
         DATA 000
MSG_111: DATA 215,212
         DATA "1 "
MSG_11a: DATA "    1 "
MSG_11b: DATA "    1 "
MSG_11c: DATA "    1"
         DATA 000
MSG_LST: DATA 215,212
         DATA "LAST"
         DATA 000
MSG_CHK: DATA 215,212
         DATA "CHICKEN!"
         DATA 000

 ORG	005#000
MSG: LAM  
   NDA
   RTZ
     CAL PRINT
     CAL INMEM
     JMP MSG
INMEM: INL
    RFZ
   INH
   RET
RN: LLI 100
   LHI 000
   LAM
   LBA
   RLC
   XRB
   RRC
   INL
   LBM
   INB
   LMB
   ADB
   DCL
   LMA
   RET
SSPLS: LEI 367
      JMP PLS
SSMNS: LEI 010
     JMP MNS
ASPLS: LEI 317
PLS: CAL RN
     ORI 300
   LLA
   LAE
   NDM
   LMA
     JMP GLXCK
ASMNS: LEI 020
MNS: CAL RN
    ORI 300
   LLA
   LAE
   ORM
   LMA
     JMP GLXCK
DIGPRT: LAM
     ADI  260
     CAL INMEM
     CAL SWITCH
   LMA
     CAL DCMEM
   DCB
   RTZ
     CAL SWITCH
     JMP DIGPRT
DCMEM: DCL 
   INL
     JFZ LODCR
   DCH
LODCR: DCL 
   RET
SWITCH: LCL
    LLE
   LEC
   LCH
   LHD
   LDC
   RET
BINDEC: CAL SWITCH  
   LLI 140
   LHI  000
   LMH
   INL
   LMH
   INL
   LMH
   INL
   LMH
   INL
   LMH
   CAL SWITCH
   LEM
   DCB
   JTZ BNDC
   INL
   LDM
BNDC: LLI 144
   LHI 000
   LCI 020
   LBI 047
   CAL BD
   DCL
   LCI 350
   LBI 003
   CAL BD
   DCL
   LCI 144
   LBI 000
   CAL BD
   DCL
   LCI 012
   CAL BD
   DCL
   LME
   RET
BD: 
   LAM
   ADI 001
   LMA
   LAE
   SUC
   LEA
   LAD
   SBB
   LDA
   JFC BD
   LAE
   ADC
   LEA
   LAD
   ACB
   LDA
   LCM
   DCC
   LMC
   RET
LOAD: LLI 117
   LMI 210
   INL
   LMI 023
   INL
   LMH
   INL
   LMH
   LLI 132
   LMI 012
   RET
ROTR4: RRC 
ROTR3: RRC    
   RRC
   RRC
   RET
LOCSET: 
   CAL RN     
   NDI 077
   LBA
   CAL MATCH
   JTZ LOCSET
   LLE
   LMB
   INE
   DCC
   JFZ LOCSET
   RET
ROWSET: LLI \LB\MSG_STDT2 ;217
   LHI \HB\MSG_STDT2
RCLR: LMI 240   
   INL
   LAI 247
   CPL
   JFZ RCLR
   LAC
   ADI 260
   LLI \LB\MSG_STDT1 ;216
   LMA
   DCC
   LHI 000
   LLI 103
   CAL RWPNT
   JFZ STR
   LMI 274
   INL
   LMI 252
   INL
   LMI 276
STR: LLI 104
STR1: LHI 000   
   CAL RWPNT
   JFZ NXSTR
   INL
   LMI 252 
   LLE
NXSTR: INL
     LAI 113
   CPL
   JFZ STR1
   LHI 000 
   CAL RWPNT
   JFZ AS
   LMI 276 
   INL 
   LMI 261 
   INL
   LMI 274
AS: LLI 114
AS1: LHI 000
   CAL RWPNT
   JFZ NXAS
   LMI 253 
   INL
   LMI 253 
   INL
   LMI 253
   LLE
NXAS: INL
     LAI 117 
   CPL
   JFZ AS1
   LHI \HB\MSG_STDT
   LLI \LB\MSG_STDT ;214
   JMP CMSG
RWPNT: LAM 
   NDA
   RTS
   CAL ROTR3
   NDI  007
   CPC
   RFZ
   LAM
   NDI  007
   LBA
   RLC
   ADB
   ADI \LB\MSG_STDT2 ;217
   LEL
   LLA
   LHI \HB\MSG_STDT2 ;001
   XRA
   NDA
   RET
RED: LMI 322
   INL
   LMI 305
   INL
   LMI 304
   INL
   LMI 000
   JMP CND
QUAD: LLI  131
   LHI 000
   LEI \LB\MSG_PQD ;324
   LDI \HB\MSG_PQD ;001
   CAL TWO
   LLI \LB\MSG_QAD
   JMP MSG
TWO: LAM
   LBA
    CAL SWITCH
T1: CAL ROTR3
   NDI  007
   ADI 261
   LMA
   LAB
   NDI 007 
   ADI 261 

   CAL INMEM
   CAL INMEM
   LMA
   RET
FNUM: LAM 
   CPI 260
   RTS
   SUI 272
   ADI 200
   RET
NTN: LHI 023
NT1: LAI   215
   CAL PRINT
   LAI  212
   CAL PRINT
NT2: LAI   255
   CAL PRINT
   DCH
   JFZ NT2
   RET
LRR: ADI 300 
   LBA
   NDI  007
   JTZ CLC1
   LAB
   SUI  001
   LLA
   LAM
LR3: LLI \LB\MSG_11a ;311
   CAL QDS1
   LLB
   LHI 000
   LAM
   LLI  \LB\MSG_11b ;317
    CAL QDS1
   LAB
   NDI 007
   CPI 007
   JTZ CLC2
   LAB
   ADI  001
   LLA
   LHI  000
   LAM
LR4: LLI \LB\MSG_11c ;325
    CAL QDS1
LRP: LLI \LB\MSG_111 ;305
    LHI \HB\MSG_111 ;004
    JMP MSG
QDS1: LHI \HB\MSG_111 ;004
QDSET: LCA  
    CAL ROTR4
    NDI 003
    ORI 260
    LMA
    CAL INMEM
    LAC
    CAL ROTR3
    NDI 001
    ORI 260
    LMA
    CAL INMEM
    LAC
    NDI  007
    ORI 260
   LMA
   RET
CLC1: XRA    
   JMP LR3
CLC2: XRA  
   JMP LR4
RWCM: LLI  136
   LAM
   RRC
   NDI 007
   LBA
   INL
   LAM
   RLC
   RLC
    NDI 070
   ADB
   LBA
   RET
TIME: LLI \LB\MSG_MSF ; 135
   LHI \HB\MSG_MSF ;002
DONE: CAL MSG  
   JMP GALAXY
LOST: LLI \LB\MSG_YMO ;310
   LHI \HB\MSG_YMO ;002
   JMP DONE
WPOUT: LLI \LB\MSG_KAB ;215
   LHI \HB\MSG_KAB ;002
   JMP DONE
EOUT: LLI \LB\MSG_NEL ; 227 
   LHI \HB\MSG_NEL ;004
   JMP DONE
NWQD: LLI 104 
    LEI 013
CLR: LMI  200
   INL
   DCE
     JFZ CLR
    LLI  102
   LAM
    NDI 007 
   LCA
    LEI 104
  CFZ LOCSET
    LLI 102
   LAM
   CAL ROTR3
  NDI 001
   LCA
 LEI 113
 CFZ LOCSET
    LLI 102
   LAM
    CAL ROTR4
  NDI 003
  LCA
 LEI 114
    CFZ LOCSET
LDAS: CAL RN
     LLI 123 
     CAL LAS
    LLI  125 
     CAL LAS
    LLI 127
   JMP LAS
LAS: LMA   
  NDI 003
   INL
   LMA
   JMP RN
MATCH: LLI 104
SCK: LAM   
   NDA
   JTS NS
   CPB
   RTZ
   INL
   LAI 113
   CPL
   JFZ SCK
NS: LLI 113
   LAM
   CPB
   RTZ
ACK: INL 
   LAM
   CPB
   RTZ
   LAL
   CPI 116
   JFZ ACK
   NDA
   RET
ELOS: LLI 062
   LME
   INL
   LMD
   DCL
   LBI 002
   CAL BINDEC
   LDI  \HB\MSG_LOP ;003
   LEI  \LB\MSG_LOP ;023
   LBI 004
   CAL DIGPRT
   LLI \LB\MSG_LOE ; 377
   LHI \HB\MSG_LOE ; 002
   CAL CMSG
   LLI 062
   LEM
   INL
   LDM
ELS1: CAL CKSD  
   JFC FMSD
   LEM
   INL
   LDM
   CAL FMSD
   CAL TOMN
   LLI 062
   LEM
   INL
   LDM
SD0: CAL CKMN    
   JTC EOUT
   CAL FMMN
   LLI \LB\MSG_DSE ;025 
   LHI \HB\MSG_DSE ;003  
   CAL CMSG
   LBI  002
   CAL DVD
   CAL CKMN
   JTC EOUT
   JMP FMMN
ELOM: CAL CKMN  
   JFC FMMN
   LCE
   LBD
   LLI  121
   LEM
   INL
   LDM
   CAL FMSD
   CAL TOMN
   LEC
   LDB
   JMP SD0
DLET: LMI 200
   LBL
   LLI 131 
   LAM
   ADI 300
   LLA
   LAB
   CPI 113
   JFZ DLAS
   LAM
   NDI 067
   LMA
   LLI 102
   LMA
   LLI 133
   LBM
   DCB
   LMB
   RFZ
   LLI \LB\MSG_DSE ;333
   LHI \HB\MSG_DSE ;004
CMSG: CAL MSG 
    LHI 000
   RET
DLAS: LAM   
   SUI  020
   LMA
   LLI 102
   LMA
   LLI 134
   LBM
   DCB
   LMB
   RFZ
   LLI \LB\MSG_CYH ;324
   LHI \HB\MSG_CYH ;003
   JMP DONE
DRCT: CAL INPUT   
   LLI 136
   LHI 000
   CPI  261
   JTC ZRET
   CPI 271
   JFC ZRET
   NDI 017
   RLC
   LMA
   LAI 256
   CAL PRINT
   CAL INPUT
   CPI  260
   JTZ CR1
   CPI  265
   JFZ ZRET
CR1: NDI 001    
    ADM
   RLC
   SUI 004
   LMA
   RFZ
   ADI  001
   RET
ZRET: XRA  
   RET
QCNT: LHI 000  
   LLI 131
   LAM
   ADI  300
   LLA
   LAM
   LLI  102
   LMA
   RET
ACTV: LLI  136
   LLM
   LCM
   INL
   LDM
   LLI  103
   LAM
   LBA
   NDI 007
   LLI 136
   RLC
   LMA
   INL
   LAB
   NDI 070
   RRC
   RRC
   LMA
   RET
TRK: LLI 060
   LMH
   LLI 136
   LAM
   ADC
   LMA
   JFS NOBK
   NDI 017 
   LMA
   LLI 060
   LML
   LLI  131
   LAM
   NDI 007
   RTZ
   LBM
   DCB
   LMB
   JMP RMV
NOBK: CPI 020
   JTC RMV
   NDI 017
   LMA
   LLI 060
   LML
   LLI 131
   LAM
   NDI 007
   ADI 001
   CPI 010
   RTZ
   LBM
   INB
   LMB

RMV: LLI 137
   LAM
   ADD
   LMA
   JFS NOUP
   NDI 017 
   LMA
   LLI  060
   LML
   LLI 131
   LAM
   NDI  070
   RTZ
   LAM
   SUI  010
   LMA
   JMP CKX
NOUP: CPI  020  
   JTC CKX
   NDI  017
   LMA
   LLI 060
   LML
   LLI  131
   LAM
   NDI 070
   ADI 010
   CPI 100
   RTZ
   LAM
   ADI 010
   LMA
CKX: LLI  050
   LME
   INL
   LMD
   INL
   LMC
   RFZ
   LAI  001
   NDA
   RET
DVD: NDA  
   LAD
   RAR
   LDA
   LAE
   RAR
   LEA
   DCB
   JFZ DVD
   RET
WASTE: CAL ELOM 
   LLI \LB\MSG_NAS ;171
   LHI \HB\MSG_NAS ;004
   CAL MSG
   JMP CMND
EIN: LHI 000 
   LLI 144
   LMH
   LLI 143 
   CAL INPUT
   CPI  255
   JFZ EN2
   INL
   LML
   DCL
EN1: CAL INPUT 
EN2: LMA    
  CAL FNUM
   RTS
   LAM
   NDI 017
   LMA
   DCL
    LAI 137 
   CPL
   RTZ
   JMP EN1
DCBN: LLI 140
   LAM
   DCL
   LMH
   DCL
   LMA
   LLI 141
   LAM
   NDA
   JTZ DC1
   LBA
   LEI 012
   LDH
   CAL TOBN
DC1: LLI 142
   LAM
   NDA
   JTZ DC2
   LBA
   LEI  144
   LDH
   CAL TOBN
DC2: LLI 143
   LAM
   NDA
   JTZ DC3
   LBA
   LEI 350
   LDI 003
   CAL TOBN
DC3: LLI  136
   LEM
   INL
   LDM
   RET
TOBN: LLI 136
   CAL TO1
   DCB
   RTZ
   JMP TOBN
TOMN: LLI 117 
TO1:   LAM  
   ADE
   LMA
   INL
   LAM
   ACD
   LMA
   RET
TOSD: LLI  121
   JMP TO1
FMMN: LLI 117
FM1: LAM 
   SUE
   LMA
   INL
   LAM
   SBD
   LMA
   RET
FMSD: LLI  121
   JMP FM1
CKMN: LLI 120
CK1: LAM  
   DCL
   CPD
   RFZ
CK2: LAM  
   CPE
   RET
CKSD: LLI  122
   JMP CK1
OVER: LLI \LB\MSG_CHK ;342
   LHI \HB\MSG_CHK ;004
   CAL MSG
   HLT
SPRC: LAM  
   NDI 007
   LCA
   LAM
   CAL ROTR3
   NDI  007
   LBA
   RET
 ORG 012#000
GALAXY: LLI \LB\MSG_DYW  
   LHI  \HB\MSG_DYW
   CAL MSG
START: 
   CAL RN
   CAL INPCK
   JFS START
   CAL INPUT
   CPI 316
   JTZ OVER
   LEI  300
GLXSET: CAL RN
   NDI 177
   LLA
   LHI  017
   LAM
   LLE
   LHI  000
   LMA
   INE
   JFZ GLXSET
GLXCK: LDH 
   LCH
   LLI 300 
GLXCK1: LAM
    NDI 010
   ADD
   LDA
   LAM
   NDI  060
   RRC
   RRC
   ADC
   LCA
   INL
   JFZ GLXCK1
   LAD
   RRC
   RRC
   RRC
   LDA
   CPI 007
   JFC SSPLS
   CPI 002
   JTC SSMNS
   LAC
   RRC
   RRC
   LCA
   CPI 040
   JFC ASPLS
   CPI  012
   JTC ASMNS
   LLI  133
   LMD
   INL
   LMC
   LAC
   ADI  005
   INL
   LMA
   LBI 001
   CAL BINDEC
   LDI \HB\MSG_DTS ;001
   LEI \LB\MSG_DTS ;116
   LBI 002
   CAL DIGPRT
   LLI  134
   LHI 000
   LBI 001
   CAL BINDEC
   LDI \HB\MSG_SPS ; 001
   LEI \LB\MSG_SPS ;074
   LBI 002
   CAL DIGPRT
   LLI 133
   LHI 000
   LAM
   ORI  260
   LHI  \HB\MSG_SSS ; 001
   LLI  \LB\MSG_SSS ;137
   LMA
   LLI \LB\MSG_YJD ;050 
   LHI \HB\MSG_YJD ; 001
   CAL MSG
   CAL RN
   NDI 077
   LLI  131
   LMA
   CAL QCNT
   CAL LOAD
   CAL NWQD
   LCI  001
   LEI 103
   CAL LOCSET
SRSCN: LLI \LB\MSG_123 ;160
   LHI \HB\MSG_123 ;001
   CAL MSG
   LCI  001
   CAL ROWSET
   LLI  135
   LHI 000
   LAI 062
   SUM
   INL
   LMA
   LBI 001
   CAL BINDEC
   LDI \HB\MSG_SDP ;001
   LEI \LB\MSG_SDP ;266
   LBI 002
   CAL DIGPRT
   LLI \LB\MSG_STDT3 ;250
   LHI \HB\MSG_STDT3 ;001
   CAL MSG
   LCI 002
   CAL ROWSET
   LLI 102
   LAM
   LLI \LB\MSG_GRN ; 303
   LHI \HB\MSG_GRN ;001
   NDI  060
   JFZ RED
   LMI 307 
   INL
   LMI 322
   INL
   LMI 305
   INL
   LMI 305
   INL
   LMI 316
CND: LLI \LB\MSG_CND ;270
   CAL MSG
   LCI 003
   CAL ROWSET
   CAL QUAD
   LCI 004
   CAL ROWSET
   LLI 103
   LEI \LB\MSG_SC1 ; 343
   IND
   CAL TWO
   LLI \LB\MSG_SCT ; 330
   CAL MSG
   LCI 005
   CAL ROWSET
   LLI 117
   LBI 002
   CAL BINDEC
   LDI  \HB\MSG_ENP ;001
   LEI  \LB\MSG_ENP ;365
   LBI  004
   CAL DIGPRT
   LLI \LB\MSG_ENR ;347
   LHI \HB\MSG_ENR ;001
   CAL MSG
   LCI 006
   CAL ROWSET
   LLI  132
   LBI  001
   CAL BINDEC
   LDI \HB\MSG_TPP ;002
   LEI \LB\MSG_TPP ;003
   LBI 002
   CAL DIGPRT
   LLI \LB\MSG_TRP ;367
   LHI \HB\MSG_TRP ; 001
   CAL MSG
   LCI 007
   CAL ROWSET
   LLI 121
   LBI  002
   CAL BINDEC
   LDI \HB\MSG_SHP ;002
   LEI \LB\MSG_SHP ;023
   LBI  004
   CAL DIGPRT
   LLI  \LB\MSG_SHD ;005
   LHI  \HB\MSG_SHD ;002
   CAL MSG
   LCI 010
   CAL ROWSET
   LLI \LB\MSG_123 ;160
   LHI \HB\MSG_123 ;001
   CAL MSG
CMND: LHI 000
   LEI  012
   LDH
   CAL ELOM
   LLI 101
   LEM
   INE
   LME
CMD: LLI \LB\MSG_CMD ;025
   LHI \HB\MSG_CMD ;002
   CAL CMSG
   CAL INPUT
   CPI  260
   JTZ CRSE
   CPI  261
   JTZ SRSCN
   CPI  262
   JTZ LRSCN
   CPI 263
   JTZ GXPRT
   CPI 264
   JTZ SHEN
   CPI 265
   JTZ PHSR
   CPI 266
   JTZ TRPD
   JMP CMD
LRSCN: LLI \LB\MSG_LRS ;115 
   LHI \HB\MSG_LRS ;002
   CAL MSG
   CAL QUAD
   CAL NTN
   LLI 131
   LAM
   NDI 070 
   JTZ RWC1
   LAM
   SUI  010
   CAL LRR
LR1: CAL NTN 
   LLI  131
   LAM
   CAL LRR
   CAL NTN
   LLI 131
   LAM
   CPI 070
   JFC RWC2
   ADI 010
   CAL LRR
LR2: CAL NTN 
   JMP CMND
RWC1: CAL RWC    
  JMP LR1
RWC2: CAL RWC  
    JMP LR2
RWC: LLI \LB\MSG_11a ;311
    XRA
    CAL QDS1
    LLI  \LB\MSG_11b ;317
    XRA
    CAL QDS1
    LLI \LB\MSG_11c ;325
    XRA
    CAL QDS1
    JMP LRP
CRSE: LLI \LB\MSG_CRS ;040   
    LHI \HB\MSG_CRS ;002
     CAL MSG
     CAL DRCT
 JTZ CRSE 
WRP: LLI  \LB\MSG_WRP ;063
   LHI \HB\MSG_WRP ;002
     CAL CMSG
    LLI 137
     CAL INPUT
    CPI 260
      JTC WRP
    CPI 270
     JFC WRP
    NDI 007
   RLC
   RLC
   RLC
   LMA
    LAI 256
     CAL PRINT
     CAL INPUT
    CPI 260
   JTC WRP
    CPI  270
     JFC WRP
   NDI 007
   ADM
    JTZ WRP
   LEA
   CAL ACTV
   LLI 061
   LMH
MOV: CAL TRK 
   JTZ LOST 
    LLI  060
   LAM
   NDA
   JTZ CLSN
   INL
   LML
   LEI 031
   LDH
   CAL ELOM
 
   CAL QCNT
   CAL NWQD
CLSN: CAL RWCM    
  CAL MATCH
  JFZ MVDN
  LBL
  LAB
  CPI  113
  LLI  061
  LAM
  JTZ SSOUT
  JFC ASOUT
  NDA
  JTZ WPOUT
MVDN: LHI 000  
  LLI  050
  LEM
  INL
  LDM
  INL
  LCM
  DCE
  JFZ MOV
  LLI  061
  LAM
  NDA
  JTZ NOX
  LLI  135
  LBM
  DCB
  JTZ TIME
  LMB
NOX: CAL RWCM  
   LLI  103
   LMB
   CAL MATCH

   CTZ CHNG
   CAL DKED
   JMP SRSCN
SSOUT: NDA   
   JFZ MVDN
   LLB
   CAL DLET
   LEI 130
   LDI 002
SSO1: CAL ELOS    
  JMP MVDN
ASOUT: NDA
      JFZ MVDN
   LLB
   CAL DLET
   LEI  334
   LDI  005
   JMP SSO1
CHNG: LEL     
   LCI 001
   JMP LOCSET
DKED: LLI  113
   LAM
   NDA
   RTS
   LAB
   NDI 070
   LCA
   LAB
   NDI  007
   LBA
   LAM
   NDI  007
   LEA
   LAM
   NDI  070
   CPC
   RFZ
   LAB
   ADI 001
   CPE
   JTZ LOAD
   SUI  002
   CPE
   RFZ
   JMP LOAD
SHEN: LLI \LB\MSG_SET ; 060  
   LHI \HB\MSG_SET ;003
   CAL MSG
   CAL EIN
   JTS SHEN
   CAL DCBN
   LLI  144
   LAM
   NDA
   JTZ POS
   CAL CKSD
   JTC NE
   CAL FMSD
   CAL TOMN
   JMP CMND
POS: CAL CKMN   
   JTC NE
   CAL FMMN
   CAL TOSD
   JMP CMND
NE: LLI \LB\MSG_NEE ;114 
   LHI \HB\MSG_NEE ;003
   CAL MSG
   JMP CMND
TRPD: LLI  132
   LAM
   NDA
   JTZ NTPD
   LEI  372
   LDH
   CAL CKMN
   JTC NE
   CAL FMMN
   LLI  132
   LAM
   SUI  001
   LMA
TR1: LLI \LB\MSG_TTY ;140
   LHI \HB\MSG_TTY ;003
   CAL MSG
   CAL DRCT
   JTZ TR1
   CAL ACTV
   LLI  131
   LAM
   LLI 053 
   LMA
TR2: CAL TRK  
   JTZ QOUT
   LLI  060
   LAM
   NDA
   JFZ QOUT
   CAL RWCM
   LCB
   LLI \LB\MSG_TRK ;036 
   LHI \HB\MSG_TRK ;004
   CAL T1
   LLI  022
   CAL CMSG
   LBC
   CAL MATCH
   JTZ HIT
   LLI  050
   LEM
   INL
   LDM
   INL
   LCM
   JMP TR2
HIT: LAL 
  CPI 113
  JTC QOUT
  JTZ SSTA
  CAL DLET
  LLI \LB\MSG_ASD ;177
  LHI \HB\MSG_ASD ;003
  CAL MSG
  JMP CMND
SSTA: CAL DLET 
  LLI \LB\MSG_SSD ;272
  LHI \HB\MSG_SSD ;003
  CAL MSG
QOUT:  LLI \LB\MSG_YMA ;226
  LHI \HB\MSG_YMA ;003
  CAL CMSG
  LEI  310
  LDH
   CAL ELOS
   LLI 053
   LAM
   LLI  131
   LMA
   JMP CMND
NTPD: LLI \LB\MSG_ZRO ;226
   LHI \HB\MSG_ZRO ;004
   CAL MSG
   JMP CMND
PHSR: LLI \LB\MSG_PEF ;063 
   LHI \HB\MSG_PEF ;004
   CAL MSG
   CAL EIN
   JTS PHSR
   CAL DCBN
   CAL ELOM
   LLI  102
   LAM
   NDI 060
   JTZ WASTE
   CAL ROTR4
   SUI 001
   JTZ PH1
   LBA
   CAL DVD
PH1:   LLI 136 
   LME
   INL
   LMD
   LLI 050
   LME
   INL
   LMD
   INL
   LMI 114
   CAL ASPH
   LLI 052
   LMI 115
   CAL ASPH
   LLI  052
   LMI 116
   CAL ASPH
   JMP CMND
ASPH: LLM  
   LAM
   NDA
   RTS
   LEI  \LB\MSG_SEC ;145
   LDI  \HB\MSG_SEC ;004
   CAL TWO
   LLI  116
   CAL CMSG
   LLI  103
   CAL SPRC
   LLE
   LHD
   LEC
   LDB
   CAL SPRC
   LAB
   SUD
   JFS PH2
   XRI 377
   ADI  001
PH2: LBA  
   LAC
   SUE
   JFS PH3
   XRI  377
   ADI  001
PH3: ADB 
   RRC
   RRC
   NDI  003
   LBA
   LCL
   LLI 050
   LEM
   INL
   LDM
   DCB
   INB
   CFZ DVD
   LAC
   NDI  003
   RLC
   ADI  123
   LLI 053
   LMA
   LLA
   CAL FM1
   JTS DSTR
   JFZ ALOS
   DCL
   LAM
   INL
   NDA
   JTZ DSTR
ALOS: DCL  
   LBI  002
   CAL BINDEC
   LEI \LB\MSG_DEY ;167
   LDI \HB\MSG_DEY ;004
   LBI 004
   CAL DIGPRT
   LLI \LB\MSG_EGY ; 153
   LHI \HB\MSG_EGY ; 004
   CAL CMSG
   LLI  053
   LLM
   LEM
   INL
   LDM
   LBI  002
   CAL DVD
   JMP ELOS
DSTR: LLI \LB\MSG_DES ;312
   LHI \HB\MSG_DES ;003
    CAL CMSG
    LLI  052
    LLM
    JMP DLET
GXPRT: LLI  \LB\MSG_GDY ;042
    LHI \HB\MSG_GDY ;004
    CAL MSG
    LHI 061 
     CAL NT1
     LLI  300
GL1: LDH  
    LEI  204
GL2: LAM   
    CAL SWITCH
    CAL QDSET
    LAL
    ADI  004
    LLA
    CAL SWITCH
    INL
    CPI 264
    JFZ GL2
    CAL SWITCH
    LLI 200
    CAL MSG
    LHI 061
    CAL NT1
    LAE
    CPH
    JTZ CMND
    CAL SWITCH
    JMP GL1

; sets sign flag if character coming in
INPCK:
	INP INPORT
	NDA
	JTS INPCK2 ; nothing coming in clear sign and return
	CAL CINP2 ; finish character so we don't get garbage next call 
	XRA       ; clearsign, next instruction will complement it before returning
INPCK2:
	XRI 200  ; complement MSB to set sign 0= character not coming in
	RET
        
    ORG	017#000
 DATA  000,001,004,043,012,003,007,000
 DATA  000,032,043,005,003,024,026,022
 DATA  000,000,000,000,000,005,004,027
 DATA  005,001,024,000,000,004,005,000
 DATA  007,002,021,011,000,004,000,000
 DATA  043,000,002,044,000,000,003,007
 DATA  000,025,000,005,014,000,002,006
 DATA  025,000,003,002,023,000,064,003
 DATA  007,001,000,000,000,003,025,000
 DATA  000,004,000,037,004,001,003,002
 DATA  003,024,000,000,000,026,015,000
 DATA  000,004,023,003,000,000,000,024
 DATA  013,001,025,023,000,000,004,003
 DATA  007,000,000,000,035,004,000,026
 DATA  000,023,025,000,000,004,006,002
 DATA  003,025,000,000,026,000,047,000


INPUT:
;;; HERE IS THE USER DEFINED CHARACTER INPUT TO READ FROM SERIAL PORT
CINP:	
	INP INPORT
	NDA
	JTS CINP
CINP2:
	XRA
	LBI 104

MORE1:	DCB
	JFZ MORE1
	OUT OUTPORT
	CAL TIMER
	CAL NEXBIT
	CAL NEXBIT
	CAL NEXBIT
	CAL NEXBIT
	CAL NEXBIT
	CAL NEXBIT
	CAL NEXBIT
	CAL NEXBIT

STOP:	LAI 001
	OUT OUTPORT
	LAB
	RLC
	LBI 314

MORE3:	DCB
	JFZ MORE3
	RET

NEXBIT:	INP INPORT
	NDI 200
	RLC
	OUT OUTPORT
	RRC
	ADB
	RRC
TIMER:	LBI 213
MORE2:	DCB
	JFZ MORE2
	LBA
	RET
PRINT:
;;; HERE IS THE USER DEFINED PRINT ROUTINE FOR A SERIAL PORT
	
CPRINT:	NDA
	RAL
	OUT OUTPORT
	RAR
	CAL TIMER
	CAL BITOUT
	CAL BITOUT
	CAL BITOUT
	CAL BITOUT
	CAL BITOUT
	CAL BITOUT
	CAL BITOUT
	CAL BITOUT
	LBA
	LAI 001
	OUT OUTPORT
	LAB
	CAL TIMER
	LBI 103
	JMP MORE3

BITOUT:	OUT OUTPORT
	RRC
	CAL TIMER
	RET
