LABORATORY 10:
Debugging a
Program
Now we will debug a program that
contains an execution error by executing the program step by step and observing
program operation with DEBUG commands.
1.
Insert the Programs Diskette
into drive A of the PC.
2.
Select drive A.
3.
Use the TYPE command to display the
source listing in file L3P3.LST that resides on the Programs Diskette. What is
the starting address offset from CS: for the first instruction (PUSH DS) of the
program? CS:00
The last
instruction (RET) of the program? CS:1C
A:\>TypeL3P3.LST ¿
![]()
Microsoft (R) Macro Assembler Version
5.10 2/6/93 23:29:19
BLOCK-MOVE PROGRAM Page 1-1
TITLE BLOCK-MOVE PROGRAM
PAGE ,132
COMMENT
*This program moves a block of specified number of bytes
from
one place to another place*
;Define
constants used in this program
=
0010 N = 16
;Bytes to be moved
=
0100 BLK1ADDR= 100H ;Source block offset address
=
0120 BLK2ADDR= 120H ;Destination block offset addr
=
1020 DATASEGADDR= 1020H ;Data
segment start address
0000 STACK_SEG SEGMENT STACK 'STACK'
0000 0040[ DB 64
DUP(?)
??
]
0040 STACK_SEG ENDS
0000 CODE_SEG SEGMENT 'CODE'
0000 BLOCK
PROC FAR
ASSUME CS:CODE_SEG,SS:STACK_SEG
;To
return to DEBUG program put return address on the stack
0000 1E PUSH DS
0001 B8 0000 MOV AX, 0
0004 50 PUSH AX
;Set
up the data segment address
0005 B8 1020 MOV AX, DATASEGADDR
0008 8E D8 MOV DS, AX
;Set
up the source and destination offset adresses
000A BE 0100 MOV SI, BLK1ADDR
000D BF 0120 MOV DI, BLK2ADDR
;Set
up the count of bytes to be moved
0010 B9 0010 MOV
CX, N
;Copy
source block to destination block
0013 8A 24 NXTPT: MOV AH,
[SI] ;Move a byte
0015 88 25 MOV [DI], AH
__Microsoft (R) Macro Assembler Version
5.10 2/6/93 23:29:19
BLOCK-MOVE PROGRAM Page 1-2
0017 46 INC SI ;Update pointers
0018 4F DEC DI
0019 49 DEC CX ;Update byte counter
001A 75 F7 JNZ NXTPT ;Repeat for
next byte
001C CB RET ;Return
to DEBUG program
001D BLOCK ENDP
001D CODE_SEG ENDS
END BLOCK ;End
of program
Microsoft (R) Macro Assembler Version
5.10 2/6/93 23:29:19
BLOCK-MOVE PROGRAM Symbols-1
Segments and Groups:
N a m e
Length Align Combine
Class
CODE_SEG . . . . . . . . . . . . 001D PARA NONE 'CODE'
STACK_SEG
. . . . . . . . . . . 0040 PARA STACK 'STACK'
Symbols:
N a m e
Type Value Attr
BLK1ADDR . . . . . . . . . . . . NUMBER 0100
BLK2ADDR . . . . . . . . . . . . NUMBER 0120
BLOCK
. . . . . . . . . . . . . F PROC 0000 CODE_SEG Length = 001D
DATASEGADDR
. . . . . . . . . . NUMBER 1020
N .
. . . . . . . . . . . . . . NUMBER 0010
NXTPT
. . . . . . . . . . . . . L NEAR 0013 CODE_SEG
@CPU . . . . . . . . . . . . . . TEXT 0101h
@FILENAME
. . . . . . . . . . . TEXT l3p3
@VERSION . . . . . . . . . . . . TEXT 510
59 Source Lines
59 Total Lines
15 Symbols
47748 + 428247 Bytes symbol space free
0 Warning Errors
0 Severe Errors
·
![]()
4.
Load the run module L3P3.EXE with
the DOS command
A:\>DEBUG L3 P3.EXE (¿)

5.

Verify loading of the program by unassembling the
contents of the current code segment for the offset range found in step 3.
6.

Initialize memory the same way as done in step 5 of
lab 8.
7.
Execute the program according to the
instructions that follow:
a.

GO from address CS:00 through CS: 13. What has
happened to the values in DS, AX, CX, SI, and DI?
DS= 1020,
AX=1020, CX=0010, SI=0100, DI=0120
b. 
GO from address CS: 13 through CS:1A.
c.

Display the data from 2000:0100 through 2000:013E
Which byte of data was moved? Where was it moved to?
1020:100 à 1020:120
d. 
GO from address CS: IA to CS: 13. What has happened
to the value in IP?
IP:0013
e.
GO from address CS:13 through
CS: IA.

f.
Display the data from
2000:0100 through 2000:013F Which byte of data was moved Where was it moved to?

1020:101 à 1020:11F
g. GO from address CS: IA through CS: IC.

h.

Display the data from 2000:0100 through 2000:013E
Describe the block move operation performed by the program.
The block of data from
address DS:100 to DS:10F was copied to the block of storage locations from
DS:120 through DS:111
How does
it differ from the planned operation? Assume that it was to copy the block of
data from 2000:100 through 2000: 1 OF to the range 2000:120 through 2000:12F
Assuming that it was to
copy the block of data from 2000:100 through 2000: 1 OF to the range 2000:120
through 2000:12F, Then the block of data was copied to the wrong destination
block.
From the
printout of the program's operation, what is the error in the program?
The instruction used to
adjust the contents of DI is incorrect. It should be increment the value in DI
by 1; therefore, the correct instruction is INC DI.
8.
Exit DEBUG with the QUIT command.
9.
Remove the pages) of printed
information produced and label as Printout for Laboratory 10.