¡ Disk subsystem

¡ I/O ports of disk subsystem I/F

AddressR/WDescription
FChR/W Disk subsystem I/F 8255 port A
In the standard state, it is a data reception port from the subsystem.
FDhR/W Disk subsystem I/F 8255 port B
In the standard state, it is a data transmission port to the subsystem.
FEhR/W Disk subsystem I/F 8255 port C
Bit76543210
R/WWR
Signal ATN DAC RFD DAV
DAC RFD DAV

ATN W Attention Set to 1 when sending a command to the subsystem or interrupting a command
DAC Data Accepted Set to 1 after fetching data from the subsystem
RFD Ready For Data Set to 1 when requesting data from the subsystem
DAV Data Valid Set to 1 after outputting data to port B
DAC R Data Accepted Becomes 1 after the subsystem picks up data
RFD Ready For Data Becomes 1 when the subsystem requests data
DAV Data Valid Becomes 1 after data is output to port A
FFhW Disk subsystem I/F 8255 control

¡ Communication protocols with the subsystem

¡ Routines in ROM that communicate with the subsystem

LabelAddressFunction
N88N
PUTCOM37CCh017ChSend the contents of the A register as a command to the subsystem
PUTDAT37D2h0183hSend the contents of the A register to the subsystem
GETDAT3847h01E9hReturn the data received from the subsystem to the A register

*N88: If the work area (EF15h) is not 00h, high-speed handshake is performed using the contents of the L register as the 2nd byte.

¡ Subsystem commands

The command number is sent by command transmission, and the parameters are usually sent by handshake.

<Drive number>0..1
<Track number>0..79
<Sector number>1..16 (2D)

Command number00h
Function nameInitialize
Command format Host ¨ Sub: <00h>
Function Turn on the drive motor, reset the FDC, return the head to the initial position,
and do not change the drive operation mode (duplex/single-sided) and read-after-write check mode.

Command number01h
Function nameWrite Data
Command format Host ¨ Sub: <01h> <Number of sectors> <Drive number> <Track number> <Sector number> <Data stream...>
Function Write data sent from the host to disk.

Command number02h
Function nameRead Data
Command format Host ¨ Sub: <02h> <Number of sectors> <Drive number> <Track number> <Sector number>
Function Read data from the specified sector and stores it in the subsystem's buffer.
To obtain the data, the host must execute the Send Data command in succession.

Command number03h
Function nameSend Data
Command format Host ¨ Sub: <03h>
Sub ¨ Host: <Data stream...>
Function Transfer the data of the size read by the previous Read Data command to the host.

Command number04h
Function nameCopy
Command format Host ¨ Sub: <04h> <Number of sectors> <Drive number 1> <Track number 1> <Sector number 1> <Drive number 2> <Track number 2> <Sector number 2>
Function Copy sector contents sector by sector.

Command number05h
Function nameFormat
Command format Host ¨ Sub: <05h> <Drive number>
Function Format the disk.

Command number06h
Function nameSend Result Status
Command format Host ¨ Sub: <06h>
Sub ¨ Host: <Status>
Function The execution result of the command sent just before is transmitted to the main side.

If the 0th bit of the result status is 1, there is an error.
If the 6th bit is 1, there is data in the read buffer.
If the 7th bit is 1, the I/O operation is finished.

Command number07h
Function nameSend Drive Status
Command format Host ¨ Sub: <07h>
Sub ¨ Host: <Status>
Function Bits 7 to 4 of the drive status indicate the connection status of the drive.

Command number08h
Function nameTest Memory
Command format Host ¨ Sub: <08h>
Sub ¨ Host: <Status>
Function Perform subsystem memory tests:
80h: OK
81h: Not good

Command number09h
Function nameSend Memory
Command format Host ¨ Sub: <09h> <Start address H> <Start address L> <End address H> <End address L>
Sub ¨ Host: <Data stream...>
Function Transfer subsystem memory content to host.

Command number0Ah
Function nameOutmargin Support
Command format Host ¨ Sub: <0Ah> <Data>
Function Output specified data to the subsystem I/O port F7h (no use value).

Command number0Bh
Function nameSend Memory 2
Command format Host ¨ Sub: <0Bh> <Start address H> <Start address L> <Number of bytes H> <Number of bytes L>
Sub ¨ Host: <Data stream...>
Function Transfer subsystem memory content to host.

Command number0Ch
Function nameReceive Memory
Command format Host ¨ Sub: <0Ch> <Start address H> <Start address L> <Number of bytes H> <Number of bytes L>
Function Transfer data from host to the subsystem memory.

Command number0Dh
Function nameExecute
Command format Host ¨ Sub: <0Dh> <Start address H> <Start address L>
Function Start execution in the subsystem from a specified address.

Command number0Eh
Function nameLoad Data
Command format Host ¨ Sub: <0Eh> <Number of sectors> <Drive number> <Track number> <Sector number> <Start address H> <Start address L>
Function Read data from disk and store it at a specified address in the subsystem.

Command number0Fh
Function nameSave Data
Command format Host ¨ Sub: <0Fh> <Number of sectors> <Drive number> <Track number> <Sector number> <Start address H> <Start address L>
Function Writes data to disk from a specified address in the subsystem.

Command number10h
Function nameLoad & Go
Command format Host ¨ Sub: <10h>
Function After initialization, load 256 bytes of data from drive 1, track 0, sector 1 into 5000h in the subsystem memory and execute it.

Command number11h
Function nameHigh Speed Write Data
Command format Host ¨ Sub: <11h> <Number of sectors> <Drive number> <Track number> <Sector number> <Data stream...>
Function Same as 01h write data except that the data stream is transferred using high-speed handshake.

Command number12h
Function nameHigh Speed Send Data
Command format Host ¨ Sub: <12h>
Sub ¨ Host: <Data stream...>
Function Same as 03h send data except that the data stream is transferred using high-speed handshake.

Command number13h
Function nameError Info
Command format Host ¨ Sub: <13h>
Sub ¨ Host: <Command> <ST0> <ST1> <ST2> <C> <H> <R> <N>
Function Transfer the last command executed by the FDC and the FDC status to the host.

Command number14h
Function nameSense Device Status
Command format Host ¨ Sub: <14h> <Drive number>
Sub ¨ Host: <Status>
Function Returns FDC status to host side

Bit 0Unit Select 0
Bit 1Unit Select 1
Bit 2Head Selection
Bit 3Two Sided
Bit 4Track 00
Bit 5Ready (always 1)
Bit 6Write Protected
Bit 7Fault

Command number15h
Function nameFast Send Memory
Command format Host ¨ Sub: <15h> <Start address H> <Start address L> <Number of bytes H> <Number of bytes L>
Sub ¨ Host: <Data stream...>
Function Same as 0Bh send memory except when fast handshaking is used to transfer data.
The number of transferred bytes must be an even number.

Command number16h
Function nameHigh Speed Receive Memory
Command format Host ¨ Sub: <16h> <Start address H> <Start address L> <Number of bytes H> <Number of bytes L> <Data string...>
Function Same as 0Ch receive memory except when fast handshaking is used to transfer data.
The number of transferred bytes must be an even number.

Command number17h
Function nameSet Surface Mode
Command format Host ¨ Sub: <17h> <Mode H>
Function Specify whether each drive should be in simplex or duplex mode

Bit 3 to Bit 0: 0: Single-sided 1: Double-sided

At startup, all drives are in single-sided mode.

Command number18h
Function nameSend Surface Mode
Command format Host ¨ Sub: <18h>
Sub ¨ Host: <Surface mode>
Function Send surface mode to host.

Command number19h
Function nameSet Read After Write
Command format Host ¨ Sub: <19h>
Function Perform a read-after-write check after executing this command,
a read-after-write check will be automatically performed after executing a command that involves writing to the disk.

If an error is detected, the error bit in the result status will be set.

Command number1Ah
Function nameReset Read After Write
Command format Host ¨ Sub: <1Ah>
Function Disable read-after-write checks.

Command number1Bh
Function nameResume
Command format Host ¨ Sub: <1Bh>
Function Resume execution of the subsystem stopped at a previously set breakpoint.
It is also possible to change the PC using the set register command and execute from that address.

Command number1Ch
Function nameSet Breakpoint
Command format Host ¨ Sub: <1Ch> <Address H> <Address L>
Function Set a breakpoint at the specified address.
Breakpoints can only be set at one location.

Reset when stopped at breakpoint.

Command number1Dh
Function nameSet Register
Command format Host ¨ Sub: <1Dh> <Register ID number> <Data H> <Data L>
Function Specify a register content when restarting execution with the resume command (1Bh).

Register IDRegister
0AF
1BC
2DE
3HL
4AF'
5BC'
6DE'
7HL'
8IX
9IY
10- I
11PC
12SP

Command number1Eh
Function nameSend Register
Command format Host ¨ Sub: <1Eh> <Register ID number>
Sub ¨ Host: <Data H> <Data L>
Function Send a register content to the host when the subsystem is stopped at the breakpoint.

¡ Extended subsystem commands on machines equipped with 2HD drives

Command number1Fh
Function nameSet Disk Mode
Command format Host ¨ Sub: <1Fh> <Drive number> <Disc code>
Function Set disc mode according to specified disc code.

Disc code:

Bit76543210
Signal 0 0 DSK SPC 0 SCR

DSK Disc type 00: 1D/2D type
01: 1DD/2DD type
10: 1HD/2HD type
SPC 1HDs/2HDs selection 0: 1HD
1: 2HD
SCR Sectors length 01: 256 bytes/sector
10: 512 bytes/sector
11: 1024 bytes/sector

Command number20h
Function nameSend Disk Mode
Command format Host ¨ Sub: <20h> <Drive number>
Sub ¨ Host: <Disc code>
Function Send disk mode to host.

Command number21h
Function nameSet Boundary Mode
Command format Host ¨ Sub: <21h> <Boundary Mode>
Function Set boundary mode.

0: Limit read/write range to 1D/2D disks
1: Limit the read/write range to disks with a sector length of 256 bytes (including disks with 1HDs/2HDs)
2: Allow read/write of all disks that can be supported by the subsystem

Command number22h
Function nameSend Boundary Mode
Command format Host ¨ Sub: <22h>
Sub ¨ Host: <Boundary mode>
Function Send boundary mode to host.

Command number23h
Function nameDrive Ready Check
Command format Host ¨ Sub: <23h> <Drive number>
Sub ¨ Host: <Status>
Function Disk insertion check.

00h: Disc inserted
FFh: No disc inserted

Command number24h
Function nameExpanded Format
Command format Host ¨ Sub: <24h> <Drive number> <Data>
Function Format the disk with initialization data.

¡ About 1HDs/2HDs

To be autobootable 1HD/2HD discs must have track 0 formatted in FM mode with a sector length of 128 bytes and the rest in MFM mode with a sector length of 256 bytes.

Track 0 is read/written in units of 256 bytes, so only odd sector numbers can be specified.
The number of sectors should be 1/2 of the actual number.


¡ I/O port on the subsystem side

AddressR/WDescription
F4hW Drive control

Bit76543210
Signal
CLK DSI TD1 TD0 RV1 RV0

CLK ? ?
DSI ? ?
TD1 Drive 2 track density 0: 48TPI (2D)
1: 96TPI (2DD/2HD)
TD0 Drive 1 track density
RV1 Drive 2 mode 0: 2D/2DD
1: 2HD
RV0 Drive 1 mode
F8hW Motor control

Bit76543210
Signal
PSEN
MON1 MON0

PSEN ? ?
MON1 Drive 2 motor control 0: Motor OFF
1: Motor ON
MON0 Drive 1 motor control
R FDC ƒÊPD765A TC input
When this port is read, the TC signal is input to FDC.
FAhR FDC ƒÊPD765A status register read

Bit76543210
Signal RQM DIO NDM CB D3B D2B D1B D0B

RQM Request for Master When DIO = 0: Data can written to the data register.
When DIO = 1: Data can be read from the data register
DIO Data Input/Output 0: CPU ¨ FDC
1: CPU © FDC
NDM Non-DMA Mode Transferring data in Non-DMA mode
CB FDC Busy 1: FDC is executing the command phase, result phase, and execution phase.
Commands cannot be accepted.
DnB FDn Busy Drive n is executing a seek operation using the SEEK command,
or an interrupt request to complete the seek operation is pending.
FBhW FDC ƒÊPD765A data register write
R FDC ƒÊPD765A data register read
FChR/W Disk subsystem I/F 8255 port A
In the standard state, it is a data reception port from the host.
FDhR/W Disk subsystem I/F 8255 port B
In the standard state, it is a data transmission port to the host.
FEhR/W Disk subsystem I/F 8255 port C

Bit76543210
R/WWR
Signal
DAC RFD DAV ATN DAC RFD DAV
FFhW Disk subsystem I/F 8255 control

¡ Subsystem memory map

    0000h   +---------------+
            |  System ROM   |
    0800h   |---------------|
            |    Vacant     |
    4000h   |---------------|
            |  Write Buffer |
    5000h   |---------------|
            |  Read Buffer  |
    6000h   |---------------|
            |    Unused     |
    7F00h   |---------------|
            |   Work Area   |
    8000h   |---------------|
            |    Vacant     |
    FFFFh   +---------------+
The M series system ROM is 8K bytes (0000h to 1FFFh).