• Please review our updated Terms and Rules here

Floppy disk interwseave and SYSTEM load time

Mike_Z

Veteran Member
Joined
Dec 1, 2013
Messages
1,713
Location
Near Milwaukee Wisconsin
Today, I was curious whether or not my CP/M 2.2 system was loading fast enough. I have a 2 track system on an 8 inch floppy. My CBIOS has a SecTran call and translation table like this

Code:
          SECTRAN:                      ;HL=TABLE+BC OFFSET (DE)
                    XCHG                ;HL=TRANS
                    DAD       B
                    MOV       L,M
                    MVI       H,0H
                    RET

;SECTOR TRANSLATION TABLE
          TRANS:    DB        1,7,13,19           ;SECTORS 1,2,3,4
                    DB        25,5,11,17          ;SECTORS 5,6,7,8
                    DB        23,3,9,15           ;SECTORS 9,10,11,12
                    DB        21,2,8,14           ;SECTORS 13,14,15,16
                    DB        20,26,6,12          ;SECTORS 17,18,19,20
                    DB        18,24,4,10          ;SECTORS 21,22,23,24
                    DB        16,22               ;SECTORS 25,26

This seems to imply that one track should we read in 7 revolutions of the disk. Therefore, 2 tracks should take 14 revolution plus the seek time to move from track 0 to track 1. I have the head unload set at 240 mSec, the head load at 254 mSec and the step rate at 8 mSec. Total equal to 502 mSec.

I believe the floppy rotates at 360 RPM or 167 mSec per turn.

Ignoring computer time,
14 revolutions times 167 mSec per turn plus 502 mSec = 2.84 seconds

I measured 9 2/3 seconds on my system. I first got my CP/M 2.2 system working on my homemade 8080 computer with two Shugart SA800 drives about 6 years ago. I was very ignorant of most things needed to do this and tried many things. The summer of 2015 I got a system that worked. Since then I have used the system quite a bit and never really thought about how long it should take to load the system.

The first disk's I formatted and all the ones since, I set the interweave to 1:1. Today I formatted a test disk with the same parameters but had an interweave of 7:1. Then copied my system and some files from a 1:1 disk to this 7:1 disk. This worked and the load time measured dropped to 3.2 seconds.

My CBIOS has a SECTRAN: routine, but what calls it? I'm a little confused at how to handle this? Seems the SECTRAN maybe a software method to speed up disk access, but I do not think my software is using it. When I format a disk with a 7:1 interweave, system loading time is cut by 2/3's. Mike
 
First of all, are we talking about physical interleave (the way the sector IDs occur on the disk) or logical interleave (the way the OS translates access to consecutive sectors)?

The whole rationale behind SECTRAN goes back to the early CP/M days where one purchased preformatted IBM 3740 floppies--and there was no software furnished to do a low-level format. This, for some vendors, extended into the 5¼" world. For a vendor with its own physical format, it makes more sense to physically format a floppy with the desired interleave than to use software to effect a logical one. This is particularly important when physical sector sizes are greater than 128 bytes (almost all MFM floppies) and when a floppy controller can read a 1:1 interleave without dropping a revolution between sectors.

For loading the initial boot tracks, it's up to the CBIOS/boot as to use SECTRAN or not.

In fact, some vendors special-cased physical formatting, where the boot track was formatted at 1:1, while the remainder of the disk was formatted at, say, 3:1.

Then, there's side and track skew schemes, where the ordering differs between sides and tracks to ensure that when a side or track is incremented, that the proper sector is under the head. It's possible in that case to read an entire disk without dropping a single revolution.

Floppy drives are slow. You do what you can to make things fast.
 
Well.... what I did was redo the physical interleave (weave, I've seen skew, whatever?) My FDC just reads the sector information and that is that? So, with a physical interleave of 1:1, I suspect after reading sector #1, the FDC had to wait more than one revolution before it found sector #2. When I reformatted a test disk with a 7:1 interleave, all the FDC had to wait was 6 sector times or about 36 mSec? Since there is no software used, this is why the new 7:1 interleave disk worked.

If the software were to be used, each time a sector was requested, the software would have to call SECTRAN first to get the logical number?

It would probably be best (and easiest) to use the physical 7:1 rather than try and use the software table. Is there any potential problems with using the 7:1. I don't mind being slow, but if I can pick up 6 seconds each time I boot, I'll take them. Don't have that many left. Thanks Mike_Z

Also, having the 7:1 interleave, should reduce the time it takes to load any program?
 
Timing depends on the floppy controller, at least to a large extent. If your FDC can do multi-sector reads using DMA, all that software needs to do is to set up the transfer parameters, start the operation and go away until the whole thing is complete. You didn't state what your FDC was. If it's a WD1771 (among the earliest of LSI FDCs), multiple-sector transfers can be performed and end at the last sector on a track--the sector number is incremented automatically--there's essentially no lag between sectors.

Some early BIOS versions took advantage of this by transferring an entire track at a time--it costs you a revolution whether a single sector is transferred or a whole track's worth. The logic can be a bit complicated, but it's not too bad--you can either flush writes immediately or delay until a different track is selected. Similarly, if you've got the storage, you can separate out directory reads/writes and dedicate a separate RAM buffer for those.

The speed improvement can be quite dramatic.
 
Part of the issue, traditionally, with 8" floppies was that it was the main interchange format between different systems. Digital Research would distribute their OS files on a "standard 8" floppy". This meant single-density as well. The standard, pre-formatted, floppies had a physical sector skew of 1 - the second physical sector on the track was numbered +1 from the first ("1"). The CP/M industry settled on a logical sector skew of 6, as shown in your table, which means that the data for the second sector was written to physical sector 7. This provided a enough time such that most programs could be ready for the second logical sector by the time physical sector 7 passed under the head. But, that's a trade-off and so some programs were faster and ended up "wasting time" waiting for sector 7. The issue is that logical sector skew has to be agreed upon, and known a priori, by all users of the floppy. Physical sector skew wasn't generally an option until people had controllers that could easily format the floppies - and they were willing to take the time to reformat floppies out of the box.

So, changing the physical skew is a good way to optimize a logical skew of 6, but that optimization may not hold for all use cases (programs). If a program misses it, it will take 26 revolutions to read a track - which is pretty bad.

Most OS vendors, once the controllers supported it, would provide for double-density formats that were not tied to the IBM standard. These often used a physical sector skew to optimize access. The OS driver (BIOS) needs to know how to access the data - it needs to know how the data was written. So in general SD floppies just stuck to the logical skew of 6.
 
SECTRAN is a BIOS entry point to permit CP/M 2 to perform software sector translation (as has been stated above).

If you are going to implement hardware translation, the last thing you should really be doing is implementing software translation at the some time. This could nullify the effect - or even make things work!

However, you need to make sure you don't bite yourself in the proverbial - as you will have existing disks written in one format (I am assuming) and if you change things - you could invalidate these disks.

Just a thought before you go too mad and there is no way back...

Dave
 
I tend to (being an old person) differentiate between "skew" and "interleave". "Interleave" to me is the way that sectors are placed on a track. "Skew" is the offset into the track from track to track. To give an example (simplified) for a 10-sector track.

An interleave of 2-to-1 would have the first track on the disk with the sectors laid out as 1,6,2,7,3,8,4,9,5,10. Now, suppose a one-track step takes the same time as would be required to read 2 sectors(non-interleaved). Then, the second track would be laid out as 5.10,1,6,2,7,3,8,4,9. So, reading continuously from one track to the next results in no lost revolutions. I would call that a track skew of 2. Note that with the skew, the interleave remains the same. Side skew, similarly, is also possible. For a practical example, consider the CP/M disks for the National Semiconductor BLC 86/12B.

But then, as I said, I'm old and a stickler.
 
Last edited:
Chuck, I have a Intel 8272 FDC. It reads one sector at a time and uses DMA. 128 byte sectors single side, single density.

I do have a couple dozen floppies, but I also have them backed up on hard drive. I have an HP computer with DOS/WIN98 that has an 8 inch floppy connected to it. The HP has IMD, 22DISK and ANADISK on it so I can format read etal. All my 8 inch floppies are backed up onto this HP. I tend to screw up things on a regular basis, so keeping good backup is necessary.

If I would change the physical interleave to 7:1, it would just be a matter of re formatting the floppies and then copying the system and programs from the HP back onto the floppies.

Doug, if a program misses a sector, why would it take 26 rev's to find it again. Wouldn't it come across that sector in the next revolution? Mike
 
...

Doug, if a program misses a sector, why would it take 26 rev's to find it again. Wouldn't it come across that sector in the next revolution? Mike

It would take 26 revs to read the *track*, if the program was not able to make the skew factor (assuming it was consistently unable to make the skew).
 
Doug, so that is a good reason to use physical interleave. If a sector was missed, it should be read on the next revolution. Only a 167 mSec delay. Mike
 
Chuck, I have a Intel 8272 FDC. It reads one sector at a time and uses DMA

The 8272 is the same as the NEC µPD765 (cross-licensing between NEC and Intel). It can read multiple sectors and even uses a "last sector" register to indicate the last sector of a multi-sector transfer. So, very simple to handle 1:1 interleave.
 
Another thing to be wary of is that optimizing the systems tracks for the boot may not result in the same optimal skew as what CP/M needs for the directory and data blocks. You might have to use a different skew for the data tracks than for the systems tracks, which begs the question whether it is worth it. Additionally, the ROM cold boot code may perform quite differently than the BIOS warm boot code, and so the same skew may not be optimal for both.
 
Mike,

There are two (2) ways of achieving the same result: physical and logical.

If the physical arrangement of sectors is 1,2,3,4,... on the disk and you supply a software sector translation of 1,3,5,... then reading sector number 1 is physical sector 1. Reading logical sector 2 then translates into physical sector 3 (i.e. you allow 1 sector of time for the software to access the next sector. This is the same as hardware formatting the disk with sectors as 1, n, 2, n+1, ... and no software sector translation.

Dave
 
Of course, if you have a floppy with no physical interleave and buffer it a track at a time, all logical interleaves can be accomplished without changing the basic I/O functions--all one needs is a function to compute where in the track buffer a given sector lies. And all skews/interleaves run at the same speed.

A 3740 disk would require 128*26 = 3328 bytes of RAM to buffer. A small price to pay for phenomenally fast access.
 
There are a number of variables on interleaving. In HDOS, it always skips the next sector so 1:1 was always slow. It could handle 2:1 on loading programs but for BASIC to read data inputs it needed 3:1.
( HDOS is heathkit )
Dwight
 
In the original situation, your disk had a physical interleave of one. The software interleave performed by SECTRAN is used by the BDOS, but not by the CP/M cold loader. It appears your CP/M cold loader is attempting to read each sector in sequence and can’t keep up. After reading sector 1, it then attempts to read sector 2 but is too late. Sector 2 takes another full revolution to come back around before it can be read. So the cold loader ends up taking 26 revolutions per track to load CP/M. Doing the math: 26 sectors x 2 tracks x 0.167s/revolution is over 8.5s, plus some select time, home time, and step time, and you’ve got your 9.5s boot time.

If the CP/M cold loader were modified to read every other sector (very common), load time would be reduced to two revolutions per track or closer to one second to boot instead of nine seconds.

As others have mentioned, the physical interleave of one and the soft interleave of six for the data tracks on the 8” SSSD floppy was very widely adopted and pretty much the only interchange standard prior to widespread acceptance of the IBM PC and MS-DOS formats years later. For this reason, I would not change the physical interleave of your disks.

It would be a fun exercise to write a better CP/M cold loader for your system that uses a 2:1 soft interleave and patch it into the CP/M image to be written to the boot tracks with SYSGEN.

Mike
 
Mike, he says his FDC is an Intel 8272. That can read-multi sectors at 1:1 with one hand tied behind its back. I suspect that he's just got it programmed to read a sector at a time.
 
While not modifying the disk format and instead modifying the software might seem like a better solution, it is a hack. Also, as Chuck noted, most controllers can read sequential sectors, easily.
The choice between making the software more complicated or a minor change to the format are significant. Using software interleaving requires making a new translation table for each disk format. Changing the disk format is done as the format changes.
One is not that much better than the other. Both have issues but to think one is better than the other is because it can be done is not a good justification. For the Heath kit problem, it is simpler to modify the format. It requires no software changes and it is transparent to the applications other than a significant improvement in load times. Writing your own low level code for your implementation of CP/M, it makes some sense to keep the same format but alter the software.
It really depends on what one wants to achieve. It isn't like one is that much better than the other.
If I knew I was going to have to write software to scramble the sector order, I'd change the disk format. If I knew I could read sequential sectors with ease, like using a 8272, I'd leave them formatted in sequential order.
The simplest solution is really the best, for any particular problem.
Dwight
 
I didn't get a chance to look at this today. I was called down to the Kenosha machine shop. The horizontal boring bar failed. A good friend of mine operates this shop and makes shears, arbor presses and other tools for industry. The boring bar was needed, so I traveled down there to repair it. It was not difficult but toke all day.

The way I have the 8272 programmed is to read only one sector at a time. I'm not really anxious to change what seems to work right now. I'm leaning toward just changing the physical sectoring on my floppies. Yet I'm not completely sure what interleave I actually have. I mentioned that I have IMD, 22disk and AnaDisk. Each format my floppies. I particularly like 22Disk. Seems this program can root out bad media better than the other two. It takes longer, but seems worth the wait. IMD allows me to set the interleave directly each time anything is done with the floppy. I looked at the DEF file for 22Disk, regarding the A1 definition for 8 inch floppies.

Code:
BEGIN A1  Generic CP/M - SSSD 8"
DENSITY FM ,HIGH 
CYLINDERS 77 SIDES 1 SECTORS 26,128
SIDE1 0 1,7,13,19,25,5,11,17,23,3,9,15,21,2,8,14,20,26,6,12,18,24,4,10,16,22
BSH 3 BLM 7 EXM 0 DSM 242 DRM 63 AL0 0C0H AL1 0 OFS 2
END

Does this imply that there is an interleave of 13 when this program formats a disk? Yet when a 22Disk formatted floppy is looked at in AnaDisk, AnaDisk reports a 1:1 interleave. Not sure what interleave AnaDisk has. Maybe tomorrow, I'll experiment with it and see what changes will do.

By the way we got a boat load of snow the other day, Racine reported 16.5 inches. Thanks for the help, Mike
 
Back
Top