Hardware Reference
In-Depth Information
The state of the processor registers is displayed as each instruction is executed
together with the next instruction in disassembled format. Taking the results
of executing the first instruction ( MOV AH,05 ) as an example, we see that 05
has appeared in the upper byte of AX ( AH ) and the Instruction Pointer ( IP ) has
moved on to offset address 0102 . The next instruction to be executed (located
at the address which IP is pointing to) is MOV DL,0A . The state of the processor
flags is also shown within the register dump. In this particular case, none of the
flags has been changed as a result of executing the instruction.
In order to obtain a hard copy of the program trace, a <CTRL-P> command
can be issued immediately before issuing the Proceed ( P ) command. From
that point onwards, screen output was echoed to the printer. Since the pro-
gram directs is own output to the printer, this also appears amidst the traced
output.
A single character, A, is printed after the eighth instruction (see arrow marked
on Figure 3.11). Thereafter, the program executes the loop formed by the
instructions at offset addresses 0112 and 0114 . However, no printing takes
place within this loop even though the DL register is incremented through the
required range of ASCII codes ( 41 to 7F ). Clearly the loop is not returning to
the INT 21 instruction which actually makes the required calls into DOS.
Fortunately, we can easily overcome this problem from within the debugger
without returning to the macro assembler. We simply need to modify the LOOP
instruction at offset address 0114 . To do this we can make use of the Assemble
( A ) command to overwrite the existing instruction. The required command is:
A 114
The CS:IP prompt is then displayed (in this case it shows 1662:0114 ) after
which we simply enter:
LOOP 0110
However, the CS:IP prompt is incremented since we need to make no further
changes to the code, we can simply escape from the Debug line assembler by
simply pressing <ENTER> .
Having modified our code, we can again trace the program using the Proceed
( P ) command exactly as before. The traced output produced by the modified
program is shown in Figure 3.12. Note that we have now succeeded in producing
a line of printed output showing the full range of characters (see arrow marked
on Figure 3.12).
Since no further errors have been found, we can exit from Debug, load the
macro assembler, make the necessary changes to our source code, assemble
and link to produce a modified EXE program file. The corrected source code is
shown in Figure 3.13.
Using Debug's line assembler
Debug has an in-built line assembler which can be used to generate simple
programs. The assembler is accessible from within Debug (as described in the
previous section), but can also be accessed by means of a script file that can be
generated by any word processor or text editor capable of producing an ASCII
text file (or even by means of the DOS COPY command).
Search WWH ::




Custom Search