         SOCW                       Absolute assembly mode.
         PCC      0
*
*        This is a fairly simple-minded bootstrap loading program
*        designed for use with the CP-V CSE-STOP table dump program,
*        although it may be used for loading other stand-alone
*        programs if desired.  The program to be loaded must be
*        assembled in absolute binary form (SOCW directive to META
*        or AP).  The last record in the binary deck must consist
*        of 120 bytes of zeros - a blank card will serve quite
*        well.  This loader is capable of booting a program in from
*        tape;  no error retries will be done, and an end-of-file
*        condition will not be treated properly - use that 120*0
*        record to indicate end-of-tape.  This version of the
*        loader assumes that the program is to be loaded starting
*        at X'8000';  this may be changed as desired by modifying
*        a symbol in the DUMPSYS system file (see below).  A good
*        place to have the program load would be a real-time page
*        that need not be preserved across recovery;  failing that,
*        some section of monitor code may be chosen.  The dump
*        program requires slightly less than 1 page of memory.
*
*        Author:  Dave Platt, Honeywell LADC
*
*        Note:    This loader and dump program are not CP-V
*        supported products;  they are supplied strictly on a
*        use-at-your-own-risk basis.  They have been tested under
*        CP-V E01 and F00 on both a Sigma 5 and a dual Sigma 7;
*        they should work properly on any Sigma machine and on
*        a Xerox 560.  Pleasant dumping!
*
         TITLE    'Bootstrap loader for CSE-STOP dump'
         SYSTEM   SIG9P
         SYSTEM   DUMPSYS           Get register definitions
         ORG      X'2A'             Origin of bootstrap area
BEGIN    LI,R1    1000              Spin for a while to let the
         BDR,R1   $                   card reader become ready
         TIO,R1   *X'25'            Test the card reader
         BCS,12   BEGIN             If not ready, go back and spin again
         LI,R0    DA(CDW)           If it's in Automatic, get the
         SIO,R0   *X'25'            command doubleword and start reading
PAUSE    LI,R1    1000              Spin for a while while it reads
         BDR,R1   $                   so as not to tie up the interface
         TIO,R1   *X'25'            Test the reader
         BCS,12   PAUSE             If it's still busy, wait some more
         LD,R2    CDW               Load address/length of data
LOOPCHK  MTB,0    0,R2              Test byte in data just read
         BNEZ     PROCEED           If nonzero, card was valid
         AI,R2    1                 Bump to next byte
         BDR,R3   LOOPCHK           Test next byte on card if any
         B        STOMP             If none, was last card - run.
PROCEED  LI,R1    120               When done, bump buffer address
         AWM,R1   CDW                 by 120 bytes (1 card's worth)
         B        BEGIN                 and go read some more.
         BOUND    8
CDW      DATA     X'02000000'+STOMP*4  Define program beginning
         DATA     120               There are 120 bytes on each card.
         END
         SOCW                       Absolute assembly
         PCC      0                 Don't list PAGE/TITLE cmds.
         SYSTEM   SIG9P
         SYSTEM   DUMPSYS
LABEL    CNAME
         PROC
LF       EQU      $
         DISP     $
         LIST     0
I        DO       NUM(AF)
         TEXTC    AF(I)
         FIN
         LIST     1
         PEND
TYPE     CNAME
         PROC
LF       LI,R1    AF
         BAL,R15  TYPEOUT
         PEND
         TITLE    'CSE-STOP table dump program'
         ORG      STOMP
BEGIN    STW,R7   R7VALUE           SAVE R7 FOR REFERENCE
         TYPE     NLFIVE
         TYPE     CSEHEADER
         CLM,R7   CSERANGES
         BCR,9    R7OK
         TYPE     NLTWO
         TYPE     R7QUEST
         AND,R7   R7MASK
R7OK     TYPE     NLFIVE
         LI,R5    R7VALUE           POINT TO SAVED R7
         LI,R6    BA(R7ID)          POINT TO TITLE
         BAL,R11  DUMPTBL           GO PRINT R7
         TYPE     NLFIVE
         TYPE     MAINHEADER
         TYPE     NLTWO
         LW,R5    R7                POINT TO CSESTOP TABLE
         LI,R6    BA(CSESTOPT)      POINT TO TEXTC OF TITLES
         BAL,R11  DUMPTBL           DUMP THE MAIN TABLE
         LW,R5    22,R7             CSED$3STAT POINTER
         CLM,R5   CSERANGES         CHECK TO SEE IF IT'S THERE
         BCS,9    DUMPMSTAT         IF NOT, SKIP IT
         TYPE     NLFIVE
         TYPE     CS3HEADER         PRINT HEADER FOR 3STAT TABLES
         TYPE     NLTWO
         LI,R6    BA(CS3TITLES)     POINT TO TEXTC FOR 3STAT ENTRIES
         BAL,R11  DUMPTBL           DUMP THE 3STAT TABLES
DUMPMSTAT LW,R5   20,R7             POINTER TO MSTAT TABLES
         CLM,R5   CSERANGES         IS IT THERE?
         BCS,9    DUMPPSTAT         IF NOT DON'T TRY TO DUMP IT
         TYPE     NLFIVE
         TYPE     MSTHEADER
         TYPE     NLTWO
         LI,R6    BA(MSTTITLES)     POINT TO MSTAT TEXTC
         BAL,R11  DUMPTBL
         BDR,R14  $-2
DUMPPSTAT LW,R5   21,R7             POINTER TO PSTAT TABLES
         CLM,R5   CSERANGES         IS IT THERE?
         BCS,9    ENDDUMP           IF NOT DON'T TRY IT.
         TYPE     NLFIVE
         TYPE     PSTHEADER
         TYPE     NLTWO
         LI,R14   7                 MAX OF 7 PROCESSORS
         LI,R6    BA(PSTTITLES)     POINT TO PSTAT TEXTC
         BAL,R11  DUMPTBL
         BDR,R14  $-2               GO BACK FOR NEXT PROCESSOR
ENDDUMP  TYPE     NLFIVE
         TYPE     SAVETHIS
         TYPE     NLTWO
         TYPE     OPREC
         TYPE     NLFIVE
         TYPE     NLFIVE
         WAIT
         B        $-1
         TITLE    'Dump indicated location(s) in hex, with titles'
DUMPTBL  MTB,0    0,R6              ANY MORE TITLES IN THIS SECTION?
         BEZ      *R11              IF NOT, RETURN TO CALLER
         TYPE     NL                DOWN TO NEXT LINE
         LW,R2    0,R5              GET THE DATA WORD
         AI,R5    1                 BUMP THE POINTER
         LI,R4    8                 8 DIGITS IN A WORD
HEXSHFT  SLD,R2   -4                MOVE DIGIT TO HIGH END OF R3
         SLS,R3   -28               MOVE DIGIT TO LOW END OF R3
         LB,R3    HEXVALS,R3        GET THE APPROPRIATE HEX DIGIT
         STB,R3   HEXOUT,R4         STORE DIGIT IN OUTPUT AREA
         BDR,R4   HEXSHFT           GO ON TO NEXT DIGIT
         TYPE     HEXOUT            PRINT THE NUMBER
         TYPE     R6                TYPE THE TITLE
         LB,R3    0,R6              GET BC OF TITLE
         SLS,R3   -2                DELETE LOW 2 BITS
         SLS,R3   2                 MAKE IT A BYTE COUNT AGAIN
         AW,R6    R3                BUMP TEXTC POINTER
         B        DUMPTBL           GO DUMP NEXT ENTRY
         TITLE    'Perform output to operator''s console'
TYPEOUT  CI,R1    16                Are we printing from a register?
         BL       REGLIST           If so, special case.
         LW,R2    R1                Copy pointer
         SLS,R2   2                 Make it a byte address
         LB,R3    0,R2              Get TEXTC count
         AI,R2    1                 Point past TEXTC count
         B        SETCDW            Go set up CDW
REGLIST  LW,R2    0,R1              Get address from register
         LB,R3    0,R2              Get length
         AI,R2    1                 Point past length
SETCDW   LI,R0    1                 Order code 1 = Write
         STB,R0   R2                Save it in proper place
         STD,R2   CDW               Save the CDW
         LI,R0    DA(CDW)           Point to CDW
         SIO,R0   1                 Start printing on console
DELAY    LI,R1    10000             Spin here waiting
         BDR,R1   $                   for the console
         TIO,R0   1                 Test console
         BCS,12   DELAY             If still busy, go spin again
         B        *R15              Return
         TITLE    'Define TEXTC labels and other data areas'
         BOUND    8
CDW      DATA     0,0               Console command doubleword
CSERANGES DATA    X'400',X'8000'    Acceptable places for CSESTOP table
R7VALUE  DATA     0                 Saved value from R7
R7MASK   DATA     X'0001FFFF'       Mask for questionable R7's
NL       DATA     X'01150000'
NLTWO    DATA     X'02151500'
NLFIVE   DATA     X'05151515',X'15150000'
CSEHEADER LABEL   '  *** CP-V CSE-STOP TABLES ***'
R7QUEST  LABEL    ' ((R7 LOOKS BAD))'
R7ID     LABEL    'R7 - POINTER TO MAIN CSE-STOP TABLE'
         LABEL    ''                END OF R7 "TABLE"
MAINHEADER LABEL  'MAIN CSE-STOP TABLE'
CSESTOPT LABEL    'CSED$CF'
         LABEL    'CSED$REGS (R0)'
         LABEL    'CSED$REGS (R1)'
         LABEL    'CSED$REGS (R2)'
         LABEL    'CSED$REGS (R3)'
         LABEL    'CSED$REGS (R4)'
         LABEL    'CSED$REGS (R5)'
         LABEL    'CSED$REGS (R6)'
         LABEL    'CSED$REGS (R7)'
         LABEL    'CSED$REGS (R8)'
         LABEL    'CSED$REGS (R9)'
         LABEL    'CSED$REGS (R10)'
         LABEL    'CSED$REGS (R11)'
         LABEL    'CSED$REGS (R12)'
         LABEL    'CSED$REGS (R13)'
         LABEL    'CSED$REGS (R14)'
         LABEL    'CSED$REGS (R15)'
         LABEL    'CSED$WHY'
         LABEL    'CSED$PSD (WORD 0)'
         LABEL    'CSED$PSD (WORD 1)'
         LABEL    'CSED$MSTAT$ADR'
         LABEL    'CSED$PSTAT$ADR'
         LABEL    'CSED$3STAT$ADR'
         LABEL    'CSED$MSG (WORD 0)'
         LABEL    'CSED$MSG (WORD 1)'
         LABEL    'CSED$MSG (WORD 2)'
         LABEL    'CSED$MSG (WORD 3)'
         LABEL    'CSED$MSG (WORD 4)'
         LABEL    'CSED$MSG (WORD 5)'
         LABEL    'CSED$MSG (WORD 6)'
         LABEL    'CSED$STOP'
         LABEL    'CSED$ELOG$ADR'
         LABEL    ''                (End of main CSE stop table)
CS3HEADER LABEL   'CSED$3STAT (MEMORY SCAN) TABLE'
CS3TITLES RES
         LABEL    '(ERROR LOG CODE/COUNT)'
         LABEL    '(RELATIVE TIME)'
         LABEL    '3ANDADD'
         LABEL    '3ORADD'
         LABEL    '3ANDCONT'
         LABEL    '3ORCONT'
         LABEL    '3FIRST'
         LABEL    '3FIRSTC'
         LABEL    '3LAST'
         LABEL    '3LASTC'
         LABEL    ''
MSTHEADER LABEL   'CSED$MSTAT (MEMORY FAULT STATUS REGISTER) TABLE'
MSTTITLES RES
         LABEL    'FLAGS/REAL ADDRESS'
         LABEL    'MEMORY FAULT STATUS WORD 0'
         LABEL    'MEMORY FAULT STATUS WORD 1'
         LABEL    'MEMORY FAULT STATUS WORD 2'
         LABEL    ''
PSTHEADER LABEL   'CSED$PSTAT (PROCESSOR FAULT STATUS REGISTER) TABLE'
PSTTITLES  LABEL  'PROCESSOR STATUS REGISTER'
         LABEL    ''
SAVETHIS LABEL    ' PLEASE SAVE THIS OUTPUT FOR HONEYWELL'
OPREC    LABEL    ' PLEASE ATTEMPT AN OPERATOR RECOVERY'
HEXVALS  TEXT     '0123456789ABCDEF'
HEXOUT   LABEL    '........   '
         LIST     0                 Generate 240 bytes of zeros
         DO1      60
         DATA     0
         LIST     1
         END
