home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG115.ARC
/
RENEXT.MAC
< prev
next >
Wrap
Text File
|
1979-12-31
|
8KB
|
391 lines
;
;>>> although this is written in z80 code it will run on 8080 systems <<<
;
;renext.mac v1.1 04/04/84
;
;original program (v1.0) listed in microsystems, march 1984
;
;by: george m. gallen
; ne software dev
; p.o. box 17622
; philadelphia, pa. 19135
;
;renext takes all files of one extension type and renames them to the same
;filename but with a new extension. ---> renext asm lib <--- would rename all
;.asm files to .lib...... ---> renext b:asm lib <--- would rename all .asm
;files on b: to .lib on b:
;
;------------------------------------------------------------------------------
;
;v1.1 by Simon Ewins, e-mx rcp/m, toronto, ontario, canada.
; (416) 484-9663
;
;04/04/84 - added setting/resetting attributes of final filetypes
; - allowed for stripping of all high bits in filename
; - allowed copying existing bits to final files
; - allowed maintaining .ext high bits only
;
;v1.1 command-line options/structure:
;
;' RENEXT SEXT DEXT /SRC '
;
;where: sext = source extension
; dext = destination extension
; / = options flag
; s = set system attribute on dest file(s)
; r = set read-only attribute on dest file(s)
; c = clear high bits on dest filename(s)
;
;note: the default with no / options at all is to copy all bits from the
; filename as they are and clear high bits on the extension. also,
; it is noted that with this revision, r/o files cannot be renamed.
;
;------------------------------------------------------------------------------
;
;intended to be assembled with m80, l80
;
;------------------------------------------------------------------------------
;
;equates:
;
CR EQU 13
LF EQU 10
BEL EQU 7
CTAIL EQU 80H
BDOS EQU 5
RNM EQU 23
CLOSE EQU 16
OPEN EQU 15
PNTSTR EQU 9
FCB0 EQU 5CH
NUMOPT EQU 3 ;number of options allowed
;
ASEG
.Z80
ORG 100H
;
START: LD HL,0
ADD HL,SP
LD (STACK),HL
LD HL,STKTOP
;save old stack and set new one
;
LD DE,MSG0
LD C,PNTSTR
CALL BDOS
;say hello
;
LD A,(CTAIL) ;number characters enetered in command
PUSH AF ;save it
INC A ;get passed counter byte
LD HL,CTAIL
ADD A,L ;offset to last character of command
LD L,A
XOR A
INC HL
LD (HL),A ;mark end-of line
DEC HL ;reset pointer
POP BC ;get number characters entered
SRCH: LD A,(HL)
CP ' ' ;find first space
JP Z,GSPC ;got it...
DEC HL
DEC B ;keep looking?
JP NZ,SRCH ;yes...
JP BF ;nothing entered so say how to do it
;
GSPC: INC HL ;see if next character is /
LD A,(HL)
CP '/'
JP NZ,START0 ;no options requested
;
LD B,NUMOPT ;get number of possible options
INC HL
;
GETOPT: LD A,(HL)
OR A ;at end?
JP Z,START0
CP 'S'
CALL Z,GOTSYS
CP 'R'
CALL Z,GOTRDO
CP 'C'
CALL Z,GOTCLR
INC HL
DEC B
JP NZ,GETOPT
JP START0
;
SYSFLG: DB 0
RDOFLG: DB 0
CLRFLG: DB 0
;
GOTSYS: LD (SYSFLG),A
RET
;
GOTRDO: LD (RDOFLG),A
RET
;
GOTCLR: LD (CLRFLG),A
RET
;
START0: LD A,(FCB0+1)
CP ' '
JP Z,BF
LD A,(FCB0+17)
CP ' '
JP Z,BF
;check to see if both extensions were supplied
;
LD HL,FCB0+1
LD DE,FCB1+9
LD BC,3
CALL MOVE
LD HL,FCB0+1
LD DE,FCB3+9
LD BC,3
CALL MOVE
;move the source extension to 2 spots
;
LD HL,FCB0+17
LD DE,FCB2+9
LD BC,3
CALL MOVE
;move the destination extension
;
LD A,(RDOFLG)
OR A
JP Z,NORDO
LD A,(FCB2+9)
ADD A,80H ;set read-only
LD (FCB2+9),A
NORDO: LD A,(SYSFLG)
OR A
JP Z,NOSYS
LD A,(FCB2+10)
ADD A,80H ;set system
LD (FCB2+10),A
;set flags as requested (if requested)
;
NOSYS: LD A,(FCB0)
LD (FCB1),A
LD (FCB3),A
LD (FCB5),A
;get and save the drive #
;
RNLOOP: LD HL,FCB3
LD DE,FCB0
LD BC,35
CALL MOVE
LD C,OPEN
LD DE,FCB0
CALL BDOS
;find the first file with the type '????????.[sext]'
;
CP 0FFH
JP Z,ENDIT
;if error=255 then there are no more files with source type so
;program is finished...... exit.
;
LD HL,FCB0+1
LD DE,FCB1+1
LD BC,8
CALL MOVE
LD HL,FCB0+1
LD DE,FCB2+1
LD BC,8
CALL MOVE
;move the filename (now without the '????????') with no extensions
;to the appropriate spot. the extensions were put in place at the
;start of the program.
;
LD C,CLOSE
LD DE,FCB0
CALL BDOS
;close the original file
;
LD HL,FCB2+1
LD DE,FCB5+1
LD BC,11
CALL MOVE
LD HL,FCB3+12
LD BC,23
CALL MOVE
;set up fcb for new file with new extension
;
LD HL,FCB5
LD DE,FCB0
LD BC,35
CALL MOVE
LD DE,FCB0
LD C,OPEN
CALL BDOS
CP 0FFH
JP Z,CONT
;if the file does not exist, then it can be renamed to that name.
;if it does exist then we can't proceed so we quit.
;
LD C,CLOSE
LD DE,FCB0
CALL BDOS
;close up the file, display message and quit
;
LD HL,FCB2+1
LD DE,MSG7
LD BC,8
CALL MOVE
INC DE
LD BC,3
CALL MOVE
;set up message with name & type
;
LD DE,MSG8
JP HOME
;display the message
;
CONT: LD A,(CLRFLG)
OR A
CALL NZ,STRIP
LD C,RNM
LD DE,FCB1
CALL BDOS
;do the rename bdos function using new extension
;
LD HL,FCB1+1
LD DE,MSG3
LD BC,8
CALL MOVE
INC DE
LD BC,3
CALL MOVE
LD HL,FCB2+1
LD DE,MSG4
LD BC,8
CALL MOVE
INC DE
LD BC,3
CALL MOVE
;set up message to show what was just done
;
LD C,PNTSTR
LD DE,MSG1
CALL BDOS
JP RNLOOP
;display message and get next file that matches source type
;
ENDIT: LD DE,MSG5
;we're done so display message and quit
;
HOME: LD C,PNTSTR
CALL BDOS
LD HL,(STACK)
LD SP,HL
RET
;display appropriate message (error, successful, bad format)
;reset stack and return to cp/m
;
BF: LD DE,MSG6
JP HOME
;bad format message
;
;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
;workarea and fcbs
;
FCB1: DB 0
DB '????????'
DB '???'
DB 0,0,0,0
;
FCB2: DB 0
DB '????????'
DB '???'
DB 0,0,0,0
;
FCB3: DB 0
DB '????????'
DB '???'
DB 0,0,0,0,0,0,0,0,0,0
DB 0,0,0,0,0,0,0,0,0,0
DB 0,0,0
;
FCB5: DB 0
DB '????????'
DB '???'
DB 0,0,0,0,0,0,0,0,0,0
DB 0,0,0,0,0,0,0,0,0,0
DB 0,0,0
;
MSG0: DB CR,LF,LF
DB 'RENEXT v1.1 04/04/84'
DB CR,LF,LF,'$'
MSG1: DB 'Rename: '
MSG3: DB ' . --to--> '
MSG4: DB ' . ',CR,LF,'$'
MSG5: DB CR,LF
DB 'Done.....',CR,LF,'$'
MSG6: DB CR,LF
DB '++ BAD COMMAND ++',CR,LF,LF
DB 'Use:',CR,LF,LF
DB 'RENEXT [d:]sext dext /sdrwcn'
DB CR,LF,LF
DB 'where: d: = optional drive'
DB CR,LF
DB ' sext = source extension'
DB CR,LF
DB ' dext = destination extension'
DB CR,LF
DB ' / = options flag'
DB CR,LF
DB ' s = set system attribute on dest file(s)'
DB CR,LF
DB ' r = set read-only attribute on dest file(s)'
DB CR,LF
DB ' c = clear high bits on dest filename(s)'
DB CR,LF,LF
DB 'note: the default with no / options at all is to copy all '
DB 'bits from the'
DB CR,LF
DB 'filename as they are and clear high bits on the extension.'
DB CR,LF
DB 'r/o files cannot be renamed.'
DB CR,LF,LF,'$'
MSG8: DB 'The file: '
MSG7: DB ' . already exists.'
DB CR,LF
DB 'Rename halted, all files may not be renamed.'
DB CR,LF,LF,BEL,'$'
;
MOVE: LD A,(HL)
LD (DE),A
INC HL
INC DE
DEC BC
LD A,B
OR C
RET Z
JP MOVE
;
STRIP: PUSH BC
PUSH HL
PUSH AF
LD B,8
LD HL,FCB2+1
STRIP0: LD A,(HL)
AND 7FH
LD (HL),A
INC HL
DEC B
JP NZ,STRIP0
POP AF
POP HL
POP BC
RET
;
STACK: DB 0,0
DS 32
STKTOP EQU $
;
END
;..............................SJE
,STRIP0
POP AF