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,00  (Comment: [00] = function 00h of INT 13h )
xxxx:0102 mov dl,80  (Comment: [80] = 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  (Comment: INT 13h)
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  (Comment: Executes the code that we typed in above)

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 I 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.


OTHER CONTROLLERS

As an example of how different model controllers can behave differently, the WDXT-GEN is known to fail function 00h if a hard drive is not (properly) connected to it, or the connected drive is not reporting as 'ready'.



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: [12] = function 12h of INT 13h )
xxxx:0102 mov dl,80  (Comment: [80] = 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  (Comment: INT 13h)
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  (Comment: Executes the code that we typed in above)

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 I 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: [14] = function 14h of INT 13h )
xxxx:0102 mov dl,80  (Comment: [80] = 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  (Comment: INT 13h)
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  (Comment: Executes the code that we typed in above)

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 I 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: [10] = function 10h of INT 13h )
xxxx:0102 mov dl,80  (Comment: [80] = hard drive 0 )  ([81] = hard drive 1 )
xxxx:0104 int 13  (Comment: INT 13h)
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  (Comment: Executes the code that we typed in above)

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 work, 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.
• Proper drive termination.
• 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: [11] = function 11h of INT 13h )
xxxx:0102 mov dl,80  (Comment: [80] = hard drive 0 )  ([81] = hard drive 1 )
xxxx:0104 int 13  (Comment: INT 13h)
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  (Comment: Executes the code that we typed in above)

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

In the example below, we will get the heads to seek to cylinder 64  (40 hex).

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: [0C] = function 0Ch of INT 13h )
xxxx:0102 mov dl,80  (Comment: [80] = hard drive 0 )  ([81] = hard drive 1 )
xxxx:0104 mov cx,4001  (Comment: Cylinder 40h, sector 1.  Cylinder number contained in CH and upper two bits of CL.  Sector number in lower 6 bits of CL )
xxxx:0107 int 13  (Comment: INT 13h)
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  (Comment: Executes the code that we typed in above)

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)

I saw the hard drive's stepper flag move to cylinder 64  (40h).

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.


OTHER CONTROLLERS

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 02h - Read sector/s

In the example below, we will read in the first sector on {cylinder=64}{head=0}.

IMPORTANT

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.

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 80  
xxxx:0080 mov ah,02  (Comment: [02] = function 02h of INT 13h )
xxxx:0082 mov dl,80  (Comment: [80] = hard drive 0 )  ([81] = hard drive 1 )
xxxx:0084 mov dh,00  (Comment: [00] = head 0 )
xxxx:0086 mov cx,4001  (Comment: Cylinder 40h, sector 1.  Cylinder number contained in CH and upper two bits of CL.  Sector number in lower 6 bits of CL )
xxxx:0089 mov al,01  (Comment: [01] = 1 sector is to be read)
xxxx:008B mov bx,0100  (Comment: Point ES:BX to our local data buffer)
xxxx:008E int 13  (Comment: INT 13h)
xxxx:0090 int 3  (Comment: Breakpoint return for DEBUG)
xxxx:0091      <------------------------ at this line just press the [ENTER] key - this will return DEBUG's dash prompt
- g=80  (Comment: Executes the code that we typed in above)

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)

I saw the hard drive's stepper flag move to cylinder 64 (40h).

COMMENT #1

For this function to work, 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').
• Proper cabling.
• Proper drive termination.
• Setting of drive-select on the hard drive is correct for the type of control cable - see here.
• The low-level format on the drive's platters is compatible with the IBM Fixed Disk Adapter.

COMMENT #2

If the function returns no error, and you want to write the sector that was read to a file, then type in the following commands (shown in brown) after the earlier commands:

- n mysector.bin  (Comment: file will be named MYSECTOR.BIN)
- rbx  
BX 0100  
: 0  (Comment: BX = high-order file size = 0000)
- rcx  
CX 4001  
: 200  (Comment: CX = low-order file size = 0200h [512 decimal] )
- w100  (Comment: write from offset 0100 in local segment to file)
Writing 0200 bytes  
-  


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: [13] = function 13h of INT 13h )
xxxx:0102 mov dl,80  (Comment: [80] = hard drive 0 )  ([81] = hard drive 1 )
xxxx:0104 int 13  (Comment: INT 13h)
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  (Comment: Executes the code that we typed in above)

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 track (track = a 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: [05] = function 05h of INT 13h )
xxxx:0102 mov dl,80  (Comment: [80] = hard drive 0 )  ([81] = hard drive 1 )
xxxx:0104 mov cx,6001  (Comment: Cylinder 60h, sector 1.  Cylinder number contained in CH and upper two bits of CL.  Sector number in lower 6 bits of CL )
xxxx:0107 mov dh,00  (Comment: [00] = head 0 )
xxxx:0109 mov al,05  (Comment: [05] = Use a sector interleave of 5 )
xxxx:010B int 13  (Comment: INT 13h)
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  (Comment: Executes the code that we typed in above)

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.

COMMENT

The sector interleave figure affects performance only.  For best performance, the sector interleave used depends on the specific system (motherboard, clock speed, etc.)  Therefore, there is no global 'it is best use' figure.  After a drive is up and running in a computer, SpinRite software can be used to find the optimal interleave (for that drive in that computer).  Note that for XT clones that have non-turbo/turbo functionality, the optimal interleave varies between non-turbo operation and turbo operation.