Sharp logo
Disc-overing Disc Drives 
written by Geoff Jones / SUC/UK
Source: SUC-magazine June 1986, Volume 5, Number 3, pp. 36 - 39 

Sharp Users Club - MZ-80K Section - Disk Drive Secrets / 01

The MZ-80K Section in this issue is devoted mainly to an in-depth excursion into the world of MZ-80K discs.

Geoff explains below, in relatively simple terms, how the Sharp disc drives work, on an MZ-80K. Although the article is aimed to help the newcomer, there is some interesting coding detail which may be useful to more expert members.

The MZ-80K drives are double-sided, single-density, 35 tracks per side. This differs from the industry norm of 40 tracks per side, even though the Sharp drives are Shugart compatible. By this I mean that they can in fact be plugged into almost any computer that uses a Shugart type interface, because the 34-way ribbon cable connector at the rear of the drives is pin-compatible with the Shugart industry standard. I use my Sharp drives for both my MZ-80K and my BBC computer ( sorry to mention that, but I craved for hi-res colour graphics ).

Double-sided means that there are tracks on each side of the disc; 35 on each side in this case, though to the software they are referred to as tracks 0 to 69. Each track is made up of 16 sectors. Single-density means that each of these 16 sectors is 128 bytes long ( double-density would mean that each sector would be 256 bytes long ). The Sharp drives cannot be converted to 40-track on the MZ-80K, as the mechanical bits and pieces inside the drive will move too far. This is because the floppy-disc controller chip and its associated worm drive move the head too far between tracks. I found this out when I had my drives connected to the BBC and tried to format a disc with 40 tracks; the result was horrible grinding noises!! I now use discs formatted to 35 tracks per side on my BBC.

The discs rotate at approximately 300 r.p.m. and when switched on by the software are given about half a second to get up to speed. The heads are lowered onto the discs whenever the drives are started, but only if the drive doors are shut, as the heads are mechanically interlocked with the doors.

In any read or write operation the heads are always driven to the track 0 position to start with; this position is detected by a switch, to enable an accurate starting-point to be set on each occasion. The software then sends the head to the required track. The floppy-disc controller then looks for the index hole that is punched through the disc to obtain an accurate reading for locating the sectors, and then counts up to the sector required.

The format of the discs, that is where the tracks are on the disc and where each sector is located, is determined by the initialization program supplied with the master disc. This program tells the floppy-disc controller to write markers on the disc to number the sectors 00 - 0FH. The tracks are numbered by hardware, as track 0 is at the outside edge of the slot visible in the black protective cover, and track 35 is at the inside edge of this slot; each track is 1 or 2 steps of the motor apart.

The software format of the master disc is:-
Bootstrap loader program 05FFH bytes long
01 - 03:
Directory tracks ( capacity 96 directory entries )
04 - 14:
Sharp Disc Basic
15 - 70:
Available for user programs

The user program space is thus ( 55 tracks ) * ( 16 sectors ) * ( 128 bytes ), which gives a theoretical 112,640 bytes on the master disc. On a slave disc, as there is no Disc Basic, tracks are free from 4 upwards, giving 66 * 16 * 128 or 135,168 theoretical bytes. Both these figures are very slightly reduced in practice by the fact that 2 bytes of each sector are used to store the track and sector number of that particular sector.

The bootstrap loader program contained on track 0 makes a disc a master disc i.e. one that may be booted from the Monitor. When you respond to the “BOOT DRIVE“ prompt on the screen, a jump to F000H is executed by the Monitor program. At this address is a ROM which is part of the disc drive interface card. The program contained in this ROM loads the track 0 program ( known as a bootstrap loader ) into memory locations 9800H upwards, and executes it; this program in turn decides which program on the disc is loaded and executed. On the Sharp master disc it is of course Disc Basic, which is loaded into 1200H upwards.

On the Directory tracks ( 1 - 3 ) there are 64 bytes allocated to each entry. The actual directory format is:-

File Type ( 01 = Machine-code, 02 = Basic )
02 - 17:
Filename, padded out with 0DH's
File protect flag ( 01 = Locked, 00 = Free )
19 - 20:
File size
21 - 22:
Load address
23 - 24:
Execute address
25 - 62:
Not used
Track No. of program
Sector No. of start of program

A file is deleted from the directory by setting the file type byte to 00.

For those of you who like a little excitement in your lives, you can control the discs, without any fear of damage, by writing to the relevant I/O ports. I say without fear of damage because the hardware built into the disc drives and the floppy-disc controller card protect the disc at all times. The only thing that can go seriously wrong is that you might erase or write over a program on a disc in the drives at the time; so make sure you only experiment with duplicate or unwanted discs!! There is one other minor problem, which is not being able to switch the drives off; if this happens, switch off the power to the drives or the I/O box for a few seconds; this will reset the drives to normal working.

Controlling the drives accurately enough to maintain data reliability is a very complex feat of machine-code real-time programming, which means that the commands for actually controlling the drives through the I/O ports cannot be implemented in Basic, but must be done in Assembly language or machine-code direct. The Z80 has special commands for handling the input and output ports, namely IN and OUT. The MZ-80K uses 4 ports to access the floppy-disc drives, these are F8H, F9H, FAH, and FBH. For the brave amongst you here are the commands for switching the drives on and off, moving the heads, reading the floppy-disc-controller registers, and reading and writing to the discs:-

1. To turn drives on:- LD BC,08F8H
IN A,(C)
2. To turn drives off: LD BC,00F8H
IN A,(C)
3. To select a drive:- LD BC,****H
IN A,(C)
N.B. For Drive 1 **** = 0CFB
Drive 2 **** = 0DF8
Drive 3 **** = 0EF8
Drive 4 **** = 0FF8
4. To read the controller register ( of which only the lower 3 bits are significant ):-
  IN A, (F9H)
F.D.C. received data and / or ready for data. This is used when writing to check that the data sent to the disc has been received and written, or when reading to show that the F.D.C. is ready with the next bit of data to be read.
F.D.C. ready for commands.
drive selected, running and ready.
5. To read the status register ( of which only bits 4, 5 and 6 are significant )
  IN A,(FAH)
These bits are used differently, depending on whether the operation being carried out
is a READ or a WRITE:-
  ( READ )
BIT 5:
set when head is not at track 00
  ( WRITE )
BITS 4, 5:
BIT 4:
both set for a formatted disc
( only ) set for an unformatted disc.
  ( WRITE )
BIT 6:
set for a write-protected disc.
6. To read in data:- IN A,(FBH)
( Data is usually read in blocks of 128 bytes. )


To select a sector:-

LD A, Number; set BIT 7 if odd

8. To select a track:- LD A, Number; between 0 and 69
9. To send head to track 00:- LD A,00
10. To select read from disc command:- LD A,70H
11. To select write to disc command:- LD A,B0H
12. To write block identifiers when formatting:- LD A,A0H
13. To write data on disc:- LD A,data

Most of these commands are used whenever you read or write to a disc; it‘s just a matter of using them in the correct order to perform the desired function, and testing the registers to ensure that the disc drive is ready to carry out the next step.


Geoff's article makes an interesting complement to the article by Robert Newton an page 42 of this issue, on MZ-80A discs. It seems that “K“ disc units and same early “A“ disc units were designed specifically for 35 tracks. Later units were more standard, being designed for 40 tracks but limited to 35 tracks by a plastic stop, in order to make them compatible with the earlier drives. ********

Go to the top of this page Home

last updated September 21, 2003
SUC / UK: Geoff Jones