• Keine Ergebnisse gefunden

DEBUG PROGRAM EXECUTION CONTROL

Im Dokument first title (Seite 158-164)

70 GOTO 40:REM LOOP TILL EXIT

4.11 DEBUG - THE PDS 8080/8085 PROGRAM DEBUGGER

4.11.5 DEBUG PROGRAM EXECUTION CONTROL

DEBUG offers 3 modes of control to monitor progress through a program; the breakpoint mode, the single step mode, and the trace mode. There is a

permanent breakpoint facility normally used in conjunction with the commands SET, DISB~ CLR, EXEC and REPT. There is a temporary breakpoint facility used in conjunction with the commands CONT and RET. The single-step mode is controlled with the space bar. The trace mode is a form of continuous sing1e-stepping. Use of these modes and their associated commands are detailed in this section.

4.11.5.1 THE BREAKPOINT MODE

Breakpoints provide a means to stop program execution at a given point. When program execution reaches that point control of the processor is transferred to DEBUG. Once in DEBUG, the results of the program section which was executed may be examined or modified.

Rev. 8 9/78 4-81

In the breakpoint mode DEBUG replaces the instruction at a given address with one of the 'RST' instructions of the 8080/8085 (see 4.11.4.2 the RST command). Then DEBUG replaces the three bytes of code at the corresponding

'RST' vector location with a 'JMP' instruction to a routine inside itself.

DEBUG then loads the processor's registers with the stored 'user program register' values and transfers control of the processor to the user's program.

When the breakpointed instruction address is executed, the 'RST' that DEBUG had placed at that location causes the processor to 'CALL' the RST vector location which then causes the processor to 'JMP' back to DEBUG. DEBUG then stores the processor's registers in the 'user program registers' and replaces the original contents of both the breakpointed instruction and the RST

vector location.

Because of the introduction of an 'RST' instruction into the program, when a breakpoint is encountered, at least one level of stack space must be available so that the return address back into the program can be stored. Therefore, when using the breakpoint mode the user must insure that at least one stack

level will be,available when the breakpoint is encountered.

Note that breakpoints cannot be used to DEBUG ROMed code because an 'RST' instruction cannot be patched into the code.

When a breakpoint is encountered during program execution, DEBUG will display the contents of the program registers in the following format:

A FLAGS Be DE HL SP @B @D @H @SP 13 0000 0000 0000 01A2 00 00 00 l4FE

Refer to the DISR command section for a detailed description of this display.

4.11.5.2 PERMANENT BREAKPOINTS

Permanent breakpoints are set using the SET command. These breakpoints are not cleared when control of the processor is returned to DEBUG. Permanent breakpoints are only cleared by the CLR command. Permanent breakpoints can be used as traps on such things as error routines or executive loops.

Note that permanent breakpoints do not leave a 'RST' instruction in the program code. The existence of a permanent breakpoint tells DEBUG to place a breakpoint in the code only when the program is executing. Thus the original program is intact whenever the DEBUG has control of the processor

4.11.5.3 THE SET COMMAND SET <breakpoint #> <address>

T-he SET command aerlnes a permanent breakpoint. The breakpoint # and the hex address at which the breakpoint will be set are entered with the command.

More than one breakpoint # may be set with the same breakpoint address.

However, an attempt to SET a breakpoint # which is already set will cause the message SYNTAX ERROR to be printed and the command to be ignored. A maximum of 4 breakpoint liS may be set at any time. Example:

*SET 1 2354

Permanent breakpoint number 1 was set at location 2354 (hex).

Rev. 8 9/78 4-82

4.11.5.4 THE DISS COM~~ND

DISS

The OISB command displays all currently SET breakpoints.

Example:

DISB 01 2354 03 2365

The display indicates that breakpoint number 1 is set at address 2354 (hex) and breakpoint number 3 is set at address 2365 (hex). Breakpoints number 2 and 4 are not SET.

4.11.5.5 THE CLR COMMAND CLR [<breakpoint I>]

The CLR command clears a SET breakpoint. If the optional breakpoint number is not entered~ then all SET breakpoints will be cleared. If a breakpoint number is entered but is not currently SET. the message SYNTAX ERROR will be displayed.

Example:

*CLR 1

Permanent breakpoint number 1 is cleared.

4.11.5.6 THE EXEC COMMAND EXEC <starting address>

The EXEC command transfers control of the processor to the user's program.

The processor's PC register will be set to the entered starting address and execution will start there. If a breakpoint is encountered, control of the processor will be returned to DEBUG. If no permanent breakpoints are SET at that time, the program will retain control of the processor.

Example:

*EXEC 3014

A FLAGS BC DE HL SP @B @D @H @SP 00 Z C 0012 0341 3674 0195 00 00 00 3054 3507 JMP 3643

*

Program execution was started at location 3014 (hex). A breakpoint was encountered at location 3507 returning control back to DEBUG.

Rev. 8 9/78 4-83

.. .."

4.11.5.7 THE REPT COM~~ND

REPT <breakpoint #> <repeat count>

The REPT command transfers control to the user's program until a permanent breakpoint has been hit a given number of times. The breakpoint number entered specifies the breakpoint address and the entered repeat count specifies the number

of times it must be hit before control is transferred back to DEBUG. If any ~

breakpoint other than the one being repeated is encountered. control will be transferred back to DEBUG and the repeat operation is cancelled. If the

breakpoint # specified in the REPT command is not set. a SYNTAX error is displayed.

Example:

*SET 1 3000

*00 E 2000 0000 0000 0000 00 00 00 0000 3000 DCR B

*00 lF00 0000 0000 0000 00 00 ~0 0000 3001 JMP 3000

*REPT 1 8

A FLAGS BC DE HL SP @B @D @H @SP 00 E 1800 0000 0000 01A0 00 00 00 0000

*

The breakpoint at location 3000 (hex) is all.owed to be passed over 8 times before control is transferred back to DEBUG and the processor state is displayed.

4.11.5.8 TEMPORARY BREAKPOINTS

Temporary breakpoints are one-shot breakpoints which the user instructs DEBUG to place in the program by using the CaNT or RET commands. When control of the processor returns to DEBUG. the breakpoints are cleared.

Temporary breakpoints are the type normally used to follow the execution of the program from routine to routine.

4.11.5.9 THE CaNT COMMAND

CaNT [<break 1> [<break 2> [<break 3> [<break 4>JJJ3

The CaNT command continues execution of the user's program at the current PC location with up to four temporary specified breakpoints. If no temporary breakpoints are specified. then control will never return to DEBUG unless an already specified permanent breakpoint is encountered. Example:

*CONT 356F

A FLAGS BC DE HL SP @B @D @H @SP 00 M 0120 0341 3674 0195 00 00 00 3054 3507 DCR A

*

Program execution is resumed at the next instruction indicated by the value of the user program PC register and execution continues until the breakpoint at location 356F (hex) ;s encountered. which returns control back to DEBUG.

Rev. 8 9/78 4-84

4.11.5.10 THE RET COMMAND RET

The RET command transfers control of the processor to the user's program with a temporary breakpoint set at the address which is on the top of the stack (@SP). This allows the user to 'RETURN' from a subroutine which was

'CALL'ed by the program.

If a breakpoint other than the 'RET' breakpoint is hit, control will return . to the DEBUG and the 'RET' breakpoint will be cleared.

Note. The RET command should only be used after a 'CALL' type instruction has been executed or when the top of the stack contains a known return address. Otherwise a breakpoint might be piaced at an address which is not a part of the program. (e.g. the last instruction was a 'PUSH' and therefore the top of the stack contains a data word instead of a return address)

Example:

*DISR

A FLAGS BC DE HL SP @B @D @H @SP

~0 Z 00~~ ~000 ~000 0000 00 00 00 00~0

2A00 LXI SP,3000

*00 Z 0000 00~0 000~ 30~0 00 00 00 3243 2A03 CALL 2B00

*00 Z 0000 0000 0000 2FFE 00 00 00 2A06-2B00 STC

*RET

A FLAGS BC DE HL SP @B @D @H @SP 00 ZC 0000 0000- 0000 3000 00 00 00 3243

After the second instruction single-step, the RET command causes a temporary breakpoint to be set at location 2A06 (which is the return address on the top of stack) and program execution is resumed. When the program reaches 2A06 control of the processor is returned to DEBUG and the processor state is displayed.

Exception Note: The following program fragment illustrates a special programming construct with which the RET command can not be used.

Call MESSAGE TEXT DTH 'SIGNON'

RET MESSAGE XTHL

CALL @LINEOUT INX H

RET

If an RET command is given after the call to MESSAGE has just been executed, the return address on the top of the stack is pointing to location TEXT.

DEBUG puts a breakpoint at that location. MESSAGE then outputs the Signon text and returns without encountering the breakpoint because the return address has been modified by the called routine.

Rev. 8 9/78 4-85

4.11.5.11 THE SINGLE STEP MODE

The single-stepping mode of program execution allows a datailed inspection of what the program is doing on an instruction by inst~uction basi: E:cr

Exception Note: The nature of Micropolis disk subsystems is such that a disk access must not be interrupted during the data transfer process which is accomplished by a program loop. For this reason it is not possible to TRACE successfully through portions of a program that call MOOS disk access routines, because the TRACE command effectively interrupts the program once every instruction. .

Im Dokument first title (Seite 158-164)