home *** CD-ROM | disk | FTP | other *** search
- ;This file is freeware copyright (c) MUFTI
- ;written with TLA
- ;formula is preprocessor and M4 is the preprocessor of the preprocessor 8-)
- B start
- ; formulaconfiguration:
- ; formulatempregistersave FALSE
- ; formulastackregistersave FALSE
- ; formulastacklength 100.
- ;M4-commands
- ;define(filenamelength,255)
- ;define(commandlinelength,255)
- ;define(argvindex,R8)
- ;define(commandlineindex,R9)
-
-
-
-
- ; program related data
- ;CHAR filename[filenamelength+1]
- .ALIGN
- ;CHAR outfile[filenamelength+1]
- .ALIGN
- ;CHAR command[256]
- .ALIGN
- ;CHAR commandline[commandlinelength+1]
- .ALIGN
- ;INT infilehandle
- ;INT outfilehandle
-
- ;DECLARE INT bput2(INT filehandle,CHAR character)
-
- .MACRO bput2
- LDR R0,[stackregister,`#'%3]
- LDR R1,[stackregister,`#'%2]
- SWI OS_BPut
- .ENDM
-
- ;INCLUDE <formula$dir>.function_h
-
- ; task-related data
- task .WORD 4B534154
- descr .STRING "join"
- .ALIGN
- descrptr .WORD descr
- ;INT taskdata[64]
- taskdataptr .WORD taskdata
-
- start
- ;LET system("wimpslot -min 8K -max 8K")
- MOV R0,`#'200.
- LDR R1,task
- LDR R2,descrptr
- SWI Wimp_Initialise
- ;SAVE R5
- MOV R5,R1
-
- ;LET getargv(commandline)
- ;LET commandlineindex=0
- ;LET argvindex=0
-
- ;WHILE (commandline[commandlineindex]!=0)
-
- ; skip spaces
- ;WHILE ((commandline[commandlineindex]!=0) && (commandline[commandlineindex]==32))
- ;LET commandlineindex=commandlineindex+1
- ;ENDWHILE
-
- ; copy argument
- ;LET R3=0
- ;WHILE ((commandline[commandlineindex]!=0) && (commandline[commandlineindex]!=32))
- ;LET filename[R3]=commandline[commandlineindex]
- ;LET R3=R3+1
- ;LET commandlineindex=commandlineindex+1
- ;ENDWHILE
- ;LET filename[R3]=0
- ;FREE R3
-
- ;IF (argvindex==1)
- ;LET outfilehandle=open(filename)
- ;LET close(outfilehandle)
- ;LET strcpy(command,"DELETE ")
- ;LET strcat(command,filename)
- ;LET system(command);
- ;LET outfilehandle=open(filename)
- ;ENDIF
-
- ;IF ((argvindex>1) && (filename[0]!=0))
- ;LET infilehandle=open(filename)
- ;LET R4=0
- ;WHILE (eof(infilehandle)==0)
- ;LET bput2(outfilehandle,bget(infilehandle));
- ;IF (R4==10)
- MOV R0,`#'0
- LDR R1,taskdataptr
- SWI Wimp_Poll
- ;SAVE R0
- ;IF ( (R0==18) && ((taskdata[4]==0) || (taskdata[4]==8)) )
- ;LET close(infilehandle)
- B closedown
- ;ENDIF
- ;LET R4=0
- ;FREE R0
- ;ENDIF
- ;LET R4=R4+1
-
- ;ENDWHILE
- ;FREE R4
- ;LET close(infilehandle)
- ;ENDIF
-
- ;LET argvindex=argvindex+1
-
- ;ENDWHILE
- closedown
-
- MOV R0,R5
- LDR R1,task
- SWI Wimp_CloseDown
-
- ;IF (argvindex<=1)
- ;LET writestr("syntax: join outputfile inputfile1 inputfile2 ... inputfileN")
- cr
- ;LET writestr("joins N inputfiles into outputfile")
- cr
- ;LET writestr("cooperative wimp-\"multitasking\", if started by a obeyfile")
- cr
- ;LET writestr("This file is Freeware Copyright (c) MUFTI")
- cr
- ;ENDIF
-
- ;LET close(outfilehandle)
- SWI OS_Exit
- .END
-