;*; Updated on 09-Nov-90 at 12:34 PM by Paul Ciosek; edit time: 0:00:31 ;*************************** AMUS Program Label ****************************** ; Filename: CONCAT Date: 11/9/90 ; Category: UTIL Hash Code: 553-611-565-747 Version: ? ; Initials: EESS/AM Name: CREED ERICKSON ; Company: Telephone #: ; Related Files: ; Min. Op. Sys.: Expertise Level: ADV ; Special: ; Description: concatenates files ; ; ;***************************************************************************** ;*; Updated on 31-Oct-90 at 7:02 AM by Creed A. Erickson; edit time: 0:31:33 ;*; Created on 17-Oct-90 at 9:44 PM by Creed A. Erickson; edit time: 0:20:02 ;************************************************************************ ; * ; CONCAT.M68 - AlphaBASIC XCALL to concatenate files together. * ; * ;************************************************************************ ; ; COPYRIGHT (c) 1990, Creed A. Erickson. ; All rights reserved. ; ; Edit History: ; ;[100] 10/17/90 Designed and implemented by Creed A. Erickson. ; ; USAGE: ; ; XCALL CONCAT, OUTPUT'CHAN, INPUT'CHAN1, INPUT'CHAN2....INPUT'CHANn ; ; Any number of file channels be passed (but must pass at least 2). ; If only one input file channel is specified, a simple copy is performed. ; ; For example: ; ; OPEN #1, "OUTPUT.DAT", OUTPUT ; OPEN #2, "INPUT1.DAT", INPUT ; OPEN #3, "INPUT2.DAT", INPUT ; XCALL CONCAT, 1, 2, 3 ; CLOSE #1 ; CLOSE #2 ; CLOSE #3 ; ; This example will cause INPUT1.DAT and INPUT2.DAT to be concatenated ; together into OUTPUT.DAT. ; ; NOTE: Reassembly of this file requires SBRSYM.M68 which is part of the ; AMOS 2.x distribution but (to my knowledge) not part of the AMOS 1.x ; distribution. ; SEARCH SYS ; Standard AM defs, etc. SEARCH SYSSYM ; More AM defs, etc. COPY SBRSYM.M68 ; Std SBR arg list offsets. EXTERN $FLSET, $GTARG VMAJOR = 1 ; Major version number. VMINOR = 0 ; Minor version number. VEDIT = 100. ; Edit level number. OBJNAM 0, 0, [SBR] ; Assembled file becomes xxxxxx.SBR ;*********** ; CONCAT * ;*********** ; CONCAT: PHDR -1, 0, PH$REE!PH$REU ; SBR is reentrant & reusable. CMPW ARGCNT(A3), #2. ; At least 2 file arguments passed? BLO 99$ ; No, forget the whole thing. ; Get A1 to index the output DDB. ; MOV #A1.TYP, D1 ; Index the first argument. CALL $GTARG ; Get the channel number. CALL $FLSET ; Index the output DDB. MOV A2, A1 ; Move to the right register. ; Set up the loop constants for the rest of the arguments. ; MOV #A1.TYP, D3 ; Preset offset to arg #1. ; It will be bumped in loop body. MOVW ARGCNT(A3), D4 ; Get the argument count. SUBW #<1+1>, D4 ; Adj for arg we have and DBF. ; Loop through the rest of the arguments assuming they are file channel #s. ; At this point: ; ; A3 <= AlphaBASIC XCALL argument list. ; D4 := Count of field # args to process (DBF adjusted). ; D3 := Offset from A3 to last argument entry processed. ; D2 := Flag value (True/False). ; 10$: ADD #, D3 ; Bump to next arg. MOV D3, D1 ; Put offset in proper register. CALL $GTARG ; Get the channel number. BNE 20$ ; Bypass if bad argument. CALL $FLSET ; Get the DDB index. BNE 20$ ; Bypass if bad file channel #. BCALL CPYFIL ; Copy the file. TSTB D.ERR(A1) ; Destination file error? BNE 99$ ; Yes, all done. TSTB D.ERR(A2) ; Source file error? BNE 99$ ; Yes, all done. 20$: DBF D4, 10$ ; Loop for all files. ; All done, return to AlphaBASIC. ; 99$: RTN ; All done. ;*********** ; CPYFIL * ;*********** ; Copy an input file to the output DDB. ; ; Passed: ; ; A1 => Output (destination) DDB. ; A2 => Input (source) DDB. ; ; Returned: ; ; D.ERR of the offending DDB contains error code, if any. ; ; CPYFIL: FILINB @A2 ; Get a byte from the source. TST D.SIZ(A2) ; End of file? BEQ 99$ ; Yes, all done. FILOTB @A1 ; Output to the destination. BR CPYFIL ; Loop for next. 99$: RTN ; Return to caller. END .