; ; --------------------------------------------------- ; read a record, refill buffer if empty ; ; Buffer is empty - read in another block of 16k ; rdblock: lda eoflg; Get 'EOF' flag cpi 1; Is it set? stc; To show 'EOF' rz; Got 'EOF' call rdblk1 ; " " ; Update record read ; rdrecd: lda recnbf; See how many records in the buffer ora a jz rdblock; If none, go get some lda kflg; Using 1k blocks? ora a jz rdrec1; If not, exit ; " " ; Using 1k blocks, switch to 128 if less than 8 records left lda recnbf; See how many records in buffer sui 8 jnc rdrec2; If 8 or more stay in 1k blocks xra a; Else there are 1-7 records left sta kflg; Reset the 1k flag for 128 rdrec1: lda recnbf; Get number of records in buffer dcr a; Decrement it for 128 character blocks rdrec2: sta recnbf; Store the new value ret ; ; Read up to 16k from the disk file into the buffer, ready to send ; rdblk1: mvi c,0; Records in block lxi d,dbuf; To disk buffer rdreclp: push d mvi a,stdma; Set DMA address call dos mvi a,read call fileop pop d ora a; Read ok? jnz reof; If not, error or end of file lxi h,128; Add length of one record dad d; To next buffer xchg; Buffer to 'DE' inr c; More records? mov a,c; Get count cpi bufsiz*8; Done? jnz rdreclp; Read more jmp ioexit; buffer full or got eof ; reof: dcr a jnz rderr; Not 'EOF' mvi a,1 sta eoflg; Set EOF flag mov a,c jmp ioexit ; ; Read error ; rderr: call erxit db '++ File read error ++','$' ; ; end of read record routine ; ----------------------------------------------- ; ; Writes the record into a buffer. If/when 16k has been written, ; writes the block to disk. ; ; Entry point "WRBLOCK" flushes the buffer at EOF ; wrrecd: lhld recptr; Get buffer address call grcdsz; 128/1024 on kflg dad d; To next buffer shld recptr; Save buffer address lda kflg; Using 1k blocks? ora a jz wrrec1; If not, exit lda recnbf; Get number of records in buffer adi 8; Increment it 8 records for 1k jmp wrrec2 ; wrrec1: lda recnbf; Get number of records in buffer inr a; increment it for 1 record wrrec2: sta recnbf; Store the new value cpi bufsiz*8; Is the buffer full, yet? rnz; No, return ; " " ; Writes a block to disk ; wrblock: lda recnbf; Number of records in the buffer ora a; 0 means end of file rz; None to write mov c,a; Save count lxi d,dbuf; Point to disk buff dkwrlp: push d mvi a,stdma; Set DMA call dos; To buffer mvi a,write call fileop; then write the block pop d ora a jnz wrerr; Oops, error lxi h,128; Length of 1 record dad d; 'HL'= next buff xchg; To 'DE' for setdma dcr c jnz dkwrlp; More records xra a; Get a zero ; " " ; exit from i/o operations ioexit: sta recnbf; Reset number of records lxi h,dbuf; Reset buffer buffer shld recptr; Save buffer address call dskstp; stop any disks spinning ; " " rsdma: lxi d,tbuf; Reset DMA address mvi a,stdma jmp dos ; wrerr: call rsdma; Reset DMA to normal call send3can; cancel sender call rcvsabt; Kill receive file call erxit; Exit with msg: db '++ Error writing file ++','$' ; ; File operation (a) on FCB ; a,f,d,e fileop: lxi d,fcb jmp dos ;