Chapter 11
Boot process

The boot-up process begins when the reset circuit in the clock generator chip produces the reset pulse that is applied to pin 21 of the 8088 CPU. This pin is connected to the reset circuit inside the micro-processor to force a reset address on address bus A0 thur A20. This will execute a jump instruction at address F000:FFF0 inside the ROM bios chip that points to the first instruction of the BIOS.
The ROM bios program is approximately 8K bytes long, and controls all of the hardware on the system board and interface cards. The CPU support chips are initialized with the proper default values to control such things as the video monitor, disk drives, printer ports and keyboard. After the initialization of all the hardware, the program executes a very extensive diagnostic type test on the 8088, ROMS, RAM etc. to complete what is called the POST or Power On Self Test.

If there are no critical errors during the POST, the A drive is turned on and tested for an open or closed door. The closed door condition will cause the head to position over track 0, head 0, sector 0 of the disk in the A drive and the boot loader program is transferred into memory. Once in memory, the boot loader program is given control of the CPU and a series of instructions are executed that will look in the directory of the disk for the system files, IBMBIO and IBM DOS. If these two system files are on the disk, they are loaded into low memory in that order, along with any driver programs that are listed in the device= statement of config.sys. Control of the CPU is then given to the IBMDOS program to finish the boot up process, by loading COMMAND.COM into memory in the next available space right after IBMDOS.

The boot process is complete when COMMAND.COM is given the final control of the CPU and the A prompt appears. If the system files do not exist or they are corrupt in any way, the boot loader program will display the familiar message " DISK BOOT FAILURE ".

An open door in the A drive will cause the boot process to continue from the C drive if it exist.

Debugging a program

Debug is very useful to use when debugging a program or running the program for the first time.
When a program has an error in the code and it is executed, most likely the computer will lock up making it necessary for you to reboot the machine. This can be prevented by executing only a small part of the code at a time to verify that it is OK and it does what you expect it to do. Below is the code of a small program and an explanation of how I would use the address and breakpoint parameters to debug it.

Assemble the following program and save it to the disk with the name BREAK.COM if you intend to try any of the following. In order to use breakpoint for debugging you must reload the program from the disk each time the program terminated normally.

CS:0100 MOV AH,9 |
CS:0102 MOV DX,200 | print a message on the screen
CS:0105 INT 21 _|
CS:0107 MOV AH,7 | read the keyboard and put ascii
CS:010B INT 21 | code into the al register.
CS:010B CMP AL,1B | see if it was the escape key
CS:010D JZ 0112 _| and if it was end the program
CS:010F JMP 108 _| if it wasn't the escape, read
another key
CS:0111 INT 20 _| end the program and return to

This is a very simple program that will print a short message on the screen. The message is stored in memory at offset 200 and the last character of the message is the dollar sign ($) or HEX 24. The HEX 24 ($) is what we call the end of file marker (EOF).

After the message is displayed properly, the program continues to the next part of the program, which will pause and wait for us to press a key on the keyboard. When we press any key the ascii code for that key is stored inside the al register where it will be used later.

When a key is pressed the program will test it to see if the ascii code is equal to HEX 1B. If the Test proves to be true (equal) the program will terminate and return to DOS.

If the test proves not true (not equal) then the program jumps up to the instructions that will read a key. This program repeats until We press the ESCAPE key on the keyboard.

I have divided the program up into blocks of code that will preform a function when executed, the functions in this program are:

1. Print a message on the screen.(offset 100-107)
2. Read a key from the keyboard. (offset 107-10B)
3. Test the key for HEX 1B. (offset 10B)
4. End if it is 1B. (offset 10D)
5. Get another key. (offset 10F)
6. End (offset 111)

Debugging the program

To debug the program we are going to use the P command and the G command to either single step through the program one instruction or interrupt at a time or a group of instructions up to a specific offset. After breaking the code up into groups of instructions that preform a function, we can execute them to verify proper operation. Refer to the program above for the next few steps.

The instructions from 0100 to 0106 will display a message on the screen when the INT 21 instruction is executed. To test this group of instructions use the G command to set break-points used by debug to control the flow of the program. Reset the IP register to 0100 and then enter,

G=100 107 (return)

This will execute all the instructions starting at offset 0100 and ending at offset 0107. If the code in this part of the program is valid, the message that is stored at offset 200 will be displayed on the screen.

The G command is being used with a start address followed by an end address that stops the micro-processor from executing pass a specific instruction. (This is called a break-point)

If for some reason the message was not displayed on the screen, we could conclude that there is a problem with the code in that group of instructions. To test the instructions one at a time, we will reset the IP register back to 0100 and then enter the P command.

P (return)

The P command is very similar to the T (trace) command, in that only one instruction at a time will be executed. However, the P command will execute an INT instruction, Where as the T command will not. Either one could be used here since the instruction being tested is a simple move instruction which will be verified by checking the AH register after the MOV AH,9 instruction is executed. The P and T command show the contents of the registers after the instruction is executed. The IP register is updated by the micro-processor and will be pointing to the next instruction in the program. If this instruction worked properly and is valid enter,

P (return)

This will execute the next MOV instruction at offset 102. Again, we will check the registers to verify the MOV DX,200 instruction. Enter,

P (return)

and the INT instruction at offset 0105 is executed to display the message.

This process should continue until you locate the code that is not working properly in the program.

G=100,107 To test the message code.
G=107,10B To test the keyboard input.
G=10B,10F To test the compare instruction.
G=10F To test the jump instruction.

Power on self test
of test Description working Failure

1 8088 processor test none halt at FEOAD
2 BIOS ROM check sum none halt at FE0AD
3 Timer-1 test speaker click halt at FE0AD
4 Initialize Timer-1 none none
5 Test DMAC channel-0 none halt at FE12D
6 Initialize DMAC 0 none halt at FE15C
for refresh
7 Test 1st 16K of Ram none system halts
8 Initialize PIC none none
9 read configuration none none
10 Init CRT and test cursor beep 1long 2short
video Ram appears
11 Test PIC none "101" halt at
12 Test PIT channel-0 none "101" halt at
13 Keyboard test none "301"+scan code
14 Set INT table none none
15 Test expansion
16 Test all Ram display DMA failure
17 Test refresh xxxK OK "101" halt at
18 Check for ROM basic none Display "ROM"
19 Test disk drv. adpt. motor on Display "601"
20 Init ser/par printer none none
21 Display error message cls "error resume=F1"
2 short beeps
22 Enable NMI none "Parity check 1"
"Parity check 2"
halt at FE8EF
23 Boot DOS from disk DOS prompt Boot from ROM

Creating a COM program that will display a text file on the screen.
Step 1. Using any word processor, generate the text file that you would like to be displayed and end it with the dollar sign character ($).
Return to the top of the text file and enter one line of spaces that will reserve 80 bytes of the file to be used later. Save it to the disk as text.txt.

Step 2. Load the text.txt file into debug, using the command
DEBUG TEXT.TXT. Using the dump command, verify that the file is entered properly in memory. You should notice that the first 50 hex bytes are 20, the ascii code for the space character.
When the file was created you entered 80 spaces, which is equal to 50 hex spaces.

Step 3. Assemble the following code starting at offset 100.
XXXX:0100 MOV AH,09
MOV DX,150
INT 21
INT 20

Step 4.Using the name command, enter the new name with a .COM extension. (TEXT.COM)
Find the offset number for the end of the file ($)
and set the CX register for the number of bytes.
Enter w to write the file to the disk. Quit debug and enter the name of the com file you just assembled. If the program is working ok, it will be displayed on the screen.

How to assemble a COM program.

After you have converted the flow chart of your program into the instruction code on paper, you are ready to begin the assembly process using Debug as the assembler. At the debug prompt (-) enter A 100 (return). You should see the segment-offset on the left side of the screen. We start assembly of all COM programs at offset 100 because the first 100 hex bytes is reserved for the Program Segment Prefix.(0-FF) If there isn't a valid instruction at offset 100, the program will cause the computer to crash, requiring a reboot of the system.
Follow these steps to assemble a program that will display the ascii code on the screen in a different way.

A100 (return)

XXXX:0100 MOV CX,7D0 (return)
XXXX:0103 MOV AH,09 (return)
XXXX:0105 MOV BH,50 (return)
XXXX:0107 MOV BL,DL (return)
XXXX:0109 MOV AL,DL (return)
XXXX:010B INT 10 (return)
XXXX:010D INC DL (return)
XXXX:010F LOOP 0103 (return)
XXXX:0111 INT 20 (return)
XXXX:0113 (return)

When in the A or assemble mode, debug will automatically calculate the offset for the next instruction. After the first instruction is entered at offset 100, debug displays the next offset available for the next instruction. In this program the instruction MOV CX,7D0 requires 3 bytes of memory starting at 0100 and going to 0102. The next instruction (MOV AH,09) will start at offset 0103.
The last instruction of the program must be an INT 20 in order to end the program properly. This is a two byte instruction located at offset 0111. This is determined by observing the offset of the next available instruction which is at 0113.

To write the program to the disk, you must name it with the N command, set the file size with the CX register and then enter W to do the actual writing to the disk.

_n a:\ (return)

_R cx
:13 (return)

_w (return)

We entered the complete path for the file name so that it would be written to a specific disk and directory. (A:\)
The file size was determined by subtracting 100 from 113, which is the next byte after the last instruction of the program. We subtract from 100 because that is the offset that the program started at. (113 - 100 = 13)

Since the name and file size is entered properly, the last step is to simply enter W.
If all the steps were done properly, you can quit debug (q) and at the DOS prompt enter DIR to see if the file is listed in the directory. Notice that the file size is 19 byte decimal or 13 bytes hex.
Enter ascii (return)

and the program should execute and display the ascii code from the bottom of screen to the top.

Getting the keyboard status byte

Interrupt 16 Function 2 will return one byte of information about the status of certain keys on the keyboard. The keys that are tested for their status are the Insert, Caps lock, Num lock, Scroll lock, Alt, Ctrl, Left shift and the right shift. The interrupt indicates whether or not the keys are active by setting a bit in the AL register on return. If a bit is set (logic one), than the key is pressed, a clear bit (logic 0) indicates that the key is not pressed.

Interrupt 16 Function 2 Get keyboard status

Input Output

Still under construction.

  • Return to Home Page.