Parent


IBM Fixed Disk Adapter  -  Behaviour of Some INT 13h Function Calls


WARNING:   This web page is about the IBM Fixed Disk Adapter.
Other controllers can behave differently.


Below, I show how DEBUG.COM can be used to execute some INT 13h functions.

It is relevant to recognise that:
IBM 5150/5155/5160 without IBM Fixed Disk Adapter:  INT 13h supports only the floppy disk system (because the 5150/5155/5160 motherboard BIOS knows nothing about hard drives).
IBM 5150/5155/5160 with IBM Fixed Disk Adapter:  INT 13h supports both the hard disk system and the floppy disk system.

It is very important to recognise that the 'behaviour' shown below is for the IBM Fixed Disk Adapter.  Other XT-class hard disk controllers could behave differently.  For example, maybe some makers do not support function 12h (controller RAM test) because their function 14h (controller self test) tests the RAM.  For example, some functions were dropped in the move to the AT (example).

Per here, there are three major variations of the IBM Fixed Disk Adapter.   The following reflects behaviour of variation #3.

Below, I show the segment as 'xxxx'.  That is because the segment that DEBUG.COM uses varies.  If I was to show the segment that I saw, some people would worry because the segment displayed to them was different.

For educational purposes, the code is not optimised.  E.g. Setting both DH and DL registers can be done at the same time.



Function 00h - Reset controller

EXECUTION

Boot from a DOS boot disk that contains DEBUG.COM

Execute DEBUG.  DEBUG will present a dash ("-") prompt.  When you see that prompt, enter the following commands (shown in brown):

- a 100  
xxxx:0100 mov ah,0  (Comment: Function 00h)
xxxx:0102 mov dl,80  (Comment: Hard drive 0)   (Comment: Required to inform INT 13h that the target is the hard disk system [not the floppy disk system])
xxxx:0104 int 13  
xxxx:0106 int 3  (Comment: Breakpoint return for DEBUG)
xxxx:0107  <----- at this line just press the [ENTER] key - this will return DEBUG's dash prompt
- g=100  

OBSERVED BEHAVIOUR

Executing this function on my good hardware, DEBUG showed that no error was returned, i.e. the status code returned in the AH register was 00 and the carry flag (CF) was 0.  Both AH and CF being zero indicates 'no error'.  (Example DEBUG screenshot)

And as expected, when no hard drive was connected to the IBM Fixed Disk Adapter, executing this function also returned no error (i.e. the status returned was AH=00 and CF=0).

When I then removed the IBM Fixed Disk Adapter from the computer, then executed the function, also returned was no error (i.e. the status returned was AH=00 and CF=0).
The lack of an error will be because, without the IBM Fixed Disk Adapter present, INT 13h does not know about the hard disk system and as a result, function 00h was performed against the floppy disk system.

WARNING

No error (AH=00 and CF=0) will also be returned in the following three fault scenarios:

Scenario Comment
IBM Fixed Disk Adapter - Missing its BIOS expansion ROM No on-screen indication of missing ROM at computer start-up time
IBM Fixed Disk Adapter - BIOS expansion ROM's first two bytes are damaged No on-screen indication of failure at computer start-up time
IBM Fixed Disk Adapter - BIOS expansion ROM's other bytes are damaged "C8000 ROM" displayed by IBM 5160 at start-up time

In those three scenarios, INT 13h will not become aware of the hard disk system and as a result, function 00h will be performed against the floppy disk system.



Function 12h - Get controller to test its RAM

EXECUTION

Boot from a DOS boot disk that contains DEBUG.COM

Execute DEBUG.  DEBUG will present a dash ("-") prompt.  When you see that prompt, enter the following commands (shown in brown):

- a 100  
xxxx:0100 mov ah,12  (Comment: Function 12h)
xxxx:0102 mov dl,80  (Comment: Hard drive 0)   (Comment: Required to inform INT 13h that the target is the hard disk system [not the floppy disk system])
xxxx:0104 int 13  
xxxx:0106 int 3  (Comment: Breakpoint return for DEBUG)
xxxx:0107  <----- at this line just press the [ENTER] key - this will return DEBUG's dash prompt
- g=100  

OBSERVED BEHAVIOUR

Executing this function on my good hardware, DEBUG showed that no error was returned, i.e. the status code returned in the AH register was 00 and the carry flag (CF) was 0.  Both AH and CF being zero indicates 'no error'.  (Example DEBUG screenshot)

And as expected, when no hard drive was connected to the IBM Fixed Disk Adapter, executing this function also returned no error (i.e. the status returned was AH=00 and CF=0).

When I then removed the IBM Fixed Disk Adapter from the computer, then executed the function, an error was returned, specifically the status code of AH=01 and CF=1  (AH=01 meaning 'bad command', and CF=1 meaning 'error')
Without the IBM Fixed Disk Adapter present, INT 13h does not know about the hard disk system and as a result, function 12h was performed against the floppy disk system.
Function 12h is an invalid command for the floppy disk system, and as a result, a 'bad command' error was returned by INT 13h.



Function 14h - Get controller to do a self-test

EXECUTION

Boot from a DOS boot disk that contains DEBUG.COM

Execute DEBUG.  DEBUG will present a dash ("-") prompt.  When you see that prompt, enter the following commands (shown in brown):

- a 100  
xxxx:0100 mov ah,14  (Comment: Function 14h)
xxxx:0102 mov dl,80  (Comment: Hard drive 0)   (Comment: Required to inform INT 13h that the target is the hard disk system [not the floppy disk system])
xxxx:0104 int 13  
xxxx:0106 int 3  (Comment: Breakpoint return for DEBUG)
xxxx:0107  <----- at this line just press the [ENTER] key - this will return DEBUG's dash prompt
- g=100  

OBSERVED BEHAVIOUR

Executing this function on my good hardware, DEBUG showed that no error was returned, i.e. the status code returned in the AH register was 00 and the carry flag (CF) was 0.  Both AH and CF being zero indicates 'no error'.  (Example DEBUG screenshot)

And as expected, when no hard drive was connected to the IBM Fixed Disk Adapter, executing this function also returned no error (i.e. the status returned was AH=00 and CF=0).

When I then removed the IBM Fixed Disk Adapter from the computer, then executed the function, an error was returned, specifically the status code of AH=01 and CF=1  (AH=01 meaning 'bad command', and CF=1 meaning 'error')
Without the IBM Fixed Disk Adapter present, INT 13h does not know about the hard disk system and as a result, function 14h was performed against the floppy disk system.
Function 14h is an invalid command for the floppy disk system, and as a result, a 'bad command' error was returned by INT 13h.



Function 10h - See if hard drive reports as 'ready'

EXECUTION

Boot from a DOS boot disk that contains DEBUG.COM

Execute DEBUG.  DEBUG will present a dash ("-") prompt.  When you see that prompt, enter the following commands (shown in brown):

- a 100  
xxxx:0100 mov ah,10  (Comment: Function 10h)
xxxx:0102 mov dl,80  (Comment: Hard drive 0)
xxxx:0104 int 13  
xxxx:0106 int 3  (Comment: Breakpoint return for DEBUG)
xxxx:0107  <----- at this line just press the [ENTER] key - this will return DEBUG's dash prompt
- g=100  

OBSERVED BEHAVIOUR

Executing this function on my good hardware, DEBUG showed that no error was returned, i.e. the status code returned in the AH register was 00 and the carry flag (CF) was 0.  Both AH and CF being zero indicates 'no error'.  (Example DEBUG screenshot)

When I then removed the data cable from the IBM Fixed Disk Adapter, this function still returned no error (i.e. the status returned was AH=00 and CF=0).

When I then removed the control cable from the IBM Fixed Disk Adapter, an error was returned, specifically the status code of AH=80 and CF=1 (AH=80 meaning 'timeout', and CF=1 meaning 'error')

COMMENT

For this function to pass, it requires:
• Good IBM Fixed Disk Adapter
• Hard drive that is 'ready' (i.e. when the hard drive is selected by the controller, the hard drive will assert its READY line to indicate that it is 'ready')
Control cable in place
• Setting of drive-select on the hard drive is correct for the type of control cable - see here



Function 11h - Recalibrate drive

EXECUTION

Boot from a DOS boot disk that contains DEBUG.COM

Execute DEBUG.  DEBUG will present a dash ("-") prompt.  When you see that prompt, enter the following commands (shown in brown):

- a 100  
xxxx:0100 mov ah,11  (Comment: Function 11h)
xxxx:0102 mov dl,80  (Comment: Hard drive 0)
xxxx:0104 int 13  
xxxx:0106 int 3  (Comment: Breakpoint return for DEBUG)
xxxx:0107  <----- at this line just press the [ENTER] key - this will return DEBUG's dash prompt
- g=100  

OBSERVED BEHAVIOUR

It was seen that the if the heads were not at cylinder 0, the controller took them there.  DEBUG showed that no error was returned, i.e. the status code returned in the AH register was 00 and the carry flag (CF) was 0.  Both AH and CF being zero indicates 'no error'.  (Example DEBUG screenshot)

Removing the data cable had no effect on this behaviour (including time taken to move heads).  And no error was returned (i.e. the status returned was AH=00 and CF=0).

The above indicates that for this function, the IBM Fixed Disk Adapter simply steps the heads, not reading sectors on the platter surface.  It will know when it reaches cylinder 0 when the MFM drive asserts the TRACK 0 pin on its 'control' connector (i.e. heads are on cylinder 0).



Function 0Ch - Seek to a specified cylinder

EXECUTION

Boot from a DOS boot disk that contains DEBUG.COM

Execute DEBUG.  DEBUG will present a dash ("-") prompt.  When you see that prompt, enter the following commands (shown in brown):

- a 100  
xxxx:0100 mov ah,0C  (Comment: Function 0Ch)
xxxx:0102 mov dl,80  (Comment: Hard drive 0 )
xxxx:0104 mov cx,4001  (Comment: Cylinder 40h, Sector 1)  (Comment: Cylinder number contained in CH and two bits of CL)
xxxx:0107 int 13  
xxxx:0109 int 3  (Comment: Breakpoint return for DEBUG)
xxxx:010A  <----- at this line just press the [ENTER] key - this will return DEBUG's dash prompt
- g=100  

OBSERVED BEHAVIOUR

It was seen that the heads moved to the specified cylinder.  DEBUG showed that no error was returned, i.e. the status code returned in the AH register was 00 and the carry flag (CF) was 0.  Both AH and CF being zero indicates 'no error'.  (Example DEBUG screenshot)

Removing the data cable resulted in no move, and an error was returned, specifically the status code of AH=40 and CF=1 (AH=40 meaning 'seek failed', and CF=1 meaning 'error').
That suggests to me that before any seek, the IBM Fixed Disk Adapter reads a sector from the current cylinder.

Based on the above, it is expected that for this function to work, the IBM Fixed Disk Adapter needs to be able to recognise the low-level format on the drive's platters.


( As an example of how different model controllers can behave differently, the IBM supplied controller within the IBM 5170 will happily seek away with the data cable removed. )



Function 13h - Drive Diagnostic

EXECUTION

Boot from a DOS boot disk that contains DEBUG.COM

Execute DEBUG.  DEBUG will present a dash ("-") prompt.  When you see that prompt, enter the following commands (shown in brown):

- a 100  
xxxx:0100 mov ah,13  (Comment: Function 13h)
xxxx:0102 mov dl,80  (Comment: Hard drive 0)
xxxx:0104 int 13  
xxxx:0106 int 3  (Comment: Breakpoint return for DEBUG)
xxxx:0107  <----- at this line just press the [ENTER] key - this will return DEBUG's dash prompt
- g=100  

OBSERVED BEHAVIOUR

Step 1:  If the heads are not at cylinder 0, the heads move there.
Step 2:  Then the heads are seen to slowly step to the final cylinder.  The heads are left at the final cylinder.

For an ST-412, the above two steps took about 30 seconds in total to complete.

With the data cable removed, step 1 occurs, but not step 2.  An error was returned, specifically the status code of AH=02 and CF=1 (AH=02 meaning 'address mark not found', and CF=1 meaning 'error').

Based on the above, it is expected that for this function to work, the IBM Fixed Disk Adapter needs to be able to recognise the low-level format on the drive's platters (i.e. for function 13h , the IBM Fixed Disk Adapter reads sectors).



Function 05h - Low level format a specified cylinder+head combination

EXECUTION

Boot from a DOS boot disk that contains DEBUG.COM

Execute DEBUG.  DEBUG will present a dash ("-") prompt.  When you see that prompt, enter the following commands (shown in brown):

- a 100  
xxxx:0100 mov ah,05  (Comment: Function 05h)
xxxx:0102 mov dl,80  (Comment: Hard drive 0)
xxxx:0104 mov cx,6001  (Comment: Cylinder 60h, Sector 1)  (Comment: Cylinder number contained in CH and two bits of CL)
xxxx:0107 mov dh,0  (Comment: Head 0)
xxxx:0109 mov al,5  (Comment: Sector interleave of 5)
xxxx:010B int 13  
xxxx:010D int 3  (Comment: Breakpoint return for DEBUG)
xxxx:010E  <----- at this line just press the [ENTER] key - this will return DEBUG's dash prompt
- g=100  

OBSERVED BEHAVIOUR

The heads are seen to step to the specified cylinder.  The heads are left at the cylinder.

With the data cable removed, the function results in three 'recalibrations' being seen (out to specified cylinder then back to cylinder 0), and an error was returned, specifically the status code of AH=02 and CF=1 (AH=02 meaning 'address mark not found', and CF=1 meaning 'error').

Suggested by the above is that, after the format of the specified cylinder/head, the IBM Fixed Disk Adapter reads back the sectors that were written.

COMMENT

In low-level formatting code, the programmer will usually use function 0Fh before subsequent use of function 05h, in order to populate the controller's sector buffer with the data that is to go into the sectors that will be created.
If I was writing low-level formatting code, I would populate the controller's sector buffer full of zeroes.