Materials:Working complete PCBlank DisketteStudent Diskette, "New Boot A Ver 2.0+"Student CD-ROM, "Room 6359"Objectives:The student will become familiar with the BIOS INT 13h Interface including: the passed parameters,how to read and write a sector in DEBUG.Competency:The student will learn how to use the BIOS INT 13h interface for the purposes of data recovery including the definitions of the passed parameters to the call and how to read and write a physical sector using DEBUG to execute the INT 13h call.

Preparation

In the first exercise, Basic DEBUG commands, the student learned how to clear the DEBUG RAM workspace by filling it with zeros, how to load a physical sector, specifically the floppy diskette's boot sector, into that RAM workspace, and how to display it on screen. Perform these operations first so that the workspace is cleared, the sector has been loaded into it and displayed on screen, then proceed with the following procedures.

Procedures

The BIOS holds the low level 16-bit device drivers for all of the "primitive" devices including the keyboard, floppy disk controller, hard disk controller, and the common text mode video card interfaces. DOS calls these low level drivers in order to actually access these devices. This is what makes DOS portable across all IBM compatible machines. DOS however insists on certain file system structures to be intact in order to be able to access the disk. If these structures, which are pure software structures written into certain sectors of the disk, are corrupt, then DOS will fail to read the disk at hte prompt. In this case it becomes necessary to access the disk sector by sector.

This can done using the BIOS INT 13h interface, which DOS uses, directly. The interface will deliver a physical sector from the disk or write one directly to the disk. This means that the technician must KNOW with NO DOUBT, which one is being read and which one is being written. A mistake can cause far more damage than the original problem that put the machine in the technician's hands in the first place. First, the interface must be told the following information:

Is this a read of a sector or a write to a sector?

Where in RAM will the information of the sector be located?

Which drive is being accessed (floppy A: drive, first hard drive, etc.)?

Which sector is being accessed (requires its geometric coordinate including the cylinder, head and sector of the track)?

These pieces of information are sent to INT 13h by loading the values into the processor registers prior to calling the software interrupt. Here are the registers and the valid values they can hold:

Register

Value=Meaning

AH(top byte of AX)

02=READ SECTOR(S), 03=WRITE SECTOR(S)

AL(low byte of AX)

n=number of sectors to read/write

BX

n=RAM offset within the program where the sector is

CH(top byte of CX)

n=low 8-bits of the cylinder number

CL(low byte of CX)

n=hi 2-bits of cyl# and the 6-bit sector#

DH(top byte of DX)

n=head#

DL(low byte of DX)

n=BIOS drive#

When writing the assembly language code to set the registers prior to the call, it is a common practice to combine the AH + AL into a single 16-bit value to set across the AX register. For example, both of the following pieces of code prepare to read one sector:

mov ah, 02
mov al, 01
or
mov ax, 0201

It is easier to combine the values and write one line of code than to write two lines of code that do the same thing. Here are the values needed to read the sector located on cylinder 99h, head 4, sector 17h of the first hard drive into RAM offset 100h:

These represent the values that must be placed into the DL register in order to access the correct drive. NOTE: Older BIOS'es "hard assign" 80h to the Primary Master, 81h to the Primary Slave, etc. Modern BIOS'es assign these BIOS drive numbers in accordance with the "BIOS Discovery Order." So the first drive found in the following list will get 80h, and second one found proceeding down the list will get 81h, etc.:

The code could now be compiled into an executable program or it can be executed within DEBUG. However, since the sector address was randomly selected to illustrate how to set up the registers for a complex call and the information in that sector is unpredictable this will not be done. Instead, needed sectors that do contain important information will be read and written to in future exercises using these fundamental concepts to calculate and build the correct assembly language instructions for the calls.