• Please review our updated Terms and Rules here

How to lock out bad sector

archeocomp

Experienced Member
Joined
Apr 29, 2012
Messages
416
Location
EU/SK
I have a 360k floppy disk, formatted to 18x256byte physical sectors per track that has one bad sector - track 37, head 1, sector 11.
I would like to lock out that sector from use.
Here is what I tried.

A>stat dsk:

A: DRIVE CHARACTERISTICS
2880: 128 BYTE RECORD CAPACITY
360: KILOBYTE DRIVE CAPACITY
64: 32 BYTE DIRECTORY ENTRIES
64: CHECKED DIRECTORY ENTRIES
128: RECORDS/ EXTENT
16: RECORDS/ BLOCK
72: SECTORS/ TRACK
0: RESERVED TRACKS

A>mbasic dpb
BASIC-85 Rev. 5.29
[CP/M Version]
Copyright 1985-1986 ¤ by Microsoft
Created: 28-Jul-85
33592 Bytes free
DPB VALUES FOR THE CURRENT DISK --

Sectors per Track 72
Sectors are not interleaved
Block Shift (BSH) 4
Block Mask (BLM) 15
Extent Mask (EXM) 0
Total Sectors (DSM) 179
Directory Entries (DRM) 63
Allocation 0 (AL0) 80H
Allocation 1 (AL1) 0H
Cylinder Offset (OFS) 0
.
.
.

Sectors are numbered from 0 to 17 on each side.
My program FDC says this:
Reading disk (18 sectors per track, 40 tracks)
current track:37
error reading sector(head):
37 11(1)st1 CRC error

I tried to compute allocation unit number:
sector nr -> 37*18*2*2 + 1*18*2*2 + 11*2*2 + 1 -> 2781
alloc unit (2k units) -> 2781/16 -> 173 -> 0ADh


then make any small 1 alloc.unit file

MBASIC
10 print
save "BAD",a
system
A>
ddt bad.bas

d50
0050 00 3C 00 3C 00 3C 00 3C 00 3C 00 00 00 42 41 44 .<.<.<.<.<...BAD
0060 20 20 20 20 20 42 41 53 00 00 80 01 97 00 00 00 BAS........

97 above is alloc unit number
now change it to 0ADh

s6c
006C 97 ad
006D 00 .


now change file extension to CRC
-s65
0065 42 43
0066 41 52
0067 53 43
0068 00
0069 00 .
-d50
0050 00 3C 00 3C 00 3C 00 3C 00 3C 00 00 00 42 41 44 .<.<.<.<.<...BAD
0060 20 20 20 20 20 43 52 43 00 00 80 01 AD 00 00 00 CRC........


-a100
0100 mvi a,16 --make file
0102 lxi d,5c
0105 call 5
0108 mvi a,10 --close file
010A lxi d,5c
010D call 5
0110 rst 7
0111
-s6c
006C 97 ad
006D 00 .
-g100

A>
I see no BAD.CRC file. So I see now it is not that easy :-(

Can anybody help? I am also thinking about writing a program that would accept bad sector numbers and then make lock.out file, but first I want to get it done with DDT if it is possible.
 
Well, I can offer one suggestion. Before your add the allocation unit to the FCB, do the "make", do yur substitution, then do the close. Otherwise, the "make" will clear the blcok list.

Your DPB display program doesn't display "total sectors", but rather "total blocks". I'm guessing that you get about 360K on the disk. (~~180 blocks * 2048 bytes/block).

I prefer to make my "bad block" files invisible. I give them a high user area number (e.g. 17) and make the file name lower-case. It's also easier to write the directory entry while formatting, rather than using the BDOS facility to do it.
 
Last edited:
I have a copy "FINDBAD.COM" that locks out bad sectors if you want to try it. It creates a lock-out file ([UNUSED].BAD) under user 15.

Mike
 
I could not get it done with DDT. Anytime when I called open file function DDT crashed and warm boot was issued. But I got it fixed with my floppy utility program. As I can read, write individual sectors and modify buffer contents it was easy.

So I read in the sector 0, modified allocation block to AAh (beginning of second line) which is the one containing bad sector 37/1/11 and changed the first letter of filetype to value of 'C'+128 to make it read only. I also changed the user to 15(first byte). Then I shortened the file to just one record (01 at the end of first line). And wrote back the sector. Now I can fill the floppy up the end and still all files are readable. Here it is what it looks like:

0F4241442020202020C3524300000001 .BAD .RC....
AA000000000000000000000000000000 ................

B>user 15
B>a:
A>b:stat *.*

RECS BYTES EXT ACC
1 2K 1 R/O A:BAD.CRC
BYTES REMAINING ON A: 0K

A>

A>user 0
A>dir
A: PIP COM : ASM COM : STAT COM : ED COM
A: LOAD COM : XM5V2 COM : XM5 COM : DDT COM
A: MBASIC COM : CPM22 ASM : DPB BAS : MLOAD TXT
A: MLOAD ASM : SINUS BAS : NUDE PIC : MLOAD COM
A: MOVCPM COM : FDC COM
A>stat usr:

ACTIVE USER : 0
ACTIVE FILES: 0 15
A>
A>user 15
A>era bad.crc
Bdos Err On A: File R/O
 
It's also easier to write the directory entry while formatting, rather than using the BDOS facility to do it.

I forgot to thank you. I edited first sector (beginning of file allocation table) using my low level program and it works like a charm.
 
Back
Top