home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
enterprs
/
c128
/
text
/
examples.arc
/
COPY.A
< prev
next >
Wrap
Text File
|
1989-12-01
|
5KB
|
137 lines
;copy.asm
;====================================
; Command: copy source destination
;====================================
index1 = $0024
maxmem = $0039
status = $0090
sa = $00b9
dv = $00ba
int08 = $1708
int09 = $1709
int0e = $170e
primm = $ff7d
tksa = $ff96
second = $ff93
talk = $ffb4
listen = $ffb1
acptr = $ffa5
untlk = $ffab
unlsn = $ffae
close = $ffc3
clrchn = $ffcc
chrin = $ffcf
chrout = $ffd2
chkin = $ffc6
chkout = $ffc9
star = $0b00
.wor star
* = star
jmp imove
dw Date
imove lda #"p" ;open source file for read...try PRG first
sta srctyp
ldx #1
jsr int08
bcc im0 ;open went ok
cmp #64 ;file type mismatch?
bne im1 ;no...exit
txa
jsr close ;close it and try again
ldx #1
lda #"s" ;maybe it wasn't PRG, try SEQ
sta srctyp
jsr int08
bcc im0 ;ok
im1 jsr primm
.asc 13,"Syntax: copy s:name d:name",13
.byt 0
jmp int0e
im0 stx srcla
lda srctyp ;now open destination file
ldx #2
jsr int09
bcs im1 ;error...abort
stx desla
move lda #0
sta stat ;st=0
jsr getbuf ;move to buffer
jsr putbuf ;buffer to destination
bit stat
bmi movx
bvc move ;end if eof
movx jmp int0e
desla .byt 0
srcla .byt 0
srctyp .byt 0
buflen .wor 0
stat .byt 0
getbuf jsr resbuf ;point to start of buffer
sty buflen
sty buflen+1
sty status
ldx srcla
jsr chkin
gb jsr chrin
sta $ff02
ldy #0
sta (index1),y
sty $ff00
jsr bindex
inc buflen
bne gb1
inc buflen+1
gb1 bit status
bmi gb2
bvs gb2
lda index1+1
cmp maxmem+1
bcc gb
lda index1
cmp maxmem
bcc gb
gb2 lda status
sta stat
jmp clrchn
putbuf jsr resbuf
ldx desla
jsr chkout
pb0 lda buflen
ora buflen+1
bne pb
jmp clrchn
pb sta $ff02
ldy #0
lda (index1),y
sty $ff00
jsr chrout
jsr bindex
lda buflen
bne pb1
dec buflen+1
pb1 dec buflen
jmp pb0
resbuf lda #<$4000
sta index1
lda #>$4000
sta index1+1
ldy #0
rts
bindex inc index1
bne bix
inc index1+1
bix rts
.end