From: utzoo!decvax!ucbvax!C70:info-cpm Newsgroups: fa.info-cpm Title: CP/M Blocking and Deblocking Article-I.D.: ucb.1456 Posted: Fri Jul 2 12:34:02 1982 Received: Sat Jul 3 05:13:41 1982 >From ucivax!csuf!bruce@Ucb-C70 Fri Jul 2 12:33:48 1982 Well, I found out why I was having difficulty... WARNING!!!!! To all those who are implementing a BIOS that uses the Blocking/ Deblocking algorithms supplied by Digital Research!!!!! While the bug that I found has been fixed in the copy of the algorithm supplied in DEBLOCK.ASM on the CP/M distribution disk, DR did NOT update the CP/M 2.2 Alteration Guide! I was using the listing printed in the guide when I typed in my BIOS, and did not think to check the copy on the file. As it was, DR's fix takes two instructions, while mine takes only 1, and mine is more efficient! For those of you who are waiting with baited breath (phew!), my fix is as follows: filhst: ;may have to fill the host buffer lda sekdsk ; the desired sector is now the current sector sta hstdsk lhld sektrk shld hsttrk lda seksec sta hstsec lda rsflag ; need to read? ora a cnz readhst ; yes, if non-zero xra a ; no pending write sta hstwrt sta unacnt ; <----- this is my modification - if we get ; here, we can't still be within an unallocated ; block. Digital Research fixed the problem by clearing 'unacnt' EVERY time a read is performed. My fix allows you to read back the sector you just wrote, without forgetting that you're within an unallocated block. Hmmm... come to think of it, my way of doing it may not be right, either. What if you write the first 128 bytes of a sector in an unallocated block, and then read then second 128 bytes? It seems to me that I'll get garbage... oh well, doing a preread on the unallocated block, THEN returning the second 128 bytes will also give you garbage, so I'm not going to worry about it. Actually, neither solution is optimal. What if you write a sector in an unallocated block, then go off and read something elsewhere on the disk, and then come back to write the next sector in the unallocated block? This happens fairly often when you are copying a file from one place to another on the same disk, but normally it happens so rarely that I didn't think it was worth the trouble to implement. In any case, my BIOS now works, so I'm happy... Bruce