.title rsxflu flush i/o buffers for file close .ident /4.0.01/ .enabl gbl .psect ; ; ; Copyright (C) 1979, 1980, 1981, 1982, 1983 Brian Nelson ; ; This software is furnished in an as-is ; condition, with no committments of sup- ; port or updates. This software may NOT ; be sold for profit nor can it be includ- ; ed in any package to be sold for profit ; without the written consent of the au- ; thor. This software may be used only ; within the above conditions of use. ; ; The information in contained herein is ; subject to change or revision at any ; time without notice. ; ; inpbuf = inbuf bf$pnt = bufpnt er$sav = errsav by$cnt = recount bl$num = blknum io$sta = iostat section $code e$flus:: $flush::save ; save all temps please mov 2(r5) ,r1 ; channel number asl r1 ; time 2 mov rwfdbl(r1),r2 ; get address of fdb mov bufpnt(r1),r0 ; get the current buffer pointer clr r3 ; clear size of remaining data tst r0 ; anything in the buffer ? beq 20$ ; no tst bl$num(r1) ; get number of next block br 1$ bne 5$ 1$: inc bl$num(r1) ; get number of next block 5$: mov bl$num(r1),r4 ; save number of next block 10$: tst r0 ; even here ? beq 20$ ; yes, do not write extra block add #1000 ,r3 ; increment size of leftovers cmp r0 ,#1000 ; found out how much to dump? blo 20$ ; yes sub #1000 ,r0 ; no, keep looking for < block inc bl$num(r1) ; increment eof data also br 10$ ; and check again 20$: tst r3 ; need to dump last block(s)? beq 30$ ; no calls $putbl ,<@r5,r3,2(r5),r4>; yes, dump remaining data 30$: mov bl$num(r1),f.efbk+2(r2) ; store eof block in fdb mov r0 ,f.ffby(r2) ; and first free byte also mov mx$siz(r1),f.rsiz(r2) ; stuff max recordsize clr bufpnt(r1) ; no longer useful clr bl$num(r1) ; same for block number unsave ; pop temps and exit return ; bye .end