; Copyright (C) 1991 M.J.G. Veltman ; All rights reserved. ; ; This file is part of Vsys, a software development system for the ; M680x0 microprocessor. ; ; Vsys is dual-licensed under the GNU Lesser General Public License and ; the BSD 3Clause License. The aim is to allow the software to be used, ; published, developed, and modified in the unrestrictive style of ; public scientific research, while ensuring that there is always a ; copyleft branch of the software which protects free access to the ; original source and to modifications within that branch. ; ; Vsys is free software. You can redistribute it and/or modify it under ; the terms of the GNU Lesser General Public License as published by the ; Free Software Foundation, either version 3 of the License, or (at your ; option) any later version. See the file LICENSE-LGPL.txt at the top ; level of this distribution, or see: ; ; http://www.gnu.org/licenses/ ; ; You can also redistribute and/or modify Vsys under the terms of the ; BSD 3Clause License. See the file LICENSE-BSD_3Clause.txt at the top ; level of this distribution, or see: ; ; http://opensource.org/licenses/BSD-3-Clause/ ; ; Users who distribute the software with or without modification are ; encouraged to maintain the dual-licensing system. .GLOBL _main .SET BufS=700000 .STRUCTURE BSS .LOCALS Flag,Oown,Otyp,Otime,Otimex,mode .LOCALS Fnam1,Fnam2,Fstatus1,32,Fstatus2,32,Fleng,Line,160,Buf,BufS .EQU bssS=.-BSS .STRUCTURE FILESPEC ; ;Specification file in directory. ; .LOCALS Fnam,16,Ftim,Fali,1,Ftrb,1,Fvar,1 .LOCALS Ftyp,1,Fown,1,Fmod,1,Flen,Frec,2 .TEXT entr: bsr _main |movel D0,-(SP) |bsr .exit ; dlis: .ASCIZ "Dlist" dlip: .ASCIZ "Dlist.t" cpyt: .ASCIZ "cp" txtM: .ASCIZ "No memory granted.\n" txtt: .ASCIZ "Date file %s earlier than that of %s. No copy.\n" txts: .ASCIZ "Date file %s the same at that of %s. No copy.\n" txto: .ASCIZ "Cannot open or empty file %s.\n" txtl: .ASCIZ "File %s too large. No copy.\n" txte: .ASCIZ "Error %d occurred while copying %s to %s.\n" txtc: .ASCIZ "Copied %s to %s, %d bytes.\n" txtd: .ASCIZ "File %s is a directory.\n" ftxt: .ASCIZ "File %s written, %d bytes.\n" txtm: .CPAGE Copyt options Fnam1 Fnam2 Copy file Fnam1 to Fnam2. Copying is only done if date Fnam2 is earlier than that of Fnam1, or if Fnam2 is absent. Options: -s -t If -s: when copy done the number of bytes copied is not reported. If -t: testrun: all is done except the actual copying. @@ .BYTE 0 .EVEN _main: .CALLBR .Getmem(#bssS) |movel D0,A4 addql #1,D0 |bne 8f |lea txtM,A0 |bra errr .ASSUME A4=BSS 8: movel 8(SP),A0 |addqw #4,A0 |clrl D6 clrl D7 |clrl Flag 6: movel (A0)+,D1 |beq cpfi 9: movel D1,A1 |cmpb #"-",(A1)+ |bne 7f 3: moveb (A1)+,D5 |beq 6b |cmpb #"s",D5 |bne 5f bset #7,Flag |bra 3b 5: cmpb #"t",D5 |bne manx |bset #6,Flag |bra 3b manx: lea txtm,A0 |bra errr 7: tstl D6 |bne manx |movel D7,D6 movel D1,D7 |bra 6b ; cpfi: movel D6,Fnam1 |beq manx |movel D7,Fnam2 beq manx |.CALLBR .Fstat(Fnam1,&Fstatus1) tstl D0 |bmi manx |lea Fstatus1,A3 .ASSUME A3=FILESPEC 9: clrl D1 |moveb Fmod,D1 |movel D1,mode moveb Fown,D1 |movel D1,Oown |movel D0,Otyp movel Ftim,Otime |moveq #0x3F,D1 andb Ftyp,D1 |lsrw #3,D1 |beq 2f ;Jmp if file, not directory. lea txtd,A0 |movel Fnam1,A1 |bra errr ; 2: .CALLBR .Fstat(Fnam2,&Fstatus2) tstl D0 |bmi docp .ENDF A3 movel Otime,D6 movel Ftim-FILESPEC+Fstatus2,D7 cmpl D6,D7 |bhi 1f |bne docp |lea txts,A0 |bra 3f 1: lea txtt,A0 3: movel Fnam1,A1 |movel Fnam2,A2 |bra errr ; docp: .CALLBR .Fabsrd(Fnam1,&Buf,#BufS) movel D0,Fleng |bgt 3f movel Fnam1,A1 |lea txto,A0 |bra errr 3: movel #BufS,D1 |cmpl D0,D1 |bgt 4f movel Fnam1,A1 |lea txtl,A0 |bra errr 4: btst #6,Flag |bne 7f .CALLBR .Fabswr(Fnam2,&Buf,Fleng) tstl D0 |bpl 5f |lea txte,A0 |movel D0,A1 movel Fnam1,A2 |movel Fnam2,A3 |bra errr 5: .CALL .Chown(Fnam2,Oown) .CALL .Chtyp(Fnam2,&Otyp) .CALL .Chtim(Fnam2,Otime) .CALL .Chmod(Fnam2,mode) 7: btst #7,Flag |bne 6f .CALLBR .Print(&txtc,Fnam1,Fnam2,Fleng) 6: clrl D0 |rts ; getlin: lea Line,A2 |clrl D1 1: moveb (A0)+,D0 |ble 2f |cmpb #"\J",D0 beq 3f |cmpb #"\M",D0 |beq 3f |moveb D0,(A2)+ addql #1,D1 |bra 1b 3: tstb Flag+3 |bne 4f |moveb D0,Flag+3 4: clrb (A2) |lea Line,A2 |moveb (A2),D0 tstl D1 |beq 6f |cmpb #"@",D0 |bne 5f 6: clrl D0 |rts 5: moveq #1,D0 |rts 2: subqw #1,A0 |tstl D1 |bne 3b moveq #-1,D0 |rts ; errr: .CALLBR .Print(A0,A1,A2,A3) |movel #-1,-(SP) bsr .exit ; .Chtyp: moveq #34,D0 |trap #0 |rts .REXT /usr/minlib/Iolib.a