home *** CD-ROM | disk | FTP | other *** search
- ; test buffers module. Copy file 1 to file 2
- ; This illustrates use of the .BFSWAP routine for single
- ; buffering, and fast file to file copying.
- ;
- ; d>TEST3 [d[u]:]filename.typ [d[u]:]outname.typ
- ; copies filename.typ to outname.typ
- ; (with full du addressing, across users, drives)
- ;
- ; SEE BUFFERS.DOC for linking instructions
- ;
- boot equ 0
- tfcb equ boot+05ch
- defdma equ boot+080h
- ;
- extrn .dos, b.wflg
- extrn .bload, .bdump, .bfswap
- extrn .bfropen, .fopnw, .bfclose
- extrn .pfnmdu, .xltusr, .initfcb
- ;
- begin: lhld 6; set stack at top of memory
- mvi l,0
- sphl
- ; " "
- ; apportion memory to two file buffers
- lxi d,-buffer-128; 128 byte stack/b.ohead allowance
- dad d; form size of memory available
- mov b,h ! mov c,l; will be rounded down to 128 byte unit
- push b; save buffer size
- ; " "
- ; initialize fcbs
- lxi h,fcbin
- call .initfcb
- lxi h,fcbout
- call .initfcb
- ; " "
- ; mark end of command line, just in case.
- ; Done by most CCPs, but undocumented. CCPLUS is documented
- lxi h,defdma
- mov a,m; line length
- inx h
- add l
- mov l,a
- adc h
- sub l
- mov h,a
- mvi m,0; mark eol
- ; " "
- ; parse the file names
- lxi d,defdma+1; set command scanning pointer
- lxi h,fcbin
- call .pfnmdu; will parse an empty line into
- lda fcbin+1; a blank FCB.
- cpi ' '; could use the open error instead, but
- jz nofile; CPM can create a blank named file
- mov a,b; designated user
- call .xltusr; convert 0 into current, etc
- sta inuser
- mov a,b; but bfropen needs original form
- pop b; get buffer size back
- push d; save input scan pointer
- lxi d,fcbin
- lxi h,buffer
- call .bfropen; open buffered file for read
- jc error; can't find it, abort
- pop d; restore input scan pointer
- lxi h,fcbout
- call .pfnmdu
- lda fcbout+1
- cpi ' '
- jz noutfile
- mov a,b; designated user
- call .xltusr; convert to standard form
- ori b.wflg; essential to flag correctly ** <<< **
- sta outuser; save for future
- lxi d,fcbout
- call .fopnw; open file for write
- jc createrr; can't create file
- ; " "
- ; All files open, and buffers assigned.
- ; Copy fcbin to fcbout in largest possible blocks
- copy: lxi h,buffer
- call .bload; fill the buffer
- push psw; save carry for eof
- lda outuser
- lxi d,fcbout
- call .bfswap; change to write
- sta inuser
- call .bdump; write the buffer out
- jc outerr; error occured
- pop psw; saved eof above
- jc done
- lda inuser; saved above
- lxi d,fcbin
- call .bfswap; return to loading
- sta outuser; save for next switch
- jmp copy; not complete
- ;
- ; done, close output file. No need to fill, using full recds.
- done: call .bfclose
- jnc boot; no close error
- ; " "
- ; all the errors simplified to one message
- outerr:
- createrr:
- error
- noutfile:
- nofile: lxi d,errmsg
- mvi a,9
- call .dos
- jmp boot
- ;
- errmsg: db 'Some sort of error occured$'
- ;
- ; --------- Data Segment --------
- ; Link this AFTER all the code segments
- ;
- dseg
- inuser: ds 1; user # for input file
- fcbin: ds 36; input file fcb
- outuser: ds 1; user # for output file
- fcbout: ds 36; output file fcb
- ;
- ; This must be the last program storage, see linking above.
- ; An alternative is to use a separate dseg file.
- buffer: ds 0; actually rest of memory
- ;
- end
- √