11

The Intel 8272 and NEC μPD765 floppy disk controllers implemented three SCAN commands (SCAN EQUAL, SCAN LOW OR EQUAL, SCAN HIGH OR EQUAL).

What were these SCAN commands used for? I innocently assumed that they were analogous to hardware key searches in IBM mainframe CKD/ECKD hard disks, but reading the description in the data sheets I'm less sure. Rather than comparing just searching for an initial key field, it sounds like they compare the entire sector data byte-for-byte with data supplied by the host computer. Searching for an exact match of an entire sector seems a lot less useful than searching based on a key field (such as the initial N bytes of the sector).

Is anyone aware of any software that actually used them?

Is anyone aware of any emulators that emulate them? I've checked the source code of several emulators, and all those I've checked leave these commands unimplemented.

4
  • 1
    At least for SCAN EQUAL, one obvious use case is to compare a floppy against a complete floppy image in memory, to make sure that the floppy is "correct". It's also not that hard to implement in the controller, it's just a combination of read and write. Maybe it's just there because "it was cheap to do". I am not aware of any software that actually used that command.
    – dirkt
    Commented Jul 17 at 13:37
  • 6
    I implemented SCAN in lib765: seasip.info/Unix/LibDsk/#765 and hence those emulators which use lib765.
    – john_e
    Commented Jul 17 at 15:54
  • @dirkt did computers have that much RAM 45 years ago?
    – RonJohn
    Commented Jul 18 at 8:40
  • 1
    @RonJohn Well, that's exactly the reason why SCAN EQUAL is that useful. With only read, the CPU would need to compare, thus needing twice the memory. While full size image in memory do really sound less than common, track by track or sector by sector verification does make sense. Especially the sector one. Think writing and verifying a sector. Without SCAN EQUAL two sector sized buffers are to be compared - one with the data written and one with data read - with SCAN a single buffer will do it. great relief with small memories.
    – Raffzahn
    Commented Jul 18 at 10:44

2 Answers 2

16

TL;DR: Verify and/or Search

The scan commands can be used to

  • Verify a disk content without CPU interaction, or
  • Search of specific data at a specific position

While the first is rather obvious, the second may only become such when adding a 'tiny' detail not mentioned in either manufacturers data sheet: A byte value of x'FF' from either side (data or disk) is considered a default match (wild card). With that in mind one can make up arbitrary search patterns.

Zilog and others (*1) weren't as secret. While the wording is almost exact identical to Intels 1982 data sheet - or NEC's for that matter - one important sentence has been added(*2):

The hexadecimal byte of FF from memory or from FDD can be used as a mask byte because it always meets the condition of the comparison.

As seen on page 933 of the 1985 Zilog Components Databook:

enter image description here


I innocently assumed that they were analogous to hardware key searches in IBM mainframe CKD/ECKD hard disks, but reading the description in the data sheets I'm less sure.

Yeah, a well educated guess knowing the history of magnetic recording, except the 8272 and later compare within the data fields, not key (header) fields. Somewhat more flexible.

Rather than comparing just searching for an initial key field, it sounds like they compare the entire sector data byte-for-byte with data supplied by the host computer.

Yes. And unlike the 8271 it doesn't offer support for pattern repeat (*3), so the whole data stream must be supplied right in time.

Searching for an exact match of an entire sector seems a lot less useful than searching based on a key field (such as the initial N bytes of the sector).

Yeah, that's where knowing the wild card value (x'FF') comes in handy. So if for example each 512 byte sector begins with an 8 byte key, search can be done by providing a those 8 bytes followed by 504 bytes of x'FF'.

This also gives a hint why that feature hasn't been used a lot (or at all). As the controller does not give any indication when starting/ending a sector, one has to set up either a search 'mask' for a whole cylinder (= 9 KiB for 360 KiB disks), which is a HUGE amount for back then, or adequate DMA handling(*4).

Is anyone aware of any software that actually used them?

I have seen it been used for write with verify. To use it the write software issues a regular sector Write command, followed by a Scan Equal using the same buffer. That way the sector gets written during one turn and read and compared during the next. When no error is reported one can be sure that not only the sector is present and valid, but also contains the intended data. Way more than what the PC's BIOS verify (Int 13h, Function 4) does (*5).

Is anyone aware of any emulators that emulate them? I've checked the source code of several emulators, and all those I've checked leave these commands unimplemented.

Well, as so often they only implement until it's somehow working and after that waiting for error reports/change request. With no default software using them, they may stay unimplemented for a long time. Except for some real old embedded/control applications noone writes his own diskette handlers - and such are quite rare found with people using emulators.


*1 - Found it as well in a 2004 application note by SMSC for their FDC765A.

*2 - Well, they also clarified some names, improved layout and dropped some misleading symbols. Over all the better data sheet to refer to.

*3 - The 8271 works with variable key size and record sizes in multiple sectors allowing finer specification what to search.

*4 - For example setting up a single record sized buffer and DMA in autoinitialize mode. Now the FDC would read all sectors starting at the first, compare each record against the buffer and return when found, or the whole cylinder is done. Of course EOP/TC hardware must be made to allow this - and having records fitting evenly into sectors or being multiples thereof would help as well.

Additional hardware could of course exploit this even more.

*5 - The IBM-PC BIOS for example does not really verify a sector, but only reads it. All data read is discarded without further check - that's also why any buffer given in ES:BX doesn't matter. It only 'checks' if the sector can be found, read and it's checksum being a valid one. Intels next FDC, the 81072 implements that behaviour as a dedicated command, so no DMA setup is needed.

I'm not sure right now if (GW)BASIC(A) implemented a verify at all.

2
  • Thanks. On your footnote (4), could you elaborate more what you mean by "EOP/TC hardware"? I know TC=Terminal Count, but what is EOP? And you talking about additional hardware beyond the FDC and DMA controller (e.g. Intel 8237)? Commented Jul 18 at 9:51
  • @SimonKissane It's a footnote as it depends on system design, the way the FDC is operated, so any further discussion would depend on a concrete design. Yes, EOP is the corresponding pin to TC on a 8237 DMA. It's bidirectional. It outputs low whenever the DMA's TC reaches zero. Pulling it external (like from a FDC's TC) low it terminates DMA. Quite versatile, so connection and intermediate circuit defines what modes can be created.
    – Raffzahn
    Commented Jul 18 at 10:37
4

Is anyone aware of any software that actually used them?

On this point: The DD CHECK SECTOR function found in the Spectrum +3 ROM and in CP/M for the Amstrad PCW and Spectrum +3 uses SCAN EQUAL to compare a sector on disc with the contents of a buffer in memory. Therefore any emulator for these machines will likely emulate SCAN EQUAL if not all the SCAN commands.

1
  • Cool. I already had a feeling that Sinclair or Acorn might turn up here :))
    – Raffzahn
    Commented Jul 18 at 10:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .