ASMB,C,L   GTCRC - GENERATE 264XX CRC - 7/19/77 
      HED CRC GENERATOR - PROGRAM INITIALIZATION
* 
      NAM GTCRC,7    770926 
      SUP 
      ENT GTCRC 
      EXT EXEC
* 
*  INITIALIZE VARIBLES
* 
GTCRC EQU * 
      NOP 
      ISZ GTCRC     FETCH THE BLOCK SIZE
      LDA GTCRC,I 
      LDA A,I 
      STA BLKSZ     SET BLOCK SIZE PARAMETER
      LDA .OPBF     INITIALIZE OUTPUT ROUTINE 
      CLE,ELA         BUFFER POINTER AND BUFFER 
      STA PTBW1       COUNTER 
      LDA =D-256
      STA OPCNT 
      CCA           INITIALIZE INPUT BUFFER 
      STA INCTR       AND CODE BLOCK COUNTERS 
      STA BLKCT       TO MINUS ONE
* 
*  OPEN INPUT AND OUTPUT DEVICES
* 
* 
      JSB EXEC      PUNCH TAPE LEADER 
      DEF *+3 
      DEF CTLRC 
      DEF PNLDR 
* 
*  PROCESS THE HEADER RECORD
* 
      JSB EXEC      INPUT THE HEADER FROM THE 
      DEF *+5         INPUT TAPE
      DEF INPRC       <INPUT REQUEST CODE>
      DEF RDRIN       <ASCII INPUT> 
      DEF BFOUT       <INPUT BUFFER>
      DEF BUFLN       <BUFFER LENGTH> 
* 
      STB INLEN     STORE THE INPUT LENGTH
      JSB EXEC
      DEF *+5 
      DEF OUTRC 
      DEF PNASC 
      DEF BFOUT 
      DEF INLEN 
      HED CRC GENERATOR - MAIN PROGRAM
MAINI EQU * 
      LDA BLKSZ     INITIALIZE BYTE COUNTER 
      STA NMBYT 
      CMA           COMPLEMENT THE BLOCK SIZE 
      ADA =D3       SET BLOCK ADDRESS MASK
      STA BLKMS       THIS ROUTINE IS GIVEN A 
*                                     PARAMETER THAT IS 3 LESS THAN 
*                                     THE ACTUAL BLOCK SIZE 
      CLA           CLEAR THE CRC 
      STA CRC 
      STA BCKSM     CLEAR THE CHECKSUM
* 
MAINL JSB GTBYT     GET THE NEXT INPUT BYTE 
      JSB EOJ       END OF TAPE - CHECK FOR EOJ 
      JSB PTBYT     PUT THE BYTE OUT
      JSB NXCRC     COMBINE IT INTO THE CRC 
      ISZ NMBYT     ALL BYTES DONE? 
      JMP MAINL     NO - DO NEXT BYTE 
* 
      JSB REPRT     YES - DISPLAY THE CRC 
      LDA CRC       FETCH THE CRC 
      STA CRCHD     ADD THE CRC TO THE CRC
      AND =B377 
      JSB PTBYT     OUTPUT THE MSB OF THE CRC 
      JSB NXCRC 
      LDA CRCHD 
      ALF,ALF 
      AND =B377 
      JSB PTBYT     OUTPUT THE LSB OF THE CRC 
      JSB NXCRC 
      JSB REPRT 
* 
*  OUTPUT THE CHECKSUM
* 
      LDA BCKSM     FETCH THE CHECKSUM
      ALF,ALF 
      ADA BCKSM     ADD LSB TO MSB
      ALF,ALF       SHIFT FOR COMBINED VALUE
      CMA           COMPLEMENT TO GET INVERSE 
      AND =B377     MASK FOR LOW ORDER BYTE 
      JSB PTBYT     OUTPUT THE CHECKSUM 
* 
      LDB REPD1     FETCH CONVERSION BUFFER ADDRESS 
      CCE           SET TO FILL LOW ORDER BYTE
      JSB O2AS      CONVERT TO ASCII
      LDA REPD2     TRANSFER ASCII VALUE TO MESSAGE 
      CLE,ELA 
      LDB .CKM1 
      CCE           SET UPPER/LOWER BYTE FLAG 
      ELB             IN DESTINATION POINTER
      JSB XFR 
      DEC -3
* 
      JSB EXEC      DISPLAY THE CHECKSUM
      DEF *+5 
      DEF OUTRC 
      DEF TTY 
      DEF CKMSG 
      DEF CKMLN 
      LDA EOTFL     GET END OF TAPE FLAG
      SSA,RSS       END OF TAPE REACHED?
      JMP EOTL1     YES - EXIT
* 
      LDA =D-256    RESET BLOCK ADDRESS 
      STA ADDR        COUNTER 
      JSB GTBYT     BYPASS LAST THREE BYTES 
      JMP ERRX1     UNEXPECTED EOT - TERMINATE
      JSB GTBYT 
      JMP ERRX1     UNEXPECTED EOT - TERMINATE
      JSB GTBYT 
      JMP ERRX1     UNEXPECTED EOT - TERMINATE
      JMP MAINI     DO THE NEXT BLOCK 
      SKP 
ERRX1 JSB EXEC      UNEXPECTED EOT TERMINATION
      DEF *+5       DISPLAY ERROR MESSAGE 
      DEF OUTRC       <OUTPUT REQUEST CODE> 
      DEF TTY         <TTY CONTROL CODE>
      DEF ERRM1       <POINTER TO ERROR MESSAGE>
      DEF ERRL1       <MESSAGE LENGTH>
      HED CRC GENERATOR - CLOSE PROGRAM 
EOJ   EQU * 
      NOP 
      CLA           CLEAR THE A-REGISTER
      STA EOTFL     SET THE END OF TAPE FLAG
      LDB NMBYT     GET REMAINING NUM BYTES IN BLOCK
      CPB BLKSZ     IS IT A NEW BLOCK?
      RSS           YES - END OF JOB
      JMP EOJ,I     NO - PAD OUT LAST BLOCK 
* 
*  END OF JOB - CLEAR PUNCH AND TERMINATE 
* 
EOTL1 EQU * 
      LDA PCHLU     WAIT FOR PUNCH TO FINISH
      JSB WAIT        THE LAST RECORD 
      JSB EXEC      PUNCH THE TAPE TRAILER
      DEF *+3 
      DEF CTLRC 
      DEF PNTRL 
* 
      JSB EXEC      DISPLAY THE END OF JOB
      DEF *+5         MESSAGE 
      DEF OUTRC       <OUTPUT REQUEST CODE> 
      DEF TTY         <TTY CONTROL CODE>
      DEF EOJMS       <POINTER TO EOJ MESSAGE>
      DEF EOJML       <MESSAGE LENGTH>
* 
RETN  JSB EXEC      RETURN TO DOS 
      DEF *+2 
      DEF EOJRC 
      HED CRC GENERATOR - SUBROUTINES 
* 
* * * * * A2BUF - ADD CHAR IN A-REG TO A BUFFER 
* 
*     CALLING SEQUENCE: 
* 
*     LDA <CHARACTER> 
*     JSB A2BUF 
*     DEF <BUFFER POINTER WITH UPPER/LOWER FLAG>
*     <RETURN>
* 
A2BUF NOP 
      STA A2BCH     SAVE THE CHARACTER
      LDB A2BUF,I   FETCH THE BUFFER ADDRESS
      ISZ A2BUF,I   INCREMENT THE BUFFER POINTER
      SLB,INB       ADJUST ADDRESS TO FETCH THE 
      ADB =D-2        OPPOSITE CHARACTER
      STB A2BW1 
      CLE,ERB       REMOVE UPPER LOWER FLAG 
      STB A2BPT     SAVE THE ADDRESS
      JSB NXCHR     FETCH THE OPPOSITE CHARACTER
A2BW1 DEF * 
      ALF,ALF       ROTATE IT UP
      IOR A2BCH     MERGE IN THE INPUT CHARACTER
      SEZ           NEW CHARACTER TO UPPER BYTE?
      ALF,ALF       YES - ROTATE THE WORD 
      STA A2BPT,I   RESTORE THE BUFFER WORD 
      ISZ A2BUF     INCREMENT THE RETURN ADDRESS
      JMP A2BUF,I   RETURN
* 
A2BCH OCT 0         INPUT CHARACTER 
A2BPT DEF *         POINTER TO CURRENT BUFFER WORD
      SKP 
* * * * * GTBYT - GET THE NEXT BYTE 
* 
*     CALLING SEQUENCE: 
* 
*     JSB GTBYT 
*     <END OF TAPE RETURN>
*     <NORMAL RETURN> 
* 
*         ON NORMAL RETURN, THE A-REGISTER CONTAINS THE NEXT
*         INPUT BYTE
* 
GTBYT NOP 
      LDA EOTFL     GET THE END OF TAPE FLAG
      SZA,RSS       END OF TAPE ALREADY REACHED?
      JMP GTBYT,I   YES - RETURN IMMEDIATELY
      JSB GTTAP     GET THE NEXT INPUT BYTE 
      NOP           IGNORE END OF TAPE
      ISZ BLKCT     END OF BINARY BLOCK?
      JMP GTBX1     NO - NORMAL RETURN
* 
GTBW1 JMP GTBL2     BYPASS CHECKSUM CHECK ON 1ST PASS 
      JSB GTTAP     GET CHECKSUM BYTE 
      JMP ERRX1     UNEXPECTED EOT - TERMINATE
      XOR CHKSM     MASK IN THE COMPUTED CHECKSUM 
      AND =B377     MASK OUT UPPER HALF WORD
      SZA,RSS       MATCH?
      JMP GTBL0     YES - GO FIND NEXT BLOCK
* 
      JSB EXEC      NO - REPORT ERROR 
      DEF *+5         <RETURN ADDRESS>
      DEF OUTRC       <OUTPUT REQUEST CODE> 
      DEF TTY         <TTY CONTROL CODE>
      DEF ERRMS       <OUTPUT BUFFER> 
      DEF ERRML       <BUFFER LENGTH> 
      JSB EOJ       TERMINATE THE PROGRAM 
      JMP RETN      AND RETURN
* 
GTBL0 EQU * 
      LDA =D256     UPDATE NEXT BLOCK ADDRESS 
      ADA ADDR
      STA ADDR
GTBL1 EQU * 
      JSB GTTAP     GET THE NEXT INPUT BYTE 
      JMP GTBYT,I   END OF TAPE - RETURN IMMEDIATELY
GTBL2 EQU * 
      CLB           CLEAR SKIP FOR FIRST PASS 
      STB GTBW1 
      CPA =B377     BINARY RECORD HEAD? 
      RSS           YES - START RECORD
      JMP GTBL1     NO - GET NEXT BYTE
* 
      LDA =D-256    INITIALIZE BLOCK COUNTER
      STA BLKCT 
      ISZ NMBLK     INCREMENT BLOCK COUNT 
      JSB GTTAP     GET SECOND ALL ONES BYTE
      JMP ERRX1     UNEXPECTED EOT - TERMINATE
      JSB GTTAP     BYPASS ADDRESS BYTES
      JMP ERRX1     UNEXPECTED EOT - TERMINATE
      STA CHKSM     INITIALIZE CHECKSUM 
      STA PNADR     PUT ADDRESS INTO PUNCH BUFFER 
      JSB GTTAP 
      JMP ERRX1     UNEXPECTED EOT - TERMINATE
      LDB PNADR     COMBINE LSB AND MSB OF LOAD 
      BLF,BLF         ADDRESS AND PUT INTO PUNCH
      IOR B           BUFFER
      STA PNADR 
      ADA CHKSM     ADD ADDRESS TO CHECKSUM 
      STA CHKSM 
      LDA PNADR     RECALL BLOCK ADDRESS
      AND BLKMS     GET LOW ORDER BITS FOR BLOCK
      CPA ADDR        ADDRESS CHECK 
      JMP GTBX0     COMPARE OK
* 
      JSB EXEC      MISSING DATA BLOCK
      DEF *+5         <RETURN ADDRESS>
      DEF OUTRC       <OUTPUT REQUEST CODE> 
      DEF TTY         <TTY CONTROL CODE>
      DEF ERRMA       <OUTPUT BUFFER> 
      DEF ERMAL       <BUFFER LENGTH> 
      JSB EOJ       TERMINATE THE PROGRAM 
      JMP RETN        AND RETURN
* 
GTBX0 EQU * 
      JSB GTTAP     GET THE FIRST BINARY BYTE 
      JMP ERRX1     UNEXPECTED EOT - TERMINATE
* 
GTBX1 STA B         ACCUMULATE CHECKSUM 
      ADB CHKSM 
      STB CHKSM 
      ISZ GTBYT     INCREMENT RETURN ADDRESS
      JMP GTBYT,I   RETURN
* 
ERRML DEC 7         ERROR MESSAGE BUFFER LENGTH 
ERRMS ASC 7,CHECKSUM ERROR
ERMAL DEC 11
ERRMA ASC 11,MISSING BLOCK ADDRESS
CHKSM OCT 0         COMPUTED CHECKSUM 
      SKP 
* * * * * GTTAP - GET INPUT FROM THE TAPE READER
* 
*     CALLING SEQUENCE: 
* 
*     JSB GTTAP 
*     <END OF TAPE RETURN>
*     <NORMAL RETURN> 
* 
*         RETURNS WITH THE NEXT INPUT BYTE IN THE A-REGISTER
* 
GTTAP NOP 
      ISZ INCTR     INPUT BUFFER EXHAUSTED? 
      JMP GTTL2     NO - FETCH NEXT BYTE IN BUFFER
* 
      JSB EXEC      GET ANOTHER BLOCK OF INPUT
      DEF *+5         <RETURN ADDRESS>
      DEF INPRC       <INPUT REQUEST CODE> = 1
      DEF INBIN       <BINARY INPUT CONTROL CODE> 
GTTD1 DEF INBUF       <BUFFER ADDRESS>
      DEF BUFLN       <BUFFER LENGTH> 
* 
      LDA GTTD1     INITIALIZE BUFFER POINTERS
      STA PTR 
      CLE,ELA       SHIFT IN UPPER/LOWER FLAG 
      STA GTTP1 
      LDB NMCHR     INITIALIZE COUNTER
      STB INCTR 
      CLA           CHECK FOR NULL INPUT
      BRS           DIVIDE COUNT BY TWO 
* 
GTTL1 XOR PTR,I     COMBINE ALL INPUT 
      ISZ PTR 
      INB,SZB       DONE? 
      JMP GTTL1     NO - ADD IN NEXT WORD 
      SZA,RSS       END OF TAPE?
      JMP GTTAP,I   YES - RETURN IMMEDIATELY
* 
GTTL2 JSB NXCHR     GET THE NEXT INPUT BYTE 
GTTP1 DEF * 
      ISZ GTTAP     INCREMENT THE RETURN ADDRESS
      JMP GTTAP,I   RETURN
      SKP 
* * * * * NXCHR - GET NEXT BYTE IN A STRING 
* 
*     CALLING SEQUENCE: 
* 
*     JSB NXCHR 
*     DEF <POINTER TO STRING WITH UPPER/LOWER FLAG> 
*     <RETURN>
* 
*     RETURNS WITH THE NEXT BYTE IN THE A-REGISTER
* 
NXCHR NOP 
      LDB NXCHR,I   FETCH POINTER 
      CLE,ERB       SHIFT OUT THE UPPER LOWER FLAG
      LDA B,I       FETCH THE WORD
      SEZ,RSS       UPPER BYTE? (FLAG = 0)
      ALF,ALF       YES - SHIFT UPPER BYTE DOWN 
      AND =B377     MASK OUT THE UPPER HALF WORD
      ISZ NXCHR,I   INCREMENT THE POINTER 
      ISZ NXCHR     INCREMENT THE RETURN
      JMP NXCHR,I   RETURN
      SKP 
* * * * * NXCRC - ADD ANOTHER BYTE TO THE CRC 
* 
*     CALLING SEQUENCE: 
* 
*     LDA <BYTE TO BE ADDED>
*     JSB NXCRC 
*     <RETURN>
* 
*         CRC IS STORE IN THE WORD "CRC"
* 
NXCRC NOP 
      STA B         SAVE THE DATA BYTE
      ADA BCKSM     ACCUMULATE THE BLOCK
      STA BCKSM 
      ALF,ALF       ADD IN CARRY IF ANY 
      ADA BCKSM 
      AND =B377     ACCUMULATE LOWER BYTE ONLY
      STA BCKSM 
* 
*  ACCUMULATE CRC 
* 
      LDA =D-8      SET LOOP COUNT FOR
      STA NXCCT       EIGHT BITS PER BYTE 
NXCL1 ERB           EXTRACT THE LOW ORDER BIT 
      CLA,SEZ       SET LOW ORDER BIT OF
      INA             THE A-REGISTER ACCORDINGLY
      XOR CRC       COMBINE INTO THE CRC
      ERA 
      CLA,SEZ       SET A-TO ZERO IF LSB IS ZERO
      LDA NXCK1     MERGE IN ONES OTHERWISE 
      XOR CRC 
      ERA           SHIFT IN NEW CRC BITS 
      STA CRC       SAVE THE NEW CRC
* 
      ISZ NXCCT     ALL BITS DONE?
      JMP NXCL1     NO - DO NEXT BIT
      JMP NXCRC,I   YES - RETURN
* 
BCKSM OCT 0         BLOCK CHECKSUM
CRC   OCT 0         CRC 
NXCK1 OCT 40002     SHIFT IN PATTERN FOR ONES 
NXCCT DEC 0         BIT COUNTER 
      SKP 
* * * * * O2AS - CONVERT OCTAL TO ASCII 
* 
*     CALLING SEQUENCE: 
* 
*     LDA <NUMBER TO BE CONVERTED>
*     LDB <BUFFER ADDRESS WITH U/L BYTE FLAG> 
*     JSB O2AS
*     <RETURN>
* 
*         CONVERTS TO SIX ASCII CHARACTERS
* 
O2AS  NOP 
      ELB           SHIFT IN U/L FLAG 
      STB O2AW1     STORE BUFFER POINTER
      LDB =D-6      SET LOOP COUNTER
      STB O2ACT 
      RAL           ROTATE FOR FIRST DIGIT
      STA O2ACH     SAVE THE WORD 
      AND =B1       MASK FOR FIRST DIGIT
O2AL1 AND =B7       MASK FOR OCTAL DIGIT
      ADA =B60      CONVERT TO ASCII
      JSB A2BUF     PUT THE CHARACTER INTO THE
O2AW1 DEF *           BUFFER
      LDA O2ACH     FETCH THE WORD
      ALF,RAR       ROTATE THE WORD 
      STA O2ACH     SAVE IT 
      ISZ O2ACT     ALL DIGITS DONE?
      JMP O2AL1     NO - DO NEXT DIGIT
      JMP O2AS,I    YES - RETURN
* 
O2ACT DEC -6        LOOP COUNTER
O2ACH OCT 0         SAVE AREA 
      SKP 
* * * * * PTBYT - PUT BYTE INTO PUNCH BUFFER
* 
*     ENTRY:  A = BYTE TO BE OUTPUT 
* 
*     EXIT :  B DESTROYED 
* 
PTBYT EQU * 
      NOP 
      STA PTBCH     SAVE THE BYTE 
      JSB A2BUF     PUT IT INTO THE OUTPUT
PTBW1 DEF *           BUFFER
* 
      LDA PCKSM     ACCUMULATE PUNCH CHECKSUM 
      ADA PTBCH 
      STA PCKSM 
* 
      ISZ OPCNT     BUFFER FULL?
      RSS           NO - EXIT 
      JSB PTBR1     YES - PUNCH THE RECORD
      LDA PTBCH     RECALL BYTE 
      JMP PTBYT,I   RETURN
* 
*  PUNCH THE RECORD 
* 
PTBR1 EQU * 
      NOP 
      LDA PNADR     ADD LOAD ADDRESS TO CHECKSUM
      ALF,ALF 
      ADA PNADR     COMBINE LSB AND MSB 
      ADA PCKSM     ADD TO ACCUMULATE CHECKSUM
      AND =B377     RETAIN ONLY LSB OF CHECKSUM 
      STA PCKSM     PUT INTO PUNCH BUFFER 
* 
*  WAIT FOR PREVIOUS PUNCH TO COMPLETE, THEN TRANSFER 
*    RECORD TO OUTPUT BUFFER
* 
      LDA PCHLU     WAIT FOR PUNCH LOGICAL UNIT 
      JSB WAIT        TO COMPLETE I/O 
      LDA .PBUF     FETCH SOURCE AND DESTINATION
      LDB .PBFO       POINTERS
      JSB XFRWD     TRANSFER DATA TO OUTPUT BUFFER
      ABS -PBFLN
* 
      JSB EXEC      PUNCH BINARY RECORD 
      DEF *+5         WITHOUT WAITING FOR 
      DEF OUTRC       COMPLETION
      DEF PNBIN 
.PBFO DEF BFOUT 
      DEF PBLEN 
* 
*  INITIALIZE OUTPUT ROUTINE AND RETURN 
* 
      LDA .OPBF     RESET BUFFER POINTER AND
      CLE,ELA         BUFFER COUNTER
      STA PTBW1 
      LDA =D-256
      STA OPCNT 
      LDA PNADR     INCREMENT MSB OF LOAD ADDRESS 
      ADA =D256       IN PUNCH BUFFER IN CASE 
      STA PNADR       BLOCK IS BEING PADDED OUT 
      CLA           CLEAR PUNCH CHECKSUM
      STA PCKSM 
      JMP PTBR1,I   RETURN
* 
*  DATA FOR PUNCH ROUTINE 
* 
PTBCH OCT 0         CHARACTER TO BE OUTPUT
OPCNT DEC 0         OUTPUT BUFFER COUNT 
.PBUF DEF *+1 
PNBUF EQU * 
      ASC 10,************************ 
      OCT 6412      CR/LF 
      DEC -1        TWO ALL ONES BYTE 
PNADR DEF *         LOAD ADDRESS
OPBUF BSS 128       DATA AREA 
PCKSM DEF 0         PUNCH CHECKSUM
* 
PBFLN EQU *-PNBUF   PUNCH BUFFER LENGTH 
PBLEN DEF PBFLN 
.OPBF DEF OPBUF     POINTER TO OUTPUT BUFFER
* 
BFOUT EQU * 
      BSS PBFLN     OUTPUT BUFFER 
      SKP 
* * * * * REPRT - DISPLAY THE VALUE OF THE CRC
* 
REPRT NOP 
      LDB NMBUF     INITIALIZE THE BUFFER POINTER 
      CLE           SET FOR UPPER BYTE
      LDA CRC       FETCH THE CRC 
      JSB O2AS      CONVERT TO OCTAL-ASCII
* 
      LDA CRC       FETCH THE CRC 
      AND =B377     MASK OUT UPPER BYTE 
      LDB REPD2     FETCH BUFFER ADDRESS
      CLE           SET U/L FLAG FOR UPPER BYTE 
      JSB O2AS      CONVERT LSB TO ASCII
* 
      LDA CRC       FETCH THE CRC 
      ALF,ALF       SHIFT UPPER BYTE DOWN 
      AND =B377     MASK OUT UPPER HALF WORD
      LDB REPD1     FETCH BUFFER ADDRESS
      CCE           SET FOR LOWER BYTE
      JSB O2AS      CONVERT MSB TO ASCII
* 
      LDA REPD2     FETCH BUFFER ADDRESS
      CLE,ELA       SET U/L FLAG FOR UPPER BYTE 
      LDB OUTA1     FETCH OUTPUT ADDRESS
      CLE,ELB       SET U/L FLAG FOR UPPER BYTE 
      JSB XFR       TRANSFER MSB  TO OUTPUT 
      DEC -3
      LDB OUTA2     FETCH OUTPUT ADDRESS
      CLE,ELB       SET U/L FLAG FOR UPPER BYTE 
      JSB XFR       TRANSFER LSB  TO OUTPUT 
      DEC -3
* 
      JSB EXEC      YES - DISPLAY THE VALUE 
      DEF *+5         <RETURN ADDRESS>
      DEF OUTRC       <OUTPUT CODE> 
      DEF TTY         <OUTPUT CONTROL WORD> 
      DEF OUTBF       <OUTPUT BUFFER> 
      DEF OUTBL       <OUTPUT BUFFER LENGTH>
      JMP REPRT,I   RETURN
* 
REPB1 BSS 2         CONVERSION BUFFER FOR MSB 
REPB2 BSS 3         CONVERSION BUFFER FOR LSB 
REPD1 DEF REPB1 
REPD2 DEF REPB2 
NMBUF DEF OUTNM     NUMBER FIELD POINTER
OUTBL DEC 11        OUTPUT BUFFER LENGTH
CNTR  DEC 0         DIGIT COUNTER 
OUTBF ASC 2,CRC=
OUTNM BSS 3         CRC DISPLAY VALUE 
      ASC 1, (
OUTMS ASC 3,   ) (
OUTLS ASC 2,   )
OUTA1 DEF OUTMS 
OUTA2 DEF OUTLS 
      SKP 
* * * * * WAIT - WAIT UNTIL LOGICAL UNIT BECOMES FREE 
* 
*     CALLING SEQUENCE: 
* 
*     LDA <LOGICAL UNIT NUMBER> 
*     JSB WAIT
*     <RETURN WHEN UNIT IS FREE 
* 
WAIT  NOP 
      STA WAIT0     STORE UNIT AS CONTROL WORD
* 
*  GET STATUS AND WAIT UNTIL STATUS REPORTS FREE
* 
WAIT2 EQU * 
      JSB EXEC      GET THE DEVICE STATUS 
      DEF *+5 
      DEF STARC       <STATUS REQUEST CODE> 
      DEF WAIT0 
      DEF WAIT4       <STATUS BUFFER> 
      DEF WAIT5       <TRANSMISSION LOG BUFFER> 
      LDA WAIT5     GET STATUS
      SSA           IS DEVICE FREE (>=0)? 
      JMP WAIT2     NO - CONTINUE WAITING 
      JMP WAIT,I    YES - RETURN
* 
WAIT0 OCT 0         CONTROL CODE FOR EXEC CALL
WAIT4 OCT 0         STATUS BUFFER 
WAIT5 OCT 0         TRANSMISSION LOG
      SKP 
* * * * * XFR - TRANSFER BYTES
* 
*     CALLING SEQUENCE: 
* 
*     LDA <SOURCE ADDRESS WITH U/L BYTE FLAG> 
*     LDB <DESTINATION ADDRESS WITH U/L BYTE FLAG>
*     JSB XFR 
*     DEC -<NUMBER OF BYTES>
*     <RETURN>
* 
*         ON RETURN, A AND B CONTAIN UPDATED POINTERS 
* 
XFR   NOP 
      STA XFRW1     STORE SORCE AND DESTINATION 
      STB XFRW2       POINTERS
      LDA XFR,I     FETCH THE NUMBER OF BYTES 
      STA XFRCT       TO BE TRANSFERRED 
      ISZ XFR       INCREMENT THE RETURN ADDRESS
XFRL1 JSB NXCHR     FETCH THE SOURCE BYTE 
XFRW1 DEF * 
      JSB A2BUF     PUT IT INTO THE DESTINATION 
XFRW2 DEF *           STRING
      ISZ XFRCT     ALL BYTES TRANSFERRED?
      JMP XFRL1     NO - TRANSFER NEXT BYTE 
      LDA XFRW1     YES - FETCH UPDATED 
      LDB XFRW2       POINTERS
      JMP XFR,I     RETURN
* 
XFRCT DEC 0         NUMBER OF BYTES TO TRANSFERRED
      SKP 
* * * * * XFRWD - TRANSFER WORDS
* 
*     CALLING SEQUENCE: 
* 
*     LDA <SOURCE ADDRESS>
*     LDB <DESTINATION ADDRESS> 
*     JSB XFRWD 
*     DEC -<NUMBER OF WORDS>
*     <RETURN>
* 
XFRWD NOP 
      STA XFRW1     SAVE THE SOURCE POINTER 
      LDA XFRWD,I   FETCH THE WORD COUNT
      STA XFRCT     SAVE IT 
      ISZ XFRWD     INCREMENT THE RETURN ADDRESS
* 
XFRLA EQU * 
      LDA XFRW1,I   FETCH THE SOURCE WORD 
      STA B,I       PUT IT INTO THE DESTINATION 
      ISZ XFRW1     INCREMENT SOURCE AND
      INB             DESTINATION POINTERS
      ISZ XFRCT     ALL WORDS DONE? 
      JMP XFRLA     NO - DO NEXT WORD 
      JMP XFRWD,I   YES - RETURN
      HED CRC GENERATOR - DATA
A     EQU 0         A-REGISTER
B     EQU 1         B-REGISTER
* 
BINRY EQU 2100B      BINARY I/O FLAG
LEADR EQU 1000B 
STEND EQU 700B      SET END OF TAPE 
* 
CTLRC DEC 3         CONTROL REQUEST CODE
INPRC DEC 1         INPUT REQUEST CODE
OUTRC DEC 2         OUTPUT REQUEST CODE 
EOJRC DEC 6         END OF JOB REQUEST CODE 
STARC DEC 13        STATUS REQUEST CODE 
* 
READR EQU 5         TAPE READER LOGICAL UNIT
PUNCH EQU 4         TAPE PUNCH LOGICAL UNIT 
CONSL EQU 1         CONSOLE LOGICAL UNIT
* 
TTY   DEF CONSL     CONSOLE I/O CODE
RDRIN DEF READR     ASCII INPUT CODE
INBIN ABS READR+BINRY  BINARY INPUT CODE
PCHLU DEF PUNCH     PUNCH CONTROL WORD
PNASC ABS PUNCH       ASCII OUT WITHOUT WAIT
PNBIN ABS PUNCH+BINRY       BINARY OUT WO/WAIT
PNLDR ABS PUNCH+LEADR  PUNCH TAPE LEADER
PNTRL EQU PNLDR     PUNCH TRAILER 
* 
PTR   DEF *         INPUT POINTER 
BLKSZ DEC 0         ROM BLOCK SIZE
NMBLK DEC 0         BLOCK COUNT 
BLKCT DEC 0         BINARY BLOCK COUNTER
CRCHD OCT 0         CRC SAVE WORD 
INCTR DEC 0         INPUT COUNTER 
BUFLN DEC 30        BUFFER LENGTH 
NMCHR DEC -60       NUMBER OF INPUT CHARACTERS
INBUF BSS 30        INPUT BUFFER
NMBYT DEC 0         BYTE COUNTER
INLEN DEC 0         ASCII INPUT LENGTH
EOTFL DEC -1        END OF TAPE FLAG
ADDR  DEC 0         EXPECTED BLOCK ADDRESS
BLKMS OCT 3777      BLOCK ADDR MASK (SET FOR 2K)
* 
ERRM1 ASC 13,**UNEXPECTED END OF TAPE** 
ERRL1 DEC 13        <MESSAGE LENGTH>
* 
EOJMS OCT 6412      END OF JOB MESSAGE - CR/LF
      ASC 7,**END OF JOB**
EOJML DEC 7         <MESSAGE LENGTH>
* 
CKMSG EQU *         CHECKSUM MESSAGE
      ASC 5,CHECKSUM =
CKSM1 EQU *         CHECKSUM VALUE
      ASC 2,
* 
CKMLN DEF *-CKMSG 
.CKM1 DEF CKSM1 
      END 
::
