Home
TSC 6809 Debug Package
Contents
1. 40100 0210 50215 0212 5 50100 0215 50101 0218 50210 021 5 50100 0210 440220 0220 BNE 020B 0222 JMP 003 PROT 200 22E W BOUNDS W WRITE PROTECTION 0200 022E 00 00 00 DP 00 xxSTART 200 MON XFR TO CD03 xxM 100 0100 06 0101 FF SET P 200 CC 04 06 00 DP 00 TND ON FLAG 100 CC 04 06 00 00 IX 48 IY B9 F 06FF xxTSIM 10 CC 00 A 06 B 00 DP 00 IX 02 IY B9 F 06FF CC 04 06 00 DP 00 IX 02 IY B9 F 00FF CC 08 A FF B 00 DP 00 IX 02 IY B9 F 00FF CC 08 A FF B 00 DP 00 IX 02 IY B9 F 00FF CC 00 A 02 B 00 DP 00 IX 36 IY B9 F 00FF 00 02 00 DP 00 36 9 F 00FF CC 00 02 00 DP 00 36 9 F 00FF 01 02 00 DP 00 36 9 F 00FF 58989 LDX 0225 LDX 0225 CLR 0100 LDA FF STA 0101 LDA X CMPA 0100 BCC 0215 CMPA 0101 BCC 021D CC 01 A 02 B 00 DP 00 36 IY B9 F 00FF CC 01 A 02 B 00 DP 00 36 IY B9 F 02FF 218 0218 SR G CC 01 A 36 B 00 DP 00 4 1 89 F 02FF TSIM CC 01 A 36 B 00 DP 00 4 1 89 02 ASM 21A 021A STA 101 021D CLB START 200 MON XFR TO CD03 xxM 100 0100 00 0101 02 TRACE 40 START 200 CC 00 A 06 B 00 DP 00 02 IY B9 0002 04 06 00 DP 00 02 9 0002 08 00 D
2. 40 The following Debug Package is running and the program being tested 15 resident in memory The is TSC 6809 Debug Package Example of Use sample program is an example debug session It is assumed that the shown first in its source listing form Following is the sample debug operation I Sample Program Source Listing 0100 0100 0101 0200 0200 0203 0206 0208 020B 020D 0210 0212 0215 0218 021A 021D 0220 0222 0225 0229 8E 7F 86 B7 6 1 24 B7 1 24 B7 8C 26 7E 02 0 0225 0100 FF 0101 0100 03 0100 0101 03 0100 0220 9 CD03 36 4C 20 57 37 06 0220 CD03 ORG FIND THE MAX amp MIN OF DATA LIST 0100 STORAGE LOCATIONS LARGE RMB SMALL RMB ORG 1 LARGEST VALUE 1 SMALLEST VALUE 50200 PROGRAM STARTS HERE LDX DATA POINT TO DATA STRING CLR LARGE PRESET MAX LDA FF ALSO STA SMALL PRESET MINIMUM LOOP LDA 0 X GET DATA ITEM LARGE ITEM gt LARGE BCC CONT2 STAA LARGE UPDATE LARGE CONT2 SMALL ITEM lt SMALL BCC CONT3 STA LARGE UPDATE SMALL CONT3 CPX DATEND END OF LIST BNE LOOP IF NOT REPEAT JMP MON RETURN TO MONITOR DATA LIST DATA FCB 2 54 76 32 12 87 55 6 DATEND EQU MON EQU CD03 MONITOR EQUATE END 5 6809 Debug Package II Sample Debug Session xxDIS 200 222 0200 LDX 0225 0203 CLR 0100 0206 LDA FF 0208 STA 0101 0208 LDA X 0200
3. The following descriptions may prove helpful in adapting this program to non standard systems All 1 0 and stack references are described below 1 0 References Get One Character at 5510 This jump vector references the standard input character routine in the S BUG monitor ROM It 15 extended indirect jump through the S BUG transfer vector Any input routine may be used as long as it returns the ASCII character in the accumulator with the parity removed and preserves the B and X registers Put One Character at 550C This jump vector references the standard output character routine in the S BUG monitor ROM It is an extended indirect jump through the S BUG transfer vector Any output routine may be used as long as it outputs the character from the A accumulator and preserves the B and X registers System Monitor at 5514 This jump vector references the starting entry address of the S BUG monitor ROM It is an extended indirect jump through the S BUG transfer vector This may be changed to the starting address of your own monitor This is the address used by the EXIT command Check for Input Character at 5518 This jump vector references the routine which checks for character having been entered from the keyboard It is an extended indirect jump through the S BUG transfer vector Any check input character routine may be used as long as 1 returns a not equal condition if a character has been entered does not inp
4. BCC 0215 CMPA 0101 BCC 021D STA 0101 CMPX 022D BNE 020B LDA X 5 6809 Debug Package 01 36 00 DP 00 0227 0000 5 07 U 0000 00 0200 0100 4 1 9 F 0002 00 A 36 00 DP 00 0227 0000 07 U 0000 00 0210 0215 IX 4C 1 9 0002 00 36 00 DP 00 0227 0000 5 07 U 0000 00 0215 CMPA 0101 4 9 0002 00 36 00 DP 00 0227 0000 5 07 U 0000 00 0218 021D 4 9 0002 00 A 36 00 DP 00 0227 0000 5 07 U 0000 00 0210 022D 4 IY B9 0002 HALT 0210 xxDIS 20B 210 020B LDA 020D CMPA 0100 0210 BCC 0215 ASM 210 0210 BLS 215 0212 T 0 START 200 MON XFR TO CD03 xxM 100 0100 57 0101 02 B H 200 B H 20B xxB HQ 215 xxB HQ 21D xxBP 0200 020B 0215 0210 xx9TART 200 MON XFR TO CD03 HIST 0200 020B 0215 0210 STATES STATES 00000116 Oo 44 DIS 200 223 0200 0203 0206 0208 020 0200 0210 0212 0215 0218 021A 0210 0220 0222 LDX 0225 CLR 0100 LDA FF STA 0101 LDA X CMPA 0100 BLS 0215 STA 0100 CMPA 0101 50210 STA 0101 CMPX 022D BNE 020B JMP 003 EXIT 45 TSC 6809 Debug Package 5 6809 Debug Package 46 5 6809 Debug Package Adapting to Your System
5. The simulator has the ability to keep close account of all internal actions For example any illegal opcodes are quickly detected and reported Such things as stack overflow and underflow are also easily checked Any byte of memory may have an assigned protection type such as write protection General conditions may also be spotted such as the occurrence of transfer of address type instruction Overall the simulator can keep close watch over the executing program and detect any peculiarities This all sounds great but as stated before there is a disadvantage in the simulator namely speed simulated program runs somewhere between 200 and 300 times slower than a real 6809 CPU This means that real time dependent code may not be simulated This is not serious drawback since less than one percent of all computer programs are real time dependent 5 6809 Debug Package The 6809 Simulator incorporated in the 5 6809 Debug Package supports all of the 6809 instructions All of the user registers are also provided CC 0 5 and To examine the contents of these registers it is only necessary to type R followed by carriage return This 15 assuming the Debug Package is ready to work indicated by the two asterisk prompt Typing the command will cause the debugger to display a line containing all register names followed by their contents in hex At the end of the line is the instruction to which
6. lt count gt instructions and produce another register dump Typing a return will exit the step mode Any other character will be ignored It should be noted that while the step mode breakpoints and tracing are inoperable EXAMPLES STEP Enter single step mode STEP 10 Execute 10 instructions at a time T RACE lt value gt PURPOSE Set the trace depth If value is set to zero trace mode will be disabled Setting trace to a non zero value will enable tracing up to but not including the subroutine nest level indicated by lt value gt For example if TRACE 2 is entered tracing will occur at nest level 0 and 1 but will be disabled at nest levels of 2 and higher The nest level is displayed as N in a register dump EXAMPLES TRACE 255 Enable trace at all levels T 0 Disable trace mode 5 1 lt count gt PURPOSE This command is similar to SIM except trace mode is enabled TRACE 255 and the registers will be dumped after each instruction simulated The count will default to 1 if not specified Trace will be reset to its original value following TSIM s termination EXAMPLES TSIM Trace and simulate 1 instruction TSIM 20 Trace 20 instructions ee ee 5 6809 Debug Package Control C PURPOSE Anytime a program is being simulated a control C will cause the execution to halt and the message HALT AT XXXX to be displayed at the terminal This means Operator Halt and the XXXX will be r
7. types The M action is used to print a specified message to the terminal upon execution of the breakpoint The J action is used to transfer control to another address The M J and H breakpoints are mutually exclusive Only of these may appear in breakpoint command breakpoint containing should have an ASCII string following the lt count gt or following the address if no count is specified This string is the message which will be printed on the terminal each time the instruction is to executed Messages should be kept short under 5 letters if possible For the J type action the hex address of the location of transfer should be provided after the lt count gt field The examples below 26 5 6809 Debug Package will help clarify the syntax EXAMPLES B 100 Stop and print registers at 100 B SR 100 Same as above 100 Set histogram at 100 B ZR 300 gt 100 Zero states and print registers after 100 times through 300 200 A 3C Stop amp print registers at 200 only if acc A 3C B M 210 SUB 1 Print message SUB 1 every time through location 210 B J 100 1000 Transfer control to location 1000 when reach instruction at 100 770400 lt 25 20 0 For the first 25 times through location 400 turn trace on and zero the states counter but only if location 20 is zero BP lt address gt lt address gt PURPOSE The BP command is used to print the location
8. FLAG 1A85 Set flag register to 1A85 FLAG Disable flag register printout IND ON or OFF PURPOSE Used to enable or disable the indirection printout in a register dump see REG If IND is ON the register dump will show two registers called IX and IY which are the values contained in the memory locations to which X and point respectively If this feature is off the indirection registers will not be displayed EXAMPLES IND ON Turn indirection on IND OFF Turn it off PURPOSE MACH command will print the current status of the Simulated machine Values displayed are for mode M trace T instruction count trap I nest trap stop address S interrupt trap IT transfer trap XT IRQ count IRQ FIRQ count FIRQ NMI count NMI and flag address F The description of these appear elsewhere in this manual EXAMPLES MACH Print the machine status MO DE 1 or 0 PURPOSE The debugger has two modes of operation mode 0 and mode 1 The system comes up mode 1 Mode I offers all debug features allowing the simulated program to run approximately 300 times Slower than real time mode 0 the program will run approximately 200 times slower than real time but the following features are not supported nest count checking all traps states counting memory protection past instruction bookkeeping and automatic interrupts Mode 1 should be used most of the time to take full advantage of the debu
9. The double quote character tells the FIND command that the following characters are to be considered ASCII characters instead of hex Otherwise the command works as described above 5 6809 Debug Package So far the memory commands described have been oriented toward hex and ASCII values Many times during debugging it is necessary to decode these hex values into assembler language instructions DIS command does exactly that This command is a complete program disassembler which allows the user to examine the contents of memory in a higher level form Each memory location in a specified block will be printed as address followed by the opcode mnemonic and addressing mode Standard Motorola mnemonics and addressing mode designators are used Exceptions are the PSHS PSHU PULS and PULU instructions which are display as immediate mode instructions to save space on the line during tracing To use the disassembler simply type the command name DIS followed by two address boundaries For example to disassemble the memory range between locations 100 and 108 type the following 015 100 108 0100 LDA 32 0102 STA 0240 0105 BNE 0121 0107 DECA 0108 STA 2 X Remember that at any time the display is being produced the escape key may be typed to temporarily halt the output Some instructions have two legitimate symbolic mnemonics namely LSL ASL BCS BLO LBCS LBLO BCC BHS LBCC LBHS With these intructions the first of
10. command will cause the instruction at address hex 1000 to be the next instruction executed The instruction at 27C will not be executed Any combination of action codes may be listed for a breakpoint They are executed in the order they appear in the above list For example TRZ 300 will cause the registers to be displayed R trace to be enabled T and the states counter to be zeroed Z in that order This ordering may be important for in the actions RSJ the stop S will never get executed since the J transfers control to another address The M J and H type of breakpoints are mutually exclusive Only one of these may appear any one breakpoint statement VI Advanced Breakpoints Programs containing loops or recursion are often difficult to breakpoint since one particular section of code may be called thousands or even millions of times As an example suppose there is a loop in the program being debugged and it is necessary to examine the contents of the X register after the 600th time through the loop One way is to set a breakpoint at the desired instruction and start the program simulating Every time the program halts at the breakpoint type G to restart it Repeat this process 600 times and you can examine X This 15 very time consuming The TSC 6809 Debug Package allows a pass counter to be associated with a breakpoint This count determines how many times the instruction at the address of the breakpoint should
11. digits separated by spaces or commas The second is an ASCII string preceded by a double quote character EXAMPLES FIND 0 60 7E 33 A2 Find the hex value 7 2 0 0 1000 5 Find TEST in memory 5 6809 Debug Package M EM lt address gt PURPOSE Examine and alter memory address specifies the first location to be examined Upon entering this command the address specified and its contents will be displayed on a new line At this time typing any non hex printing character will move to the next location and display its contents Typing a line feed will move to the previous location A carriage return will exit this mode To change the contents of a location type the new hex value immediately following the one displayed After the value type a space The new value will be entered and the next memory location will be displayed It should be noted that it is only necessary to type the number of significant digits and only the last two digits are used For example typing a 1 would enter 01 typing 1A2 would enter 2 etc If only a space is typed no number zero will be entered Any time non hex character 15 typed besides a space the next location will be displayed leaving the current location unchanged EXAMPLES 540 Examine memory at 540 M 200 Examine location 200 IV Simulation Control This group of commands is used to control the program simulator Code RAM o
12. each of the above pairs is the mnemonic displayed by the disassembler Now that we can examine memory in a higher level form it would be nice if we could alter it in the same way that is using assembler language mnemonics The ASM command does exactly that It acts as line at a time assembler allowing standard mnemonics and addressing modes to be typed while the corresponding hex values are automatically inserted into memory To start this process simply type the command name ASM followed by the address where the code should be placed debugger will respond by printing the address of the location specified followed by a space At this time simply type the desired instructions following each with carriage return The next available address will then be printed and assembly can continue Typing a carriage return in response to the address prompt will exit this mode of operation To show workings of this command some code will be assembled at location 200 ASM 200 0200 LDA 10 0202 LDB 10 0204 PSHS A B 0206 LDA M 0208 STA 0 020A LBRA 3000 020D Note that numeric values are interpreted as decimal unless preceded by a dollar sign to designate hex It is also possible to enter an ASCII 58 27 5 6809 Debug Package constant by preceding it with a single quote IV Simulating the Program Program simulation is very simple If the test program starts at 100 simply type START 100 to start the s
13. lt address gt lt address gt lt type gt PURPOSE The PROT command is used to assign protection to region of memory The two lt address gt specifiers designate the beginning and ending addresses of the selected region If only one address is specified only the byte at that location will be protected The lt type gt designator may either be M X W or S for memory execute write and simulate protection respectively Only one type may appear with each address range Multiple protection may be performed on one line by separating the range type specifiers by a comma or a space IMPORTANT NOTE Simulate protected memory must be entered with a subroutine call The top two bytes of the stack MUST be a return address On exit from simulate protected code the system stack MUST have the same value as when the simulate protected code was entered EXAMPLES PROT 0 100 M Memory prot 0 100 P 100 W A100 A600 S Write prot 100 and simulate protect A100 A600 VII Execution Traps Execution traps allow program stopping on certain general conditions Several traps are always enabled These include trap on illegal opcode and trap on RTS if nest count is zero The user may enable and disable several other traps These traps are for interrupt type instructions transfer of address type instructions trap on a selected subroutine depth nest count an instruction count timeout and a general stop address 30 5 6809 Debug P
14. off automatic FIRQs IRQ lt count gt PURPOSE Cause an IRQ type interrupt to be generated every lt count gt instructions If lt count gt is set to zero IRQ interrupts will be turned off EXAMPLES IRQ 5000 Generate IRQ every 5000 instructions IRQ 0 Turn off automatic IRQs NMI lt count gt PURPOSE Cause an NMI type interrupt to be generated every lt count gt instructions If lt count gt is zero automatic NMI interrupts will be turned off EXAMPLES NMI 300 Generate NMI every 300 instructions NMI 0 Turn off automatic NMIs Control F PURPOSE Typing a control F during program simulation will cause an FIRQ type interrupt to be generated Control I PURPOSE Typing a control I during program simulation will cause an IRQ type interrupt to be generated Control N PURPOSE Typing control N during program simulation will cause an NMI type interrupt to be generated 33 5 6809 Debug Package 34 Command Summary System Control C ALC lt value gt DEP TH E XIT F LAG lt address gt IND 0N or OFF MA CH MO DE 0 or 1 R EG RES ET RET S ET lt register 1151 lt value gt 5 51 TRAIL X lt FLEX system command gt II Memory Commands A SM lt address gt 15 lt address gt lt stop address gt DU MP lt address gt FIL L lt start address gt lt stop address gt lt b
15. restart the output while a return will give control back to the debugger and the xx prompt will be output II General System Control The general system control commands allow a variety of general actions to be performed Register examination and changing is supported by use of the REG and SET commands The status of several machine control registers can be obtained through the MACH command Commands to view the stack contents set simulation speed reset machine parameters enter a calculator mode examine the machine states counter and exit the debugger are all described in this section C ALC PURPOSE The calculator mode will be entered and a prompt will be printed The calculator will allow addition or subtraction of a series of numbers The numbers may be hex designated by a prefix or decimal If more than one number is typed they must be separated by a the appropriate result will be displayed The answer 15 shown in both hex and decimal It is possible to enter only one number hex or decimal optionally preceded by a unary or followed by a return The answer will be this number printed in both hex and decimal thus allowing base conversions After each calculation a new prompt will 15 5 6809 Debug Package be output To exit this mode type return as response to the prompt EXAMPLES CALC Enter calculator mode A 10 1 Add hex A and 10 and subtract 1
16. the program counter P register currently points and it is displayed in disassembled form standard Motorola mnemonics nonstandard register is also displayed the N register This register s value represents the subroutine nest depth Each time a subroutine is called interrupt occurs or the program counter is pushed on to the system stack its value is incremented and each time a return from subroutine or return from interrupt 15 executed or the program counter is pulled from the system stack its value is decremented The content of any of the displayed registers may also be set by using the SET command For example SET P 100 A F3 will set the value of the PC to hex 100 and the value of the A register to hex F3 There are several other registers and states of the simulated machine These viewed by typing MACH The items displayed with this command are primarily the states of various traps which will be described a little later There are several other internal machine variables which may be easily examined One of these is the content of the system stack Typing STACK will display the top several bytes of the system stack If more stack content is desired simply type the number of items desired after the command STACK 15 This will display the top 15 bytes of the stack Note that a comma was used as a separator in the command line It will be used in all examples in this manual but a space is also accepta
17. 00 Clear counters between 25 amp 200 PURPOSE Clear all messages in the breakpoint message table used by the M action code see the B command This table is a fixed size and can be filled up When deleting message type breakpoints using the CLB command the associated space in the message table does not get freed It is recommended that whenever all M type breakpoints have been cleared also use the CLM command Do not use this command if there are any active M type breakpoints Their message strings will be destroyed EXAMPLES CLM Clear all messages HLIST lt address gt lt address gt PURPOSE Print the histogram counter totals for the section of memory specified The addresses define the region of memory If only one address is listed then only the counter at that location is displayed If no addresses are specified all counter contents will be displayed Each counter is shown preceded by its address The counter value shows the number of times the instruction at that address has been executed EXAMPLES HIST Display all histogram counters H 0 200 Display counters between 0 amp 200 RT lt address gt PURPOSE Start real time program execution not simulated at the current location Program execution will halt at the lt address gt specified This is similar to the standard breakpoint most users are familiar with in that memory 15 actually altered at address specified with a JMP instruction
18. 0013 19 The result is printed lt value gt PURPOSE This will set the simulation delay the amount of delay after each instruction is executed to an amount proportional to lt value gt The higher the number max 255 the longer the delay delay of zero will result in the delay being turned off EXAMPLES DELAY 100 Set delay to 100 DELAY 0 Disable the delay DEP TH PURPOSE The depth command will print the deepest value of the stack pointers the lowest memory address at which the stacks were extended during program simulation To initialize this pointer it is necessary to set the stack pointers using the SET command The depth value will be set to the same value as the stack pointer This command is useful for determining the amount of stack space required by a program EXAMPLES DEPTH Print the deepest stack locations PURPOSE Exit the debug program Use this command when finished with the Debug Package EXAMPLES EXIT Exit the debugger FL AG lt address gt PURPOSE The Flag register is a 2 byte word at the specified memory location which will be displayed on a REG command or during tracing as the register The memory location for the flag will be set to the address specified If no address is given the flag register will be disabled This is useful for tracking flags in memory during program tracing See the REG command 201 0 5 5 6809 Debug Package EXAMPLES
19. 6809 Debug Package COPYRIGHT C 1979 by Technical Systems Consultants Inc 111 Providence Road Chapel Hill North Carolina 27514 All Rights Reserved COPYRIGHT INFORMATION This entire manual is provided for the personal use and enjoyment of the purchaser Its contents are copyrighted by Technical Systems Consultants Inc and reproduction in whole or in part by any means is prohibited Use of this program or any part thereof for any purpose other than single end use by the purchaser is prohibited DISCLAIMER The supplied software is intended for use only as described in this manual Use of undocumented features or parameters may cause unpredictable results for which Technical Systems Consultants Inc cannot assume responsibility Although every effort has been made to make the supplied software and its documentation as accurate and functional as possible Technical Systems Consultants Inc will not assume responsibility for any damages incurred or generated by such material Technical Systems Consultants Inc reserves the right to make changes in such material at any time without notice Table of Contents Debug Tutorial 1 I Introduction 1 II The Simulated Computer 1 III Whats in Memory 3 IV Simulating the Program 6 V Breakpointing the Program 7 VI Advanced Breakpoints 9 VII Protect Your Memory 11 VIII Trapping Those Bugs 13 IX And There is Still More 14 Command Descriptions 15 I Introduction 15 I
20. Entering RT without an address will clear any real time breakpoint which may have been 29822 TSC 6809 Debug Package previously entered This type of breakpoint and program execution is not recommended since no protection or checking 15 performed When the program reaches the break address specified the breakpoint is automatically cleared and the original code restored in memory ROM may not be breakpointed with this command IMPORTANT NOTE When the breakpoint is reached the debugger will push two bytes on 10 the system stack as it saves the program registers Therefore the system stack must NOT be pointing to data at the location of the breakpoint and two bytes of stack space MUST be available The stack is cleaned up once all registers have been saved before return control to the user EXAMPLES 600 Start at end at 600 Clear existing breakpoint VI Memory Protection The memory protection commands are a very powerful feature of the program debugger The PROT command allows selected areas of memory to be write execute memory or simulate protected Write protected memory will cause a trap on any attempt to write to it Execute protect will not allow opcodes to be fetched Memory protect will not permit any type of reference read write or execute Simulate protect is used to protect sections of code which should not be simulated executed in real time It is important that only code called as a subro
21. I General System Control 15 III Memory Commands 20 IV Simulation Control 22 V Breakpoints 25 VI Memory Protection 29 VII Execution Traps 30 VIII Interrupt Control 32 Command Summary 35 Message Descriptions 37 Getting Debug Running 39 Example of Use 41 I Sample Program Source 41 II Sample Debug Session 42 Adapting to Your System 47 I 0 References 47 II 1 0 Related Storage 47 III Stack Pointer References 48 IV Interrupt Vectors 48 V Saving the Altered Program 48 ae Preface The TSC 6809 Debug Package is powerful tool for assembler language program debugging It offers the power and flexibility of an expensive hardware emulator at only a very small fraction of the cost Used with care this package will save many hours when debugging programs It 15 recommended that the entire user s manual be read before attempting any serious debugging Tutorial is written to provide fairly complete introduction to the Debug Package while the Command Descriptions is a complete and concise description of all Debug features and commands Consult Getting Debug Running for details on how to get the program started Working through the example given in Example of Use is a good place to start once the manual has been read iv Debug Tutorial I Introduction Program debugging is usually thought of as work It should be thought of as an art There is no reason for a lot of crying whi
22. P 00 02 9 0002 08 00 DP 00 02 9 F 00FF 00 02 00 DP 00 36 9 F 00FF 00 02 00 DP 00 36 9 F 00FF 00 02 00 DP 00 36 9 F 00FF 01 02 00 DP 00 36 9 F 00FF 01 02 00 DP 00 36 9 F 00FF 01 02 00 DP 00 36 9 0002 09 02 8 00 DP 00 36 9 0002 CC 09 02 00 DP 00 36 9 0002 0226 0226 0227 0227 0225 0225 0225 0225 0226 0226 0226 0226 0226 0226 0226 0226 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 5 07 5 07 5 07 5 07 5 07 5 07 5 07 5 07 5 07 5 07 5 07 5 07 5 07 5 07 5 07 5 07 43 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 U 0000 TSC 6809 Debug Package N 00 N 00 N 00 N 00 N 00 N 00 N 00 N 00 N 00 N 00 N 00 N 00 N 00 N 00 N 00 N 00 021 P 021D P 0218 021 0203 0206 0208 P 020B P 020D P 0210 P 0215 P 0218 P 021A 0210 0220 P 020B STA 0100 CMPX 022D BCC 021D STA 0100 CLR 0100 LDA FF STA 0101 LDA X CMPA 0100
23. Package RTS IN LEVEL 0 AT An RTS instruction was encountered while the nest level was 0 no previous call to subroutine had been executed NEST LEVEL IS 0 There is no return address on the stack so the RET command can not display an address XFR TRAP AT A transfer of address type instruction has been encountered with the transfer trap enabled from XFR ON MON XFR TO program being simulated tried to pass control to the monitor address which is used by the EXIT command OP HALT AT An operator halt signal control C character was detected by the simulator 38 5 6809 Debug Package Getting Debug Running I Disk Version The Debug Package loads from address 5500 through 7FFF and uses memory down to 5000 for stack and variable storage The Debug Package may be executed from FLEX by typing DEBUG prompt should appear program is started through its cold start entry point location 5500 which initializes all system tables clears all registers and clears out breakpoints If it is necessary to re enter the debugger after an EXIT command the program should be entered at location 5503 the warm start entry point No clearing of values or tables is performed at this entry Once in the Debug Package files may be loaded from the disk by using the X command As an example to load the file TEST BIN type the following X GEL TEST If TEST is found it will be loaded into memory It
24. ackage INST lt count gt PURPOSE Set the instruction count timer to the value of count If set to zero this trap will be disabled This timer is used to count the number of simulated instructions Each time this counter reaches zero the program will halt and print IC TIMEOUT AT XXXX where XXXX 15 the address where the program stopped and the counter will be reset to the value at which it started the value specified by lt count gt EXAMPLES INST 400 Set counter to 400 INST 0 Disable the intruction counter ITLRAP ON or OFF PURPOSE Turning the ITRAP on will cause the simulator to treat interrupt type instructions similar to illegal opcodes Any time a RTI SWI SWI2 SWI3 SYNC or CWAI instruction is found the message I TRAP XXXX will be displayed address of the instruction will be printed in place of the XXXX shown EXAMPLES Enable the interrupt trap IT OFF Turn off the trap NC ST lt value gt PURPOSE Set the nest trap at the level specified by lt value gt The simulator will trap execution if a subroutine call instruction is found which will cause the nest level to equal or exceed that set by NEST Setting the lt value gt to zero will disable this trap EXAMPLES NEST 6 Set nest trap to level 6 N 0 Disable nest trap STOP lt address gt PURPOSE The STOP trap is a general stop at address X trap It is useful for trapping returns to monitor type programs or ope
25. al addition and subtraction may be performed To add two numbers simply type them in separated by a plus sign If the number is hex precede it with a dollar sign otherwise the debugger will interpret it as decimal Use minus sign for subtraction It is also possible to do base conversions This can be accomplished by entering just one number after the prompt hex or decimal followed by a return All answers are displayed in both hex and decimal An example follows CALC 1A 10 1 0023 35 256 0100 256 After entering the calculator mode the numbers hex 1A and decimal 10 were added and then 1 subtracted to give the result hex 23 or decimal 35 The second entry is base conversion of the decimal number 256 The result shows its hex equivalent is 100 The calculator mode is terminated by typing a return in response to the prompt There are still many other features in the Debug Package such as interrupt simulation which have not been described It 15 not the intention of this tutorial to teach all there is to know about the debugger but to teach enough to make the user feel comfortable with the majority of its features Once the material in this section is thoroughly understood the following detailed command description should be studied in depth Now that the basic mechanics of the Debug Package are understood they should be put to good use Keep in mind that a logical and planned approach should be taken when debugging a pr
26. be executed before the actions specified should be performed In the above example assuming the instruction to be breakpointed is at address 300 the following will do exactly what we want B 300 gt 600 or B SRC300 gt 600 Both commands are identical since the first defaults to SR actions The gt is the pass count modifier and should be read as after The result of this command is to stop and print the registers on the instruction at location 300 after 600 times through it Once the count reaches 600 or 20 5 6809 Debug Package whatever value was set the breakpoint actions will always occur A second similar type of pass count uses a lt for a modifier and should be read as before This is used to create a temporary breakpoint B R 300 lt 100 This command will set up breakpoint at 300 which will print the registers for the first 100 times through After the 100th time the breakpoint will be cleared and no longer function In summary the pass count value associated ith breakpoint is decremented each time the instruction at the specified address is executed If the modifier is a gt no actions will be performed until after the count has reached zero With the lt modifier actions are only performed before the count reaches zero and once it is zero the breakpoint is cleared In the above example it was decided that the program should be stopped after 600 times through the loop While d
27. ble and sometimes easier to type Another command which references the stack is the RET command This will print the top two bytes of the stack as an address and represents the return address if currently in a subroutine The simulated machine always keeps track of where it has been and how much time was spent there The machine states counter is used to tally the total number of machine states or cycles used so far by the executing program Each 6809 instruction requires certain number of machine cycles to execute If the CPU is running at 1 megahertz each machine state is equivalent to 1 microsecond machine states counter 15 capable of counting up to 99 999 999 cycles or roughly 99 99 seconds of actual program execution time This counter is useful for determining the exact execution time of a routine 5 6809 Debug Package The TRAIL command will print the address of the last transfer type instruction A transfer of address instruction is one which causes the CPU to change its normal course of instruction execution Normal ly instructions are executed in a sequential fashion stepping through memory sequentially JMP instruction for example will cause the next instruction to be fetched from the address specified in the instruction rather than from the next sequential address In ffect we have a transfer of address The TRAIL command will print the location of the last transfer type instruction that was executed This is ver
28. ctions are JMP LBRA BRA and all conditional branches such as BCC The subroutine calls and returns are not trapped out xxXFR ON xxXFR OFF These two commands will enable and disable this trap respectively Once program has stopped because of a transfer trap typing G will restart it allowing the current transfer to be executed This is very useful for quickly following the major flow of a program Another one of the general traps allows halting the program if the subroutine nest counts reaches a specified level NEST 20 This will cause a trap if the nest level ever reaches 20 To disable the nest trap use NEST 0 The last general trap to be discussed is the ITRAP This command allows activation of the interrupt trap and will cause the simulating program to stop if an interrupt type instruction is encountered SWI SWI2 513 RTI SYNC and CWAI Since these instructions are not used in the majority of programs it is a good idea to use this feature An example will demonstrate its use 13 5 6809 Debug Package ITRAP 0N ITRAP 0FF These two commands will enable and disable the interrupt trap respectively IX And There is Still More There are still many undescribed features of the TSC 6809 Debug Package One of these is the handy little CALC command which acts as a hex calculator Typing CALC followed by a return will cause the debugger to output an equals sign for a prompt At this time hex and decim
29. eared in a similar fashion The first command will clear all protection while the second will only 5 6809 Debug Package clear the defined execute and write protected regions VIII Trapping Those Bugs The previously described breakpointing feature allows programs to stopped at specific locations and on specific conditions It is often desirable to trap a program on some general condition such as every time a transfer of address instruction is encountered The memory protection described above is a form of trap in that the program will stop if a protection violation is detected e g writing into write protected memory There is address information associated with this protection which makes it different from the general traps available in the Debug Package The general traps cause programs to stop general condition which is not address dependent One of these traps is the illegal opcode trap which 15 always enabled Any time an illegal opcode is encountered during the course of program simulation the program will stop and report its occurrence A second always enabled trap will stop the program if an RTS instruction is encountered and the current nest level is 0 There are several user controlled traps which may be enabled and disabled at will The transfer trap is enabled with the XFR command When enabled the program will stop each time a transfer of address is encountered These instru
30. ebugging loops it is not always possible to determine an exact number of times to execute the loop before it should be stopped Often it is desirable to stop ona certain condition such as the contents of a register or the state of a particular memory location Conditional expressions are allowed in breakpoint definitions and provide a great deal of power The conditional can be determined on the contents of a selected register CC A B DP X Y U 5 or P being equal or not equal to a specified value A particular memory location may also be tested for zero or not zero Following are a few examples B 1000 IF A 3F xxB RQ320 IF B 10 xx B TG6A7 IF 20 0 IF statement designates the conditional part of the breakpoint definition The first example will stop and print the registers at location hex 1000 but only when the value in the A accumulator is hex The second example will print the registers at 320 only if the contents of the register is not hex 10 is to be read as equals The last example will enable the trace mode at location 6A7 if the contents of memory location hex 20 is zero The dollar sign is used to designate a memory reference and not a hex value the value is always interpreted as hex The value on the right of the equals sign must always be zero when a memory reference has been designated The above breakpoint features may be combined in a variety of ways to produce a large variet
31. ed so if C23A 15 typed will get entered If zero is to be entered simply type a space After the new value 15 entered the next sequential memory location will be displayed Any time a non hex character is typed with the exception of space one of two actions will occur First if the character is a line feed the previous location will be displayed with the current location left unchanged If the character is any other hon hex character the next location will be displayed leaving the current location unchanged An example will clarify the M command s use M 100 0100 CE 0101 3A 46 0102 4D Location 100 was left unaltered while location 101 was changed from a 5 6809 Debug Package 3A to 46 Finally this mode was terminated on the next line by typing a return Many times while debugging it is desirable to examine a large block of memory DUMP command is used for exactly that This command will display 16 lines of data 16 bytes per line for a specified memory region Each byte is displayed as a hex value as well as its ASCII equivalent 11 control characters those bytes having a value less than 20 hex are displayed as an underscore character To display 256 bytes starting at memory location 1000 the following command should be typed DUMP 1000 At the end of the dumped block the program will stop and wait for a character to be typed Typing an will move forward in memory p
32. eplaced by the actual address where the program was halted Escape Character PURPOSE During program tracing typing an escape will cause the program to pause at the end of the next displayed line At this time typing another escape will enable the trace to restart while typing a return will return control back to the command entry mode V Breakpoints Breakpoints allow the insertion of check points into a program A breakpoint always has an address associated with it The address specifies where in the program the breakpoint action should occur These actions range from printing the machine registers to controlling trace mode Each breakpoint may also have a pass counter which determines the amount of time until it becomes active or the amount of time it should remain active The actions are also dependent on the result of a conditional expression involving a CPU register or memory location Breakpoints are decoded with the following precedence If the address of the current PC matches the address of a breakpoint then the pass count is checked If the counter is in state to allow continuing then the condition is checked if present Finally the actions specified for the breakpoint are performed The other commands in this group allow clearing breakpoints removing them printing histogram counter values printing breakpoint location and type and clearing histogram counters B lt actions gt lt address gt lt modifier
33. es unless the address is preceded by a gt which forces an extended memory reference In indexed mode the index register must be preceded by a comma Instructions of the form LDA X meaning LDA are not permitted The smallest possible offset is generated for indexed mode Extended addressing and 16 bit indexed offsets may be forced by placing a gt character as the first character of the operand Constants addresses and offsets may be either decimal or hexadecimal indicated by a leading Eight bit immediate mode constants may also be an ASCII character preceded by a single quote Negative numbers are not allowed Negative numbers should be entered as hex values the CALC command can be used to determine the negative of a number For relative branch and PC relative instructions the actual target address 15 specified the assembler will calculate the offset EXG TFR PSHS PSHU PULS and PULU accept standard register notation The 15 automatically advanced to the next location after the line is assembled To exit this mode type a return in response to the address prompt EXAMPLES ASM 100 Start assembly at 100 100 LEAX 110 PCR X Message Address 103 JSR F810 Print message 107 LDA A Load an ASCII A 109 STA 0 Y Store it 10B BRA 100 Loop 10D Exit with return 20 5 6809 Debug Package D IS lt start address gt lt stop address gt PURPOSE Disassemble memory between the addresses
34. f this command SIM 100 This line will cause 100 instructions to be simulated starting at the address to which the program counter points The TSIM command is identical to the SIM command except trace is automatically set to 255 during the execution of the command It is often desirable to step through the execution of a program one instruction at a time The STEP command will start simulation at the instruction to which the program counter points execute a specified number of instructions print a register dump and then wait for input At this time a space will repeat the process while a return will return control back to the debugger The usual method of operation is single step which will execute one instruction then dump the registers This mode can be entered by 5 6809 Debug Package STEP Multiple instructions can be executed between register dumps by specifying a count For example STEP 25 will cause 25 instructions to be simulated at a time The step mode is a very powerful method for closely following the flow of a program During program execution the simulator keeps track of the last 256 instructions executed If a program ever goes off on its own ending up in memory where it should not the PAST command can be used to examine the instructions executed to get it there Typing the command PAST 20 will display the addresses and mnemonic instructions of the last 20 opcodes executed V Breakp
35. gger EXAMPLES MODE 1 Set mode to 1 MO 0 Set mode to 0 ae 5 6809 Debug Package PURPOSE Print the contents of the machine registers All values are shown in hex Besides the hardware registers CC A B DP X Y U S and PC the nest level 15 displayed shows how deep in subroutine calls as well as three optional registers Two are enabled by the IND command and display the bytes to which the X and Y registers point These are shown as IX and IY in the REG dump The third register is enabled by the FLAG command and will display the selected two bytes of memory This is shown as in the dump The instruction to which the program counter points is also disassembled in the dump EXAMPLES REG Display all registers R Display all registers RES PURPOSE The RESET command is used to reset all machine states All registers will be set to zero the stack pointer will be set to CO7F all breakpoints and memory protection will be cleared and the mode will be set to 1 This will set up the machine exactly the same as initializing the debugger upon first entry EXAMPLES RESET Reset the machine RET PURPOSE Print the top two items the stack If the system is currently subroutine these bytes will represent the return address from this routine If the nest level is currently zero N 0 the message NEST LEVEL IS 0 will be displayed EXAMPLES RET Print the return address S ET lt
36. gt lt count gt 1F lt condition gt or B lt address gt lt modifier gt lt count gt 1F lt condition gt PURPOSE The B command is used to set breakpoints These breakpoints are nondestructive in that they do not alter the contents of memory at the breakpoint location Two forms of the command exist The first is the general form of the command and allows user definable breakpoint actions The lt actions gt may be any one or combination of the following 95 5 6809 Debug Package Print register contents mode on Trace mode off untrace the states counter Histogram counter message Jump to new address Stop simulation 220 The above actions executed in the order shown histogram action causes a counter to be set up such that each time the instruction at the address specified is executed the counter will be incremented by one By later requesting histogram all of the counters and their associated values will be displayed The second form of the command is a special case of the first In this form no actions are specified and they default to S and R just as if S and R were used in form one The lt count gt part of the syntax is optional and acts as a pass counter The lt modifier gt shown in the command description represents either gt used to mean after and lt to represent before A count preceded by gt
37. imulation process The program will run exactly as the CPU would run it just slower The START command clears several of the machine conditions such as the states counter To start a program where it left off the GO command can be used This will cause the program to start execution at the location to which the program counter P register points No states will be cleared A very valuable feature of the simulator is the trace mode When trace is enabled register dump exactly like that produced by the command will be displayed after each instruction 15 executed The simulation may be temporarily halted by typing an escape character anytime during the tracing operation The simulation may also be stopped by typing a control C This will cause the debug prompt to be reissued To enable the trace mode use the TRACE command TRACE 10 This line will cause the debugger to trace all instructions which are ina subroutine nest level of 9 or lower The number in the command line specifies the nest level where tracing should be disabled This allows only the outermost program structure to be traced if desired while the deeper subroutines will be simulated without the tracing To disable the trace use a count of zero e g TRACE 0 There are several other methods of starting program simulation One is the SIM command This command will allow the simulation of a specified number of instructions Tracing is disabled during the execution o
38. instruction This is useful when attempting to find how a program ended up where it did EXAMPLES TRAIL Print the last transfer address X lt operating system command gt PURPOSE The X command is only operational on disk systems see Adaptions It allows the execution of any DOS command from the debugger EXAMPLES X CAT 1 Catalog drive 1 19 5 6809 Debug Package III Memory Commands The memory commands allow examining and altering the contents of memory in variety of ways assembler allows simple direct insertion of object code by using standard opcode mnemonics and addressing mode designators The disassembler provides an opposite type of convenience in that the contents of memory may be displayed as assembler language mnemonics and operands A single byte memory examine and change function is also available the MEM command Commands for viewing large blocks of memory finding specific hex or ASCII strings and filling section of memory with a selected character are all available in this group A SM lt address gt PURPOSE Enter the line at a time assembly mode Assembly will start at the address specified or at the location of the program counter if no address is specified No labels are permitted standard Motorola 6809 instruction mnemonics and addressing modes are accepted pseudo ops are not allowed Memory references to addresses lower than 100 are assembled as direct referenc
39. ions to be displayed Each instruction is Shown in a disassembled form with its address EXAMPLES PAST Display the past 255 instructions PAST 10 Display the past 10 instructions SIM lt count gt PURPOSE Simulate the number of instructions specified by lt count gt with the trace disabled If the count is not specified one instruction will be executed Execution starts at the current PC No machine values are altered prior to simulation Trace will be reset to its original value following SIM s termination EXAMPLES SIM Simulate one instruction SIM 100 Simulate 100 instructions ST ART lt address gt PURPOSE Start program simulation at the specified address The PC will be set to the address specified the states counter will be zeroed and the nest count will be cleared EXAMPLES START 1000 Start simulation at 1000 ST 2A Start simulation at 002A 23 5 6809 Debug Package STEP lt count gt PURPOSE This command will cause the debugger to enter the step mode The lt count gt specifies how many instructions should be executed at a time in this mode and defaults to one single step Upon entering the STEP command the system will immediately execute the number of instructions specified by lt count gt then print a register dump The execution will begin at the location pointed to the P register program counter After the register dump typing a space will cause execution of the next
40. is important that the program being tested and the Debug Package do not overlap in memory If they do the RUN utility supplied on the Debug diskette may be used to load the Debug Package at some other address For example to load the Debug Package at address 3500 type the following RUN 3500 DEBUG The prompt should appear Note however that the coldstart and warmstart entry points will be different if the Debug Package is loaded at some address other than its default load address The coldstart entry point is at the load address the warmstart address is 3 locations higher Be sure to leave 500 bytes free below the Debug Package for stack and variable storage II Cassette Version The object code supplied loads from address 5500 through 7FFF and uses memory down to 5000 for stack and variable storage The tape should be loaded into memory using your monitor system s load routine Once loaded the program to be debugged should be loaded It is important that the two programs do not overlap memory If they do it will be necessary to move the Debug Package to a location in memory such that the two programs do not conflict See the section below on Moving the Debug Package for more information After all code is resident in memory start the Debug Package at Location 5500 the cold start entry point A xx prompt should appear The cold start entry initializes all system tables clears all registers and clears out breakpoint
41. le attempting to make a new program do what was intended This is only true however if the program was designed with some forethought and planning Computer programs are executed in a logical step by step fashion This 15 the approach both program writing AND debugging should take So many times a programmer will spend hundreds of hours carefully planning the flow of a new program but spend only a few minutes thought on a debugging approach The debugging is usually attempted in some haphazard keep your fingers crossed method Sometimes this works and sometimes it does not but in most cases valuable time is wasted By using a debugging tool and by using some logical thinking program debugging can become very straight forward and sometimes even purpose of this tutorial is to introduce the reader to the capabilities of the TSC 6809 Debug Package and offer some suggestions on how to tackle those program bugs The following sections give a more detailed description of its capabilities II The Simulated Computer The TSC 6809 Debug Package is more than the name may imply It 15 fact complete 6809 simulator A computer simulator 15 a program which when run behaves exactly like the computer it is simulating Given 6809 machine language the simulator will perform the instructions as does the actual 6809 CPU There are two major differences one being an advantage the second being a disadvantage First for the good news
42. low 5 6809 Debug Package Print register contents Enable the trace function Disable trace untrace Zero the states counter Histogram counter Print a message to specified address Stop simulation CONDO 20 first breakpoint example shown defaulted to 5 type actions since none were specified The Z action zeroes the machine states counter This is useful for program timing For an example the states counter may be zeroed upon entry to a subroutine and a stop type breakpoint set at the exit point of the routine By using the STATES command after the program stops the exact number of executed machine states for that routine will be displayed The T and U actions allow the trace mode to be enabled and disabled at selected points in a program When enabled trace will be set to level 255 Many times tracing is only desired during one routine or selected portion of the program These actions will permit this sort of program tracing A few examples will demonstrate action type breakpoints B RZC1000 16 first command will set breakpoint at location hex 1000 which when executed will print the registers and zero the states counter program will then continue since a stop S action was not specified The second example will cause trace to be turned on at location hex 16 Another action is the histogram H A histogram counter count
43. may require over an hour if simulated To get around this problem it is possible to set a real time breakpoint This is entirely different from the previously described breakpoints in that it does modify the contents of memory by substituting a JMP instruction and no pass counting or conditionals are permitted The only action performed is to stop and print the registers An example of use follows 5 00 This command will cause the CPU to start executing the program the simulator at the current address of the program counter When the program reaches the specified address 5A00 the program will stop print the registers and restore the contents of RAM at that location remove the breakpoint Since the program is being executed in real time and not being simulated no other breakpoints illegal condition checking states counting or record keeping is performed This type of execution 15 not recommended for this reason and should only be used where the simulation time gets tremendously long VII Protect Your Memory Perhaps the most aggravating aspect of program debugging 15 having your program destroy itself in memory Too many times programs run away writing garbage in memory usually exactly where it is not wanted In these instances it would be nice to be able to write protect memory or at least certain portions of it The TSC 6809 Debug Package will allow exactly that In fact any section of memory right d
44. not selected a manual simulated interrupt must be entered from the keyboard to continue simulation A control C may be entered to return to command mode while a SYNC or CWAI is waiting for an interrupt however restarting simulation with GO SIM TSIM or JUMP will cause the debugger to continue to wait for an interrupt regardless of where the program counter is pointing A START command can be used to continue simulation at some other address and will clear the waiting for interrupt condition in the debugger The 6809 Debug Package uses the interrupt vectors at FFF2 FFFD to determine the location to which to transfer control when simulated interrupt is received In most systems these will point to routines in the system monitor ROM which in turn will give control to some user routine These interrupt handlers in the system ROM must NOT be simulate protected since they will be entered bn an interrupt not subroutine call as is required for simulate protected code It is possible to patch the Debug Package so that simulated interrupts will not refer to the standard vectors at FFF2 FFFD See the section on Adapting to Your System for details a 97 TSC 6809 Debug Package FIRQ lt count gt PURPOSE Cause an FIRQ type interrupt to be generated every lt count gt instructions If lt count gt is zero automatic FIRQ interrupts will be turned off EXAMPLES FIRQ 1000 Generate FIRQ every 1000 instructions FIRQ 0 Turn
45. of breakpoints and their associated action codes The two address specifications are used to define the region of memory for checking breakpoints beginning and ending respectively If no addresses are specified all breakpoints will be listed If only one address is given then only the breakpoint at that address will be displayed if one exists Only the action codes are listed with each address EXAMPLES 10 00 List breakpoints between 510 8 00 List all breakpoints CLB lt address gt lt address gt PURPOSE Clear breakpoints in specified memory region addresses define the region of memory If only one address is listed then only the breakpoint at that location will be cleared If no addresses are specified all breakpoints will be cleared EXAMPLES CLB Clear all breakpoints CLB 0 100 Clear breakpoints between 0 amp 100 CLB 22A Clear breakpoint at 22A 27 5 6809 Debug Package CLH lt address gt lt address gt CLM PURPOSE Clear histogram counters in the specified memory region The addresses define the region of memory If only one address 15 listed then only the histogram counter at that location will be cleared If no addresses are specified all counters will be declared NOTE This command does not remove the histogram breakpoints but clears its associated counter to zero in preparation for a new run EXAMPLES CLH Clear all histogram counters 25 2
46. ogram Use the available tools such as memory protection and breakpoints When first starting the debug process on new program start at the beginning working your way through the flow of the program Let the program be the guide If you pay close attention it will definitely point out the bugs Above all have patience Great bugs are not killed overnight x ae 5 6809 Debug Package Command Des criptions I Introduction This section of the manual contains a detailed description of each Debug command Each command is shown with a few examples The syntax definitions show optional items in square brackets 11 11 command parameters are shown separated by commas for clarity in the syntax definitions and examples Any place a comma is shown a space may also be used The following definitions apply throughout this document ITEM MEANING lt address gt 1 4 digit hex value lt value gt decimal number max 255 lt count gt decimal number max 65 000 The Debug Package is ready to accept a command anytime the prompt is present the line When typing commands a control H will cause a backspace and delete the last character typed A control X will cause the entire line to be deleted and a new prompt of 22 will be output to show the deletion of the line Any time text is being output to the terminal display may be stopped at the end of a line by typing an escape character Once stopped another escape will
47. ointing the Program So far methods have been described which allow all or a certain number of instructions to be simulated Most of the time the number of instructions to certain point in the program is not known It would be helpful if a break in the program simulation could be specified to take place at particular point in the program or in other words breakpoints A breakpoint is a mechanism for stopping the execution at a specified address in the program As an example to set a breakpoint at location 23A use the following command xxBQ23A As the program executes any time location 23A is reached simulation will stop and the registers will be dumped to the terminal After the program has stopped typing 0 will restart execution starting at address 23A the breakpoint will be temporarily ignored It should be noted that the method used to create the breakpoint does not alter the contents of memory in any way This means that after setting a breakpoint the contents of memory at the breakpoint location will be unchanged This allows breakpoints to be set in ROM as well as RAM In the above example the breakpoint caused two actions to take place One was printing the registers the other was stopping program simulation These actions are the ones performed by most debugging systems The TSC 6809 Debug Package allows six other actions to be performed upon the execution of a breakpoint list of all 8 possible actions fol
48. own to a single byte may be write execute memory or simulate protected Write protecting memory will prohibit any stores or writes into it Execute protection prohibits opcodes froin being fetched from memory other words the program counter PC will not be permitted to point to a 5 6809 Debug Package location of memory which is execute protected Memory protect is brute force type of protection By memory protecting a region you are in effect saying that no memory exists in this region and that nothing should be allowed to reference it in any way Any memory referenced in conflict with its protection will cause the simulation to stop and appropriate message will be printed Finally simulate protection 15 slightly different from the rest It is used to tell the simulator to execute any code in a simulate protected region in real time or in other words not simulated A restriction requires the code in a simulate protected region to be called as a subroutine JSR LBSR or BSR from the non simulate protected code This is very convenient 1 0 operations All 1 0 routines can be simulate protected such as terminal and disk routines allowing them to be executed by the CPU real time and not the simulator It is often convenient to simulate protect the entire region of memory containing the monitor and or operating system since this code is known functional Keep in mind that code in simulate protected memory ma
49. r ROM may be simulated There are several methods of initiating simulation Programs may be executed with trace on or off While trace is on each instruction will be displayed prior to its execution along with the current state of the CPU all register contents are displayed Trace provides a very powerful tool for following program flow Several keyboard commands may be invoked during actual program simulation These commands allow the speeding up or slowing down of simulation as well as ways to halt the execution of the program The PAST command is a powerful bookkeeper which keeps track of where your program has been 610 PURPOSE Start the program executing at the location to which the program counter currently points No machine values are altered with this command EXAMPLES GO Start the simulation at the PC G Does the same thing 22 5 6809 Debug Package J UMP lt address gt PURPOSE This command is exactly like GO except execution will begin at the address specified No machine values are altered with this command except the program counter which is set to lt address gt EXAMPLES JUMP 322 Start simulation at 322 J 80 Start simulation at 80 lt value gt PURPOSE Display the past several instructions executed by the simulated program If lt value gt is not specified the past 255 instructions will be printed oldest to most recent otherwise lt value gt sets the number of instruct
50. rating systems The trap is set at the address specified EXAMPLES STOP 100 Set stop trap at 100 STOP E0DO Set trap at a monitor entry lt 3j 5 6809 Debug Package XFR ON or OFF PURPOSE Enabling the XFR trap will cause a trap each time transfer of address type instruction is found JMP BRA LBRA LBxx or Bxx This is useful for following major program flow Typing G command after this trap will cause the program to start executing again EXAMPLES XFR ON Enable the transfer trap XFR OFF Turn the trap off VIII Interrupt Control FIRQ NMI and IRQ type interrupts may be simulated Two modes of operation are possible The first is automatic periodic interrupt generation This mode allows interrupts to be generated every N instructions The second allows random interrupt generation from the keyboard When these keys are typed during program simulation the appropriate interrupt will be issued Simulated interrupts advance the nesting level N as do subroutine calls The nesting level is decremented by the RTI instruction Simulated interrupts however will not cause a nest level trap to occur if the nesting limit is exceeded If a SYNC or CWAI instruction is being simulated the simulation will stop waiting for an interrupt to occur If automatic interrupt generation is enabled and the condition codes are set appropriately simulated execution will resume automatically If automatic interrupt generation 15
51. register list gt PURPOSE The SET command is used to set or assign values to registers The lt register list gt is list of register names DP X U S P followed by an equals sign followed by the hex value Setting a stack pointer will also set the corresponding depth value to the same value 5 6809 Debug Package EXAMPLES SET P 100 A C3 Set PC to 100 and to C3 5 20 X 1FFF Set to 20 X to 1FFF lt value gt PURPOSE Print the contents of the system stack number bytes specified by lt value gt will be printed lt value gt 15 not specified the top 12 bytes will be printed The stack is printed from high address to low address so the top of stack will be the last item printed EXAMPLES STACK Print the top 12 stack bytes STACK 10 Print the top 10 stack bytes STAT ES PURPOSE Display the current value of the states counter This value represents the number of actual machine cycles microseconds on a 1 megahertz computer which have been executed since the last START or RESET command It is also possible to set this counter to zero using breakpoints Only states for simulated instructions are counted real time and simulation protected routines do not accumulates states EXAMPLES STATES Print the current states count TRAIL PURPOSE Print the address of the last executed instruction which caused a transfer of address e g JMP
52. rinting the next sequential 256 bytes In this example typing an F would display the block starting at 1100 It is also possible to display the previous block of 256 bytes by typing a B for backward movement A carriage return will cause the debugger to regain control and the prompt will be issued Any other characters will be ignored It should be noted that any time the debugger is displaying data on the terminal the display may be stopped at the end of the line by typing an escape character Once stopped another escape will resume the display while a return will give control back to the debugger Another useful memory interrogation command is the FIND command which is used to find a specific string of bytes or characters in a selected block of memory As an example suppose there was a jump to subroutine instruction somewhere in your program It is known that the code is BD 34 00 and that it 15 somewhere between locations 100 300 The following command line will find it FIND 100 300 BD 34 00 This tells the debugger to look between memory locations hex 100 and 300 for the hex string BD3400 All memory locations which contain this string will be displayed on the terminal It is also possible to search for an ASCII string Suppose it was necessary to find the character string ERROR 3 in memory It should be somewhere between locations 200 and 1000 This can be done in the following way FIND 200 1000 ERROR 3
53. rmine those addresses to which to transfer control when simulated interrupt occurs It is possible to patch the Debug Package to reference other addresses in determining the location of interrupt routines These patch points contain addresses of locations which turn contain the addresses of the interrupt handling routines Be sure to preserve this double indirection when modifying these patch points NMI at 5520 default FFFC SWI at 5522 default FFFA IRQ at 5524 default FFF8 FIRQ at 5526 default FFF6 SWI2 at 5528 default FFF4 SWI3 at 552A default FFF2 V Saving the Altered Program After modifications have been made to the program it may be saved on mass storage The program should be saved from 5500 through 7FFF The starting or transfer address is 5500 48
54. s If it is necessary to re enter the Debug Package after an EXIT command the program should be entered at location 5503 the warm start entry point No 39 5 6809 Debug Package clearing of values or tables is performed at this entry Moving the Debug Package The Debug Package is written to be position independent it may be moved to any location in memory and it will run correctly without modification The following is an example of a program which moves the Debug Package to another memory location 8E 5500 LDX 5500 X OLD ORIGIN 10 LDY lt new origin address gt 80 TAG LDA MOVE 7 STA 8 8000 458000 CHECK ADDRESS 25 F7 BLO TAG IF NOT DONE JMP lt your monitor gt Insert the appropriate addresses for the xxxx and yyyy Note that if you are moving the Debug Package to a higher address you should start at the high end of the Debug Package and work downward After the Debug Package has been moved the cold start entry point is now at the lt new origin address gt and the warm start entry point is 3 locations higher For example if the Debug Package was moved to 1000 the cold start is at 1000 and the warm start is at 1003 When moving the Debug Package be sure to leave 500 bytes free below it for stack and variables The stack may be moved independently of the Debug Package see the section on Adapting to Your System for details
55. s the number of times the instruction at that address has been executed This is useful for determining hot spots or sections of programs which are executed very frequently By setting a histogram breakpoint at the first instruction of each subroutine in a program it is possible to find out exactly how many times each routine was called As an example suppose there were three subroutines in a program and they were located at 100 123 and 1A0 To set histogram counters at these locations type the following commands 100 123 1 After simulating the program typing HIST will display the totals of the counters at each address This command is used to examine the histogram counters at any time command is used to clear the histogram counters CLH 100 xxCLH first command will clear set to zero the value of the histogram 8 5 6809 Debug Package counter at location 100 second command will zero all of the counters The histogram commands allow a very complete profiling of a program letting the user fine tune it for maximum speed The remaining two action codes are special purpose One permits selected message to be printed as the action the second allows transfer of control to a specified address like a JMP instruction B M 325 SUB 1 B J 27C 1000 The first line will print the message SUB 1 each time the instruction at 325 is executed The second
56. specified address mnemonic and addressing mode will be printed out for each instruction in the range If an illegal opcode 15 found four stars will be displayed instead of a mnemonic followed by the hex value found at that address EXAMPLES DIS 100 1A0 Disassemble from 100 to 1A0 DU MP lt address gt PURPOSE Dump 256 byte blocks of memory starting at the address specified The memory is displayed 16 bytes per line followed by the ASCII values of the hex numbers After each block is dumped typing an F will move Forward and display the next 256 bytes typing a B will move Back and display the previous 256 bytes Typing a return will exit this mode EXAMPLES DUMP 0 Dump memory at A00 FIL L lt start address gt lt stop address gt lt byte gt PURPOSE This command will fill memory with the lt byte gt hex specified starting at the first address filling through the second address If lt byte gt is not specified zero will be used EXAMPLES FILL 100 300 FF Fill with FF from 100 to 300 FILL 0 100 Clear from 0 to 100 FIN D lt start address gt lt stop address gt lt string gt PURPOSE Find the specified string in memory The search will start at the lt start address gt and continue through the lt stop address gt The address of each location where the string is found will be displayed The lt string gt be entered in one of two ways The first can be a string of hex
57. tions specified the INST trap command have been executed ILLEGAL OPCODE AT The instruction to which the PC points 15 an illegal opcode I TRAP AT SWI 5 12 SWI3 RTI SYNC CWAI instruction has been encountered and the ITRAP command has been used to enable the interrupt trap LAST XFR FROM Displayed by request using the TRAIL command The address gives the location of the last transfer of address type instruction which was executed SYNTAX ERROR The command just entered does not follow the syntax rules for that command EP TRAP AT An Execution Protect trap at the specified location resulting from an attempt to execute code in execute protected memory WP TRAP AT A Write Protect trap at the specified location resulting from an attempt to write into write protected memory EX MP TRAP AT An attempt to execute code residing in memory protected memory has been detected at the specified address REF MP TRAP AT An attempt to reference read or write a byte in memory protected memory has been detected at the specified address SP TRAP AT A Stack Pointer reference PSH JSR etc was attempted in a section of memory which is memory protected TABLE OVERFLOW The last command entered caused an internal table to overflow The command did not get executed NC TRAP AT Nest Count trap occurred as a result of the nest level reaching the level specified in a NEST command 37 5 6809 Debug
58. ut the character itself and preserves the B and X registers II 1 0 Related Storage BSP at 551C This byte contains the character which is decoded as the backspace character currently a Control H 08 Change as desired DEL at 551D This byte contains the character which is decoded as the line cancel character currently a Control X 18 Change as desired BSE at 551E This byte contains the character which will be echoed after the receipt of backspace character currently a Control H 508 If this character is set to 08 a space will be output preceding the backspace echo character Setting this byte to zero will inhibit the backspace echo character ESC at 551F This byte contains the character which is decoded as the Escape character currently an ASCII Escape 1B This may be changed as desired 47 5 6809 Debug Package Stack Pointer References The stack pointer is normally preset to the origin address of Debug Package To use a different area for the stack load the system stack pointer S register with the desired stack address and enter the Debug Package at the origin address plus 6 5506 for cold start and at the origin address plus 9 5509 for warm start The Debug Package requires 500 bytes for stack space since it puts all variables and tables the stack IV Interrupt Vectors The Debug Package normally references the hardware interrupt vectors located at FFF2 FFFD to dete
59. utine from non simulate protected memory be contained in the area s of memory designated as simulate protected An example would be to simulate protect the section of memory where a DOS resides All subroutine calls to the DOS would then be executed in real time Code which is simulate protected and does not follow this convention will usually cause the CPU to take over the execution of the program resulting in a loss of control Other commands in this group allow examination of protection bounds as well as the clearing of protection types 51 lt types gt PURPOSE Display the bounds of protected memory Each lt type gt specified will list all regions of memory protected by that type lt type gt may be or 5 for write memory execute and simulate respectively Multiple types may be displayed by listing the types on the command line separated by a comma or space If no type is specified all types of protection will be listed EXAMPLES BOUNDS Display all memory protection BO M X Display memory and execute protection bounds 29 TSC 6809 Debug Package CLP lt type gt PURPOSE Clear all protected regions for a specified type of protection The lt type gt is specified by the same letters described in BOUNDS Only one type may be listed per command line If type 15 not specified all protection will be cleared EXAMPLES CLP Clear all protection X Clear execute protection P ROT
60. will cause the breakpoint defined on the line to remain inactive until lt count gt number of times through that address A count preceded lt will cause the breakpoint defined to be active for only the lt count gt number of times through that address at which time it will be automatically removed The lt count gt in either case must not exceed 32 000 The next part of the syntax is the optional lt conditional gt This allows the breakpoint action to be dependent on some condition The condition can be the contents of any machine register being equal or not equal to a hex value and respectively or the contents of a specified memory location being zero or not zero If a register is used simply state the register name followed by the relational followed by the hex value e g 23 or 2 The allowable registers are X U 5 and To use a memory location a dollar sign must precede the address For example 100 0 would check if the byte at location hex 100 was zero and A20 0 would check if the byte at location hex A20 was zero If a memory address is specified the only allowed value to the right of the relational is zero and if any other value is used an error message is issued NOTE The conditional part of the breakpoint definition may not be used with H M or J action codes Two of the breakpoint actions require special syntax These are the M message and J jump
61. y handy in determining what caused a program to end up in memory where it did The simulated machine is capable of running in two different modes These are referenced as mode 1 and mode 0 In mode 1 the default mode 11 checking and bookkeeping 15 performed In mode 0 several of the features are turned off in order to improve the speed performance of the Simulator It is recommended that mode 1 always be used since it does the most work for you and will catch more errors III Whats in Memory Now that the simulated CPU has been described we need to at memory The TSC 6809 Debug Package offers several ways of examining the contents of memory locations as well as altering them The simplest form is the MEM command or for short Typing followed by an address will display that byte of memory For example 100 100 CE shows that memory location hex 100 contains hex CE At this time several choices at hand If all you wanted to do was check the contents of location 100 simply type a carriage return and the debug prompt will be issued If you want to change the contents of 100 simply type the new value followed by a Space The space tells the debugger that the new value is ready to be entered It is only necessary to type the significant digits of the new value to be entered For example if 6 was to be entered simply type 6 followed by a space It should be noted that only the last two digits will be us
62. y of breakpoint combinations As an example B TZ 1000 gt 100 1F X 100 111 cause trace to be enabled and the states counter to be zeroed after executing the instruction at hex 1000 100 times but then only if the value of the index register is 100 It should be noted that the H M and J action codes will not allow a conditional expression as part of the breakpoint definition 10 5 6809 Debug Package Once breakpoints are set it is possible to examine the location of them as well as remove them To check the locations of breakpoints use the BP command RD 100 100 500 first line will print the location of all breakpoints each followed by list of its action codes No pass counts or conditionals are displayed The second example will display the action codes of the breakpoint at location hex 100 if one exists The last command line will display all breakpoints between location 100 and 500 inclusive The command is similar syntax but 15 used to clear or remove breakpoint CLB by itself will clear all breakpoints If it is followed by an address the breakpoint at that address will be removed If two addresses are specified then all breakpoints in their range will cleared While debugging very large programs it may become quite time consuming to simulate the program up to a desired address For example a program which requires a minute to execute in real time
63. y only be accessed via a subroutine call The command used to set protection is PROT A few examples will demonstrate its use PROT 100 3FF X PROT 2E0 W PROT 500 6FF M 1200 1F FF W The first example will execute X protect the memory between locations 100 and 3FF second line write protects location 2E0 last example will memory protect M locations 500 through 6FF and write protect 1200 through 1FFF There are some guidelines to follow when protecting memory Memory protection should be used on all sections of memory not referenced or used by the program being debugged especially the area of memory containing the Debug Package This will keep a runaway program from clobbering something it should not Sections of memory which are used for register storage flags should be execute protected Memory containing the actual program code should be write protected for obvious reasons Finally as mentioned above the memory locations where the monitor and or operating system reside should be simulate protected Once the protection has been defined it may be checked by using the BOUNDS command This command will allow the examination of the boundaries of each type of protection Either all types or selected ones may be displayed BOUNDS BOUNDS W M The first example will display all types while the second will show only the defined boundaries for write and memory protection Memory protection can be cl
64. yte gt FIN D lt start address gt lt stop address gt lt string gt lt address gt III Simulation Control 6 0 J UMP lt address gt lt value gt SIM lt count gt ST ART lt address gt STEP lt count gt T RACE lt value gt 5 1 lt count gt 35 5 6809 Debug 5 6809 Debug Package IV Breakpoints B lt action gt lt address gt lt modifier gt lt count gt 1F lt condition gt B lt address gt lt modi fier gt lt count gt 1F lt condition gt BP lt address gt lt address gt CLB lt address gt lt address gt CLH lt address gt lt address gt CLM HLIST lt address gt lt address gt RT lt address gt V Memory Protection BO LOUNDS lt types gt P ROT lt address gt lt address gt lt type gt VI Execution Traps INST lt count gt IT RAP ON or OFF NLEST lt value gt STOP lt address gt XFR ON or OFF VII Interrupt Control FIRQ lt count gt IRQ lt count gt NMI lt count gt 36 5 6809 Debug Package Message Descriptions The following is a list of all Debug generated messages their respective meanings WHAT This is the general error message reported when an invalid input command has been entered STOP AT The address set by the STOP trap command has been reached TIMEOUT AT number of instruc
Download Pdf Manuals
Related Search
Related Contents
Product ManualDownload PDF Samsung Galaxy Note 4 manual do usuário(OPEN) British Telecom Baby Monitor 250 Appliance Manual SMP 350ML - SMP Canada User`s manual FLIR A3xxseries FLIR A6xx series Lightolier FW7200 User's Manual Denon DCD-SA1 User Guide Manual - DVDPlayer Notas acerca deste manual de instruções Dados pessoais Nosso Copyright © All rights reserved.
Failed to retrieve file