home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
UNIFLEX
/
UNIFLEX
/
UniFLEX_Std.Utils1.tar.Z
/
UniFLEX_Std.Utils1.tar
/
utils1
/
mu-flex
< prev
next >
Wrap
Text File
|
1981-09-01
|
9KB
|
434 lines
opt pag
ttl FLEX Copy and Directory
pag
* FLEX Copy and Directory Utility
*
* Copyright (c) 1980 by
* Technical Systems Consultants, Inc.
* Box 2570, West Lafayette, IN 47906
*
* This utility runs under UniFLEX and when called
* with no parameters, performs a directory listing
* of the FLEX disk in drive #1. If filenames are
* given, it will copy the specified FLEX file to
* the specified UniFLEX file. The FLEX disk must
* be single-density and in drive #1.
* Syntax is as follows:
*
* ++ flex <FLEX filename> <UniFLEX filename> [+r]
*
* where the <FLEX filename> defaults to an extension of
* .TXT. The optional "+r" parameter causes the file to
* be copied in a raw mode (no space expansion). All
* FLEX random files will be automatically copied in the
* raw mode with the sector map sectors removed.
info UniFLEX flex
info Version 1, Released August 25, 1980
info Copyright, (C) 1980, by
info Technical Systems Consultants, Inc.
info All rights reserved.
* equates
indx equ 1
term equ 5
open equ 10
create equ 11
read equ 12
write equ 13
seek equ 14
status equ 28
org $0000
* start of program
flex ldx #obuf initialize output
stx obfptr
clr raw clear raw copy flag
clr lastch null last character
* ensure single user mode
* sys status,utmp,rdbuf
* bes stater
* ldd rdbuf+11
* beq opnrd skip if single user
*stater ldx #mumode else, report error
* lbra pexit
* open flex disk for read
opnrd ldx #iopen point to indirect open
sys indx do indirect open
lbes ferror
std ifd save input file descriptor
* see if copy or dir
ldd 0,s get argument count
cmpd #1 no parameters means dir
lbeq dir
cmpd #4 4 means copy w/ option
bne lookup skip if no option
ldd [8,s] get option
cmpd #$2B72 is it "+r" for raw?
bne lookup skip if not
stb raw set flag
* look for flex file in directory
lookup ldd #$0005 directory start T&S
std rdbuf put in fwd link
ldu #rdbuf+256 directory pointer
look lbsr nxtent check next entry
lbeq notfnd skip if end of dir
lbsr compar found file entry?
bne look loop if not
* found flex file, create uniflex file
opnwrt ldx #icreat point to indirect create
ldy 6,s get filename pointer
sty 1,x put in indirect function
sys indx do indirect create
lbes uerror
std ofd save output file descriptor
* check flex file for random (file sector map)
lda 19,u get random indicator
beq look2 skip if sequential
lda #2 set sector skip count
sta raw force raw mode copy
look2 sta rnd
ldd 13,u get start T&S
std rdbuf set into fwd link
skprnd tst rnd past file sector map?
beq copy
lbsr sread read one flex sector
dec rnd decrement skip count
bra skprnd
* copy file to UniFLEX
copy ldu #wrtbuf set buffer pointer
copy1 ldd rdbuf check forward link
lbeq copy8 finished if zero
lbsr sread read one sector
ldx #rdbuf+4
ldb #252
tst raw doing raw copy?
bne copy5 skip if so
lda lastch get last character
copy2 cmpa #$09 was last char a tab?
bne copy3
pshs b
ldb 0,x+ get expansion count
lda #$20 setup space
expand sta 0,u+ put spaces in buffer
decb
bne expand
puls b
bra copy4
copy3 lda 0,x+ get character
beq copy4 strip nulls
cmpa #$09 strip tabs
beq copy4
sta 0,u+ put in write buffer
copy4 decb
bne copy2
sta lastch save last character
bra copy6
copy5 lda 0,x+ get character from flex
sta 0,u+ put in write buffer
decb
bne copy5
copy6 cmpu #hotzne is buffer full
blo copy1 get more if not
lbsr flush flush write buffer
bra copy1 continue
copy8 lbsr flush flush write buffer
ldx #cpycom print "copy completed"
lbsr pdata
ldd #0
sys term terminate task
*********************************
* directory printer
*********************************
dir ldx #dirhd print dir header
lbsr pdata
ldd #$0005 directory start T&S
std rdbuf put in fwd link
ldu #rdbuf+256 directory pointer
dir2 lbsr nxtent check next entry
beq dir8 exit if end of dir
clrb
dir3 lda b,u get a character
lbsr outch print it
incb bump count
cmpb #8 at end of name?
bne dir3
lda #'. output period
lbsr outch
dir4 lda b,u get character
lbsr outch
incb
cmpb #11 at end of extension?
bne dir4
ldd 17,u get file size
lbsr outdec output decimal value
lda #$0D
lbsr outch
bra dir2 do next entry
dir8 lda #$0D
lbsr outch
ldd #0
sys term terminate task
* routine to point to next flex directory entry
nxtent leau 24,u get to next entry
cmpu #rdbuf+256 past buffer end?
blo nxten2 skip if so
ldd rdbuf check forward link
beq nxten9 exit if end of directory
lbsr sread read next directory sector
ldu #rdbuf+16 set pointer
nxten2 lda 0,u check first character
bmi nxtent if deleted entry, try again
nxten9 rts
* compare file name to directory entry
compar ldx 6,s point to supplied name
leay 0,u get dir entry pointer
ldb #8 set name length
compr1 lda 0,x+ get character
beq compr3
cmpa #'. at the extension?
beq compr2 skip if so
cmpa 0,y+ compare to dir entry
bne compr9 exit if not equal
decb
bne compr1
lda 0,x+ get next character
beq compr3
cmpa #'. should be period
bne compr9 exit if not
* check supplied extension
compr2 bra compr4 go compare it
* check default extension
compr3 ldx #dfault point to default ext
compr4 tstb at end of entry?
beq compr5 skip if so
lda 0,y+ check next character
bne compr9
decb
bne compr4
compr5 ldb #3 set extension length
compr6 lda 0,x+
bne compr7
leax -1,x
compr7 cmpa 0,y+ compare to entry
bne compr9 exit if not same
decb
bne compr6
compr9 rts
* read one sector from flex
sread ldx #iseek point to indirect seek
ldd rdbuf get track & sector address
beq sread9
std 3,x setup trk & sct for seek
ldd ifd get input file descriptor
sys indx do indirect seek
lbes ferror
ldd ifd get input file descriptor
sys read,rdbuf,256 read one sector
lbes ferror
sread9 rts
* routine to flush the write buffer
flush ldx #iwrite point to indirect write
tfr u,d get buffer end pointer
subd #wrtbuf find size of buffer
std 3,x put in indirect function
ldd ofd get output file descriptor
sys indx do indirect write
lbes uerror
ldu #wrtbuf reset buffer pointer
rts
* output value in D in decimal
outdec ldx obfptr get output buffer ptr
pshs a
lda #$20 setup leading space
sta 0,x+ save in buffer
puls a
clr 0,-s set up bookkeeping
clr 0,-s
ldy #conlst point to constants
decst4 cmpd 0,y compare number to constant
blo decst5
subd 0,y do subtraction of constant
inc 1,s bump digits counter
bra decst4
decst5 pshs a save number
tst 2,s zero digit?
bne decst6
tst 1,s any numbers output yet?
bne decst6
lda #$20 set up space
bra decst7
decst6 lda 2,s get digit count
inc 1,s set 'got one' flag
ora #$30 make ascii
decst7 sta 0,x+ save in buffer
decst8 puls a reset number
clr 1,s clear out digit
leay 2,y bump constant ptr
cmpy #conend end of list?
bne decst4
leas 2,s clean up stack
orb #$30 make last digit
stb 0,x+ save in buffer
stx obfptr update buffer pointer
rts
* print a string of characters
pdata lda 0,x+
beq pdata2
bsr outch
bra pdata
pdata2 rts
* output a character
outch pshs d,x
tsta replace blank with space
bne outch1
lda #$20
outch1 ldx obfptr point to buffer
sta 0,x+ put character in
stx obfptr
cmpa #$0D was it a return?
bne outch9 exit if not
* flush the terminal output buffer
ldd obfptr find no. of chars.
subd #obuf
ldx #iprint
std 3,x
ldd #1 standard output file
sys indx do indirect write
ldx #obuf restore buffer pointer
stx obfptr
outch9 puls d,x,pc
* file not found
notfnd ldx #ntfnds print file not found
* error handlers
pexit bsr pdata print string
ldd #$00FF
sys term
uerror ldx #uermsg
bra error
ferror ldx #fermsg
error pshs d,x save error no. & msg. address
ldx #err print error header
bsr pdata
ldd 0,s restore error number
lbsr outdec print the number
ldx 2,s get message address
bsr pdata
puls d,x restore error number
sys term
* strings and names
dfault fcc 'TXT'
devnam fcc '/dev/fdc1',0
utmp fcc '/act/utmp',0
dirhd fcc $D,'Directory of FLEX disk',$D
fcc 'Name Ext Size',$D
fcc '---- --- ----',$D,0
cpycom fcc $D,'Copy completed.',$D,0
mumode fcc $D,'Must be in single-user mode.',$D,0
ntfnds fcc $D,'FLEX file not found.',$D,0
err fcc $d,'UniFLEX error',0
uermsg fcc ' with UniFLEX file.',$d,0
fermsg fcc ' with FLEX file.',$d,0
* constants for convert
conlst fdb 10000
fdb 1000
fdb 100
fdb 10
conend equ * end of list
org (*+511)&!511
* read buffer
rdbuf rmb 256
* console output buffer
obuf rmb 128
* temporary storage
iopen fcb open
fdb devnam,0
icreat fcb create
fdb 0,$1B
iseek fcb seek
fdb 0,0,0
iwrite fcb write
fdb wrtbuf,0
iprint fcb write
fdb obuf,0
rnd rmb 1
raw rmb 1
lastch rmb 1
ifd rmb 2
ofd rmb 2
obfptr rmb 2
org (*+511)&!511
* write buffer
wrtbuf equ *
org $1FFF
wbfend fcb 0
hotzne equ wbfend-1023
end flex