
ASMB,A,B,L,C    2000E BOOTSTRAP LOADER VERS (1438)
      HED  2000E BOOTSTRAP LOADER 
* 
*     THIS SECTION OF THE TSB SYSTEM BOOTSTRAP IS LOADED
*     INTO MEMORY STARTING AT ADDRESS 2B BY THE BASIC BINARY
*     LOADER. TO RUN, LOAD ADDRESS 2B AND PRESS 'RUN'. THIS 
*     PROGRAM WILL DUMP THE CONTENTS OF THE CARTRIDGE DISC
*     ONTO THE FIXED DISC AND COME TO HALT 33B (T-REGISTER
*     SET TO 102033B). REMOVE THE 'SLEPT' CARTRIDGE DISC AND
*     REPLACE IT BY THE FIRST USER DISC OR ANY SPARE DISC 
*     CARTRIDGE. UPON PRESSING 'RUN', THE LOADER WILL READ
*     THE TSB SYSTEM LOADER FROM TRACK 0 : SECTORS 0, 1, 2. 
*     CONTROL WILL THEN TRANSFER TO THE SYSTEM LOADER.
* 
      ORG 0        ASSEMBLY ORIGIN
RLOAD OCT 0,0      SKIP (A) AND (B) 
      JMP BOOT     STARTING POINT OF BOOTSTRAP
RT/TS OCT 2002     TRANSFER ADDRESS TO SYSTEM LOADER
      HLT 4,C      POWER FAIL INSTRUCTION 
* 
BOOT  LDA WRTC      JUST IN CASE. 
      STA WRITE 
      LDA HLT11 
      STA STAT1 
      CLB           CLEAR ALL DEVICES.
      CLC 0,C 
      CLC 0,C 
      ISZ 1 
      JMP *-3 
QUEST LDA QSTL       OUPUT
      LDB QSTA        QUESTION
      JSB TTY35 
      CLA            INPUT RESPONSE 
      JSB TTY35 
      LDA INBUF 
      ALF,ALF 
      AND DB177 
      CPA Y            YES? 
      JMP SYSD
      CPA N              NO?
      RSS 
      JMP QUEST         DUMMY!
* 
***   PERFORM DISC DUMP 
* 
      JSB CLEAR     CLEAR ALL DISCS 
      LDB M5      READ
      STB WORD      LABEL 
      LDB READA       ON
      CLA 
      JSB DISC
      JSB LABCK     CHECK LABEL.
* 
*  INITIALIZE DISC
* 
      LDB ERRT      REPLACE "HLT 11" IN DISC
      STB STAT1       DRIVER WITH "RSS".
      LDB INITC     SET FOR INITIALIZATION. 
      STB WRITE 
      LDB M203       SET TRACK COUNTER. 
      STB TEMP
      LDB M6144     SET WORD COUNT. 
      STB WORD
      CLA           SET FOR TRACK 0.
      JMP *+3 
INIT  LDA TRK#      COMPUTE TRACK NR. 
      ADA D200        AND 
      STA TRK#          SAVE IT.
      LDB WRITA     INITIALIZE
      IOR CDISC       TRACK.
      JSB DISC
      NOP           NORMAL RETURN.
      ISZ TEMP      ERROR RETURN. DONE? 
      JMP INIT      NO. 
      LDA WRTC      RE-INSTATE
      STA WRITE       DISC
      LDA HLT11         DRIVER
      STA STAT1           ERROR HANDLING. 
* 
      LDB M6144    SET TO TRANSFER 6144 WORDS 
      STB WORD
      LDB M203     SET TO TRANSFER 203 TRACKS 
      STB TEMP
      CLA          SET TRACK POINTER TO TRACK ZERO
      JMP *+3 
DLOOP LDA TRK#     COMPUTE
      ADA D200     TRACK NUMBER 
      STA TRK#     AND SAVE IT
      LDB READA    READ ADDRESS IN (B)
      JSB DISC     READ INTO CORE 
      LDA TRK#     (A) = TRACK #
      LDB WRITA    (B) = WRITE ADDRESS
      IOR CDISC    ADD ON SYSTEM DISC FLAG
      JSB DISC     WRITE TO SYSTEM DISC 
      ISZ TEMP     DONE?
      JMP DLOOP    NO - CONTINUE DISC DUMP
      CLF 0 
      LDA D50       YES. OUTPUT MESSAGE 
      LDB MESG2       AND 
      JSB TTY35         HALT. 
      HLT 33B 
      JSB CLEAR     CLEAR ALL DRIVES. 
      JMP SYSD1     CONTINUE. 
* 
* 
***   READ TSB SYSTEM LOADER FROM DISC
* 
SYSD  JSB CLEAR     CLEAR ALL DISCS 
      LDB M5        READ LABEL. 
      STB WORD
      LDB READA 
      CLA 
      IOR CDISC 
      JSB DISC
      JSB LABCK     CHECK LABEL.
SYSD1 LDB M1020 
      STB WORD
      CLA,INA 
      IOR CDISC    READ TSB 
      LDB MEMAD    SYSTEM LOADER
      JSB DISC     FROM DISC
      JMP RT/TS,I  TRANSFER TO SYSTEM LOADER
* 
***   DISC DRIVER 
* 
DISC  NOP 
      STA DADDR    SAVE DISC AND
      STB CORE     CORE ADDRESSES 
      LDA WORD     EXIT ON
      SZA,RSS      WORD COUNT 
      JMP DISC,I   OF ZERO
      SSB,RSS      ROUND UP 
      AND M.128    TO FULL SECTOR 
      STA WORD     ON WRITE 
      LDA DADDR 
      AND B77 
      STA HD/SC     SAVE SECTOR NUMBER
      ADA M24        > = 24?
      SSA,RSS 
      STA HD/SC      YES
      LDB HD/SC      GET SECTOR NUMBER IN B 
      SSA,RSS 
      ADB HEAD1       ADD HEAD 1 BIT IF >24 
      STB HD/SC 
      LDA DADDR 
      LSR 7        GET
      AND D.377    TRACK NUMBER 
      STA TRCK#    SAVE TRACK NUMBER
      LDA DADDR    LOAD DISC CALL WORD
      LSR 6       CARTRIDGE OR FIXED DISC?
      LDB HD/SC      GET HEAD AND SECTOR PART 
      SLA          SKIP IF CARTRIDGE
      ADB HEAD2 
      STB HD/SC    STORE HEAD/SECTOR COUNT
      LDA TRCK#    OUTPUT TRACK NUMBER
      OTA DC       FOR SEEK OPERATION 
      STC DC,C
      LDA SEEK
      CLC CC       CLEAR PREVIOUS COMMAND 
      OTA CC       OUTPUT SEEK COMMAND
      STC CC,C     TO COMMAND CHANNEL 
      SFS DC
      JMP *-1 
      LDA HD/SC 
      OTA DC       OUTPUT HEAD/SECTOR 
      STC DC,C     TO DATA CHANNEL
      SFS CC       WAIT FOR 
      JMP *-1      SEEK RECORD COMPLETE 
      LDA DMACW 
      OTA 6        OUTPUT DMA CONTROL WORD
      CLC 2 
      LDB CORE     OUTPUT BUFFER ADDRESS
      OTB 2 
      STC 2 
      LDB WORD     OUTPUT WORD COUNT
      OTB 2 
      JSB STAT     CHECK CTATUS 
      LDA READ.    (A) = READ COMMAND 
      LDB CORE     READ OPERATION REQUESTED?
      SSB,RSS 
      LDA WRITE    NO: (A) = WRITE COMMAND
      CLC CC
      OTA CC       OUTPUT READ/WRITE COMMAND
      SSB,RSS      IF OUTPUT, PRESET
      STF DC       DATA CHANNEL FLAG
      SSB          IF INPUT, CLEAR
      STC DC,C     THE FLAG AND SET CONTROL 
      STC 6,C      START DMA
      STC CC,C     START READ/WRITE OPERATION 
      SFS CC       WAIT FOR READ/WRITE
      JMP *-1      TO COMPLETE
      JSB STAT     CHECK STATUS 
      CLC DC
      CLC CC
      CLC 6,C 
      JMP DISC,I   RETURN 
* 
***   CHECK DISC STATUS 
* 
STAT  NOP 
      STC DC,C
      CLA          SET TO CHECK DRIVE ZERO
      OTA CC       OUTPUT SEEK COMMAND
      CLC CC
      STC CC,C     TO COMMAND CHANNEL 
      SFS DC
      JMP *-1 
      LIA DC       GET DISC STATUS
      CLC DC
      SLA,RSS      ANY ERRORS?
      JMP STAT,I   NO 
      XOR FSEEK    IS ERROR DUE TO FIRST SEEK?
      SZA,RSS      CHECK FIRST SEEK BIT 
      JMP STAT,I   OK 
STAT1 EQU * 
      HLT 11B      YES - IRRECOVERABLE ERROR
      JMP *-1 
* 
      ISZ DISC      FOR INITIALIZATION. 
      JMP STAT,I
* 
BOOT1 LDA D16       OUTPUT ERROR MESSAGE. 
      LDB MESG1 
      JSB TTY35 
      HLT 22B 
      JMP BOOT
* 
HEAD1 OCT 400 
B77   OCT 77
M24   DEC -24 
M5    DEC -5
M4    DEC -4
ADR1  NOP 
ADR2  NOP 
LABEL DEF *+1 
      ASC 4,TSSYSTEM
D16   DEC 16
MESG1  DEF *+1
      ASC 7,NOT A SYS DISC
      OCT 6412
D50   DEC 50
MESG2 DEF *+1 
      ASC 12,INSERT CARTR IN SUBCH 1
      OCT 6412      CR-LF 
      ASC 11,PRESS 'RUN' WHEN READY 
      OCT 6412      CR-LF 
* 
* 
**  CLEAR ALL DISC DRIVES 
* 
CLEAR NOP 
      LDA M4    SET COUNT TO 4 DRIVES 
      STA CCNT
      CLA 
      STA DRV#  INITIALIZE DRIVE NUMBER 
CLER1 JSB .STAT 
      ISZ DRV#
      ISZ CCNT
      JMP CLER1 
      LDA M4
      STA CCNT
      CLA 
      STA DRV#
CLER2 EQU * 
      CLA        NOW DO SEEK OPERATION
      OTA DC
      STC DC,C
      LDA SEEK
      IOR DRV#
      CLC CC
      OTA CC
      STC CC,C
      SFS DC
      JMP *-1 
      CLA 
      OTA DC
      STC DC,C
      SFS CC
      JMP *-1 
* 
      JSB .STAT    GEWT STATUS AGAIN
      ISZ DRV#      NEXT DRIVE
      ISZ CCNT    DONE? 
      JMP CLER2 
      JMP CLEAR,I    YES
* 
.STAT NOP 
      CLA 
      IOR DRV#
      STC DC,C
      CLC CC
      OTA CC
      STC CC,C
      SFS DC
      JMP *-1 
      LIA DC
      JMP .STAT,I 
CCNT  NOP 
DRV#  NOP 
* 
* 
LABCK NOP           CHECK LABEL.
      LDA WRITA     SET POINTERS. 
      STA ADR1
      LDB LABEL 
      STB ADR2
      LDB M4        SET COUNTER.
      ISZ ADR1      BUMP POINTER TO 2ND LABEL WORD. 
LBCK1 LDA ADR1,I    LOAD LABEL WORD.
      CPA ADR2,I    WORDS COMPARE?
      RSS 
      JMP BOOT1     NO. OUTPUT MESSAGE. 
      ISZ ADR1      YES. BUMP POINTERS. 
      ISZ ADR2
      INB,SZB       DONE? 
      JMP LBCK1     NO. 
      JMP LABCK,I   YES.
* 
      HED * ASR35 DRIVER *
* 
*     UPON ENTRY (A) HOLDS THE NUMBER OF CHARACTERS TO BE 
*     OUTPUT OR IS ZERO TO REQUEST INPUT. FOR OUTPUT REQUESTS 
*     (B) POINTS TO THE FIRST WORD OF THE BUFFER. A LINE-FEED,
*     RUBOUT, NULL, OR X-OFF IS IGNORED BY INPUT. ON INPUT
*     A CARRIAGE RETURN ENDS THE RECORD, A _ BACKSPACES ONE 
*     CHARACTER, AND AN ESCAPE OR ALT-MODE DELETES THE
*     INPUT RECORD. 
* 
TTY35 NOP 
      STA CCNTY    SET CARACTER COUNT 
      SZA,RSS      OUTPUT REQUEST?
      JMP TTY6     NO 
      BLS          YES, INITIALIZE
      STB BUFAD    CARACTER POINTER 
      CCA          SET FLAG 
      STA TFLAG    AS 'OUTPUT'
      LDA B120K    SEND BITS FOR
      OTA TTYSC     'PRINT ONLY'
TTY1  LDA CCNTY    ALL CHARACTERS 
      SZA,RSS      OUTPUT?
      JMP TTY35,I  YES
      ADA NM1      NO, CORRECT
      STA CCNTY    CHARACTER COUNT
      LDB BUFAD    COMPUTE
      ISZ BUFAD    WORD-CHARACTER 
      CLE,ERB      ADDRESS
      LDA 1,I      LOAD WORD
      SEZ,RSS      POSITION 
      ALF,ALF      CHARACTER
      AND DB177    EXTRACT CHARACTER
      IOR NB200    ADD IN BIT 7 
      OTA TTYSC    OUTPUT IT
TTY2  STC TTYSC,C  REQUEST CHARACTER TRANSFER 
      SFS TTYSC    WAIT FOR 
      JMP *-1      COMPLETION FLAG
      LDA TFLAG 
      SZA          OUTPUT?
      JMP TTY1     YES
      LIA TTYSC    NO, EXTRACT
      AND DB177    CHARACTER
      CPA DB12     LINE FEED? 
      JMP TTY2     YES
      CPA DB177    NO, RUBOUT?
      JMP TTY2     YES
      SZA          NO, NULL 
      CPA NB23     OR X-OFF 
      JMP TTY2     YES
      CPA BKSPC    NO, '_'? 
      JMP TTY4     YES
      CCB          NO 
      CPA DB30     CONTROL X => DELETE RECORD 
      JMP TTY5
      STA TTYTM    SAVE CHARACTER 
      LDB CCNTY    BACKSPACE
      CPB D.72     IF BUFFER
      JSB BKSP     IS FULL
      LDB BUFAD    COMPUTE
      ISZ BUFAD    NEXT BUFFER
      CLE,ERB      ADDRESS
      SEZ,RSS      POSITION 
      ALF,SLA,ALF  AND FORM 
      IOR 1,I      BUFFER WORD
      STA 1,I      STORE AND
      ISZ CCNTY    COUNT CHARACTER
      LDA TTYTM    WAS IT A 
      CPA NB15     CARRIAGE RETURN? 
      JMP TTY8
      JMP TTY2     NO 
TTY4  JSB BKSP     BACKSPACE
      JMP TTY2
TTY5  STB TFLAG    SET TO OUTPUT
      ADB TTY35    SET RETURN 
      STB TTY35    TO INPUT CALL
      LDA N.3      OUTPUT '\' AND 
      LDB RVRSA    CARRIAGE RETURN- 
      JMP TTY35+1  LINE FEED
TTY6  LDB IBUFA    SET UP INPUT 
      STB BUFAD    POINTERS 
      STA TFLAG    SET TO INPUT MODE
      LDA B160K    SEND INPUT BITS
      JMP TTY2-1   TO ASR 35
* 
TTY8 LDA B120K
      OTA TTYSC 
      LDA NB15
      OTA TTYSC 
      STC TTYSC,C 
      SFS TTYSC 
      JMP *-1 
      LDA DB12
      OTA TTYSC 
      STC TTYSC,C 
      SFS TTYSC 
      JMP *-1 
      CLC TTYSC 
      JMP TTY35,I 
* 
**    BACKSPACE ON CHARACTER  **
* 
BKSP  NOP 
      LDB CCNTY    DECREMENT
      SZB,RSS      CHARACTER
      JMP BKSP,I   COUNT
      ADB NM1      IF 
      STB CCNTY    NON-ZERO 
      CCB          BACKSPACE
      ADB BUFAD    CHARACTER
      STB BUFAD    ADDRESS
      CLE,ERB      INSURE 
      LDA 1,I      NEXT CHARACTER 
      AND HIMSK    WILL NOT BE
      STA 1,I      GARBLED
      LDA TTYTM    RETRIEVE CHARACTER FOR CALLS 
      JMP BKSP,I   FROM BUFFER OVERFLOW 
NM1   DEC -1
N.3   DEC 3 
DB12  OCT 12
NB15  OCT 15
NB23  OCT 23
QSTL  DEC 28
QSTA  DEF *+1 
      OCT 6412
      ASC 13,IS SYSTEM ON SUBCHANNEL 0? 
DB30  OCT 30
Y     OCT 131 
N     OCT 116 
D.72  DEC 72
DB177 OCT 177 
NB200 OCT 200 
BKSPC OCT 137 
B120K OCT 120000   'PRINT ONLY' TTY CONTROL BITS
B160K OCT 160000   'INPUT' TTY CONTROL BITS 
HIMSK OCT 177400
RVRSL OCT 56015,5000  '\ CR-LF' FOR LINE DELETION 
TTYSC EQU 10B 
CCNTY BSS 1 
INBUF BSS 36       TTY INPUT BUFFER 
BUFAD BSS 1        TTY CHARACTER ADDRESS
TFLAG BSS 1        TTY I/O MODE 
TTYTM BSS 1        TTY TEMPORARY
IBUFA ABS INBUF+INBUF 
RVRSA DEF RVRSL 
      SPC 5 
* 
*** 
***   CONSTANTS/DATA/STORAGE
* 
DC    EQU 11B 
CC    EQU 12B 
* 
HD/SC NOP 
TRCK# NOP 
CORE  NOP 
DADDR NOP 
TRK#  OCT -200
TEMP  NOP 
WORD  NOP 
M.128 DEC -128
M6144 DEC -6144 
M203  DEC -203
M1020 DEC -1020 
CDISC OCT 100 
D200  OCT 200 
D.377 OCT 377 
FSEEK OCT 40001 
WRTC  OCT 10000 
HLT11 HLT 11B 
ERRT  RSS 
INITC OCT 110000
HEAD2 OCT 1000
WRITE OCT 10000 
READ. OCT 20000 
SEEK  OCT 30000 
MEMAD OCT 102002
READA OCT 104000
WRITA OCT 4000
DMACW ABS 120000B+DC
      END 
