.MCALL .MODULE .MODULE SPLIT,VERSION=11,COMMENT=,AUDIT=YES ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ; ; EDIT HISTORY ; ; 11-Jul-83 JFW ; 8-Jan-1985 George Thissell ; Allow /B switch to be processed properly ; 010 01-Nov-1990 JFW ; Bracket error messages with ;+/;ERROR/.../;- ; 011 11-Jun-1991 WFG ; ACTION #7479, Add "AUDIT=YES" to .MODULE line .MCall .GtLin .CsiGen .Print .ReadW .WritW .Close .MCall .SReset .CStat .Wait .ReadC .WritC .SetTop .MCall Sob .Assume .Br .Exit ...CMZ ...CMY .MCall .GTim Ident: .Print #ZIdent ; identify program and version Split:: .GTim #GArea ;Ask for time of day to bump date ...CMZ .SReset ; clean up in case of restart Mov #Buffer,R1 ; point to buffer area Add #256.*2,R1 ; allocate area for it Mov R1,Free ; save for CSI request (fetch area) .SetTop R1 ; ask for it Cmp R0,R1 ; got it? Beq 1$ ; yes Jmp NoMem ; no 1$: Mov SP,R5 ; save stack pointer Mov #M,R4 ; point to boundaries area Mov #Buffer,R1 ; R1 -> buffer area Bit #Chain$,@#Jsw ; were we chained to? Beq 5$ ; branch if not Mov #CHAREA,R1 ; R1 -> chain area Br 8$ ; skip GtLin 5$: .GtLin #Buffer,#ZStar ; get command line TstB Buffer ; empty command line? Beq Ident ; yes, just ident the program 8$: .CsiGen Free,#DefExt,R1 ; parse the command line Bcs IllCmd ; illegal command .CStat #CArea,CODE=NOSET ; check input file Mov R4,R0 ; copy pointer Mov #-1,(R0)+ ; assume biggest M .Assume M+2 EQ N Mov #-1,(R0)+ ; assume biggest N Mov R4,R1 ; copy pointer Mov (SP)+,R2 ; get switch count Beq NoSwit ; none specified DoSwit: Mov #Chars,R3 ; point to char constants Mov (SP)+,R0 ; get switch letter CmpB R0,(R3)+ ; /H[elp]? Beq Help ; yes CmpB R0,(R3)+ ; /h[elp]? Beq Help ; yes CmpB R0,(R3)+ ; /2 (half)? Beq Bisect ; yes CmpB R0,(R3)+ ; /B[oundary]? Beq Bound ; no, unknown switch CmpB R0,(R3)+ ; /b[oundary]? Bne BadSwi ; no, unknown switch Bound: Tst R0 ; value specified? Bpl NoVal ; no, error Mov (SP)+,(R1)+ ; copy it into boundaries area Cmp R1,#O ; still in area? Bhi TooVal ; no, too many values Sob R2,DoSwit ; do all the switches Br Sort ; go sort the values Bisect: ; just cut it in half Mov O,M ; copy length Cmp O,#2 ; big enough to divide by 2? Blo TooSml ; no Asr M ; and divide by 2 Sort: Mov #N,R0 ; which is smaller? Call Order Mov #O,R0 ; which is smaller? Call Order Bcs Sort ; check again .Br CkInp CkInp: .Wait #In1 ; is there an input file? Bcs NoIFil ; no input file Clr R2 ; init channel to 0 10$: Mov -2(R4),R3 ; init input block number .Wait R2 ; is this channel open? Bcs 30$ ; no, try next one MovB R2,WChan ; supply current channel number Clr WBlock ; clear output block number 20$: ;;; .ReadW #Area,#In1,#Buffer,#256.,R3 ; get a block Mov R3,RBlock ; supply current block number .ReadC #RArea,CODE=NOSET ; get a block Bcs InErr ; error Inc R3 ; next input block number ;;; .WritW #Area,R2,,,R1 ; write it out .WritC #WArea,CODE=NOSET ; write it out Bcs OutErr Inc WBlock ; next output block number Cmp R3,@R4 ; got to a boundary? Blo 20$ ; no, continue .Close R2 ; yes, close output file 30$: Tst (R4)+ ; point to next boundary Inc R2 ; next channel number Cmp R2,#Out3 ; done Blos 10$ ; no, try next Br Split1 ; get next command Order: Cmp @R0,-(R0) ; are they in order? Bhis 10$ ; yes, ascending Mov (R0)+,-(SP) ; exchange them Mov @R0,-(R0) Mov (SP)+,2(R0) 10$: ; Carry set == exchange done Return Help: Mov #ZHelp,R1 Br Print ; print, reset stack, ask for command ;+ ;ERROR NoMem: Mov #ZNoMem,R1 Br Error BadSwi: Mov #ZBadSw,R1 Br Error IllCmd: MovB @#ErrByt,R0 ; load the error byte Asl R0 ; make into word index Mov CsiErr(R0),R1 Br Error InErr: Mov #ZInErr,R1 Br Error NoIFil: Mov #ZNoIFi,R1 Br Error NoSwit: Mov #ZNoSwi,R1 Br Error NoVal: Mov #ZNoVal,R1 Br Error OutErr: Mov #ZOutEr,R1 Br Error TooSml: Mov #Z2Smal,R1 Br Error TooVal: Mov #Z2Val,R1 .Br Error Error: ;- .Print #ZPrefx ; print error prefix Print: .Print R1 ; print message Mov R5,SP ; restore stack Split1: ...CMY Bit #Chain$,@#Jsw ; were we chained to? Beq 10$ ; Branch if not .Exit 10$: Jmp Split ;+ ;ERROR CsiErr: .Word ZIllCm,ZIllDv,ZProtF,ZFull,ZFNF ;- .CStat =: 27 .GTim =: 21 .Read =: 10 .Write =: 11 CArea: .Byte In1,.CStat ; .CStat request block .Word ChStat ; answer area GArea: .Byte 0,.GTim ; .GTim request block .Word ChStat ; answer area (answer ignored) RArea: .Byte In1,.Read ; .ReadW request block RBlock: .BlkW 1. ; block number .Word Buffer ; buffer address .Word 256. ; buffer size .Word 0 ; Wait type request WArea: ; .WritW request block WChan: .BlkB 1. ; Channel number .Byte .Write ; request code WBlock: .BlkW 1. ; block number .Word Buffer ; buffer address .Word 256. ; buffer size .Word 0 ; Wait type request Charea =: 522 ; Chain info area (skipping return program ; which SPLIT currently doesn't support) Jsw =: 44 ; Job Status Word Chain$ =: 400 ; Chain bit in jsw ErrByt =: 52 ; RT-11 error byte in SysCom LF =: 012 CR =: 015 NoCrLf =: 200 ; do not append CR LF .NList BEX Chars: .Ascii "Hh2Bb" ;chars for switch match code ZHelp: ; help text .Ascii "Program to split a file into several files on block boundaries." .Ascii "A,B,C=D/B:m:n A=D[0:m-1]; B=D[m:n-1]; C=D[n:end]" .Ascii " Where D[x:y] means blocks x thru y from D." .Ascii " Any output file may be omitted." .Ascii "A,B=C/2 A=C[0:end/2-1]; B=C[end/2:end]" .Asciz "/H HELP" ZStar: .Ascii "*" ; prompt string ZIdent: .NlCsi ; program name and version ZPrefx: .NlCsi TYPE=I,PART=PREFIX ; prefix .Ascii "E-" ;+ ;ERROR ZBadSw: .Asciz "Unknown option" ZIllCm: .Asciz "Invalid command" ZIllDv: .Asciz "Invalid device" ZProtF: .Asciz "Output file protected" ZFull: .Asciz "Output device full" ZFNF: .Asciz "Input file not found" ZInErr: .Asciz "Input error" ZNoIFi: .Asciz "No input file" ZNoMem: .Asciz "Insufficient memory" ZNoSwi: .Asciz "An option must be specified" ZNoVal: .Asciz "/B requires a value (or 2)" ZOutEr: .Asciz "Output error" Z2Smal: .Asciz "Input file too small" Z2Val: .Asciz "Too many values for /B" ;- .Even DefExt: .Rad50 " " ; no default extensions ; last word in DefExt is used as L: and is 0 ChStat: .BlkW 6. L =: ChStat-2 M =: ChStat+0 N =: ChStat+2 O =: ChStat+4 ; file size from ChStat Free: .BlkW 1 Out1 =: 0 Out2 =: 1 Out3 =: 2 In1 =: 3 Buffer: .End Split