; test buffers module. Copy file 1 to file 2 ; This does a totally unnecessary double buffering, in order ; to illustrate use of the package and linking methods to ; keep a maximum memory area available. ; ; d>TEST2 [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.ohead extrn .bfgetc, .bfputc extrn .bfropen, .bfwopen, .bfclose extrn .pfnmdu, .initfcb ; begin: lhld 6; set stack at top of memory mvi l,0 sphl ; " " ; apportion memory to two file buffers lxi d,-inbuff-128; 128 byte stack/b.ohead allowance dad d; form size of memory available mov a,h ora a rar mov b,a; 1/2 space to buffers size mov a,l; will be rounded down rar mov c,a; 1/2 space to buffer size lxi h,inbuff shld @inbuff dad b lxi d,b.ohead; input space + 12 dad d shld @outbuff; form outbuffer pointer 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 ' ' jz nofile mov a,b; designated user pop b; get buffer size back push b; re-save buffer size push d; save input scan pointer lxi d,fcbin lhld @inbuff call .bfropen; open buffered file for read jc error; can't find it, abort pop d; restore input scan pointer push b; save size again lxi h,fcbout call .pfnmdu lda fcbout+1 cpi ' ' jz noutfile mov a,b; designated user pop b lxi d,fcbout lhld @outbuff call .bfwopen; open buffered file for write jc createrr; can't create file ; " " ; All files open, and buffers assigned. ; Copy fcbin to fcbout byte by byte. copy: lhld @inbuff call .bfgetc; get a byte jc done; eof mov c,a lhld @outbuff; Every byte passes thru here, so call .bfputc; that any desired filters can be jc outerr; implemented here. jmp copy ; ; done, close output file done: lhld @outbuff 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 fcbin: ds 36; input file fcb fcbout: ds 36; output file fcb @inbuff: ds 2; pointer to input buffer @outbuff: ds 2; pointer to output buffer ; ; This must be the last program storage, see linking above. ; An alternative is to use a separate dseg file. inbuff: ds 0; actually 1/2 of remainder ; end