extrn .nilchk, .sdem, b.cnt ; ; .binit, but ensure size is a multiple of 128 ; a,f,c .bfinit:: push psw mov a,c ani 080h mov c,a; round down to 128 byte multiple pop psw ; " " ; initialize buffer hl^ to empty, size bc, attach file de^ ; set initial flags (lo byte only) to a, clear hi byte. ; For file reads the initial flag should be 0, for write 1. ; a,f .binit:: call .nilchk ! rc; error, no buffer specified mov m,a ! inx h mvi m,0 ! dcx h; set initial flags mov a,b ! ora c stc ! rz; error, buffer size 0 push d ! push h inx h ! inx h mov m,c ! inx h mov m,b ! inx h; set size call .sdem; save fcb pop h ! pop d ; " " ; Set pointers back to start for aligned read/writes. ; Flush any data in buffer. Return a=0 and z flag. ; a,f .bflush:: call .nilchk ! rc push d ! push h lxi d,b.cnt ! dad d; point to cnt field lxi d,0 call .sdem; zero bytes available call .sdem; set rd ptr to 1st address call .sdem; set wrt ptr to 1st address pop h ! pop d xra a; signal flushed ret