nimate...............................27
4.2.13.2 ingle step...........................27
4.2.13.3 roc step.............................28
4.2.13.4 Using race..........................28
4.2.14 nassemble.................................29
4.3 The Repeat Count....................................30
4.4 Program Termination.................................31
5.0 Notes about Debugging with TTCD.........................32
5.1 Source Code Formatting..............................32
5.2 Mnemonic Differences................................32
5.3 Special Interrupts..................................33
5.4 Floating Point Emulation Deviations.................33
5.5 Floating Point Problems.............................33
5.6 Optimization Options................................34
5.7 The "#line" Directive...............................34
5.8 Memory Considerations...............................34
5.9 Interrupt Vector Trapping...........................35
5.10 Trapping Math Errors...............................35
6.0 Input responses to TTCD prompts.........................36
6.1 Input field editing.................................36
6.2 Case sensitivity....................................36
6.3 Input Radix Defaults................................37
6.4 Address Specification Defaults......................37
7.0 TTCD.MAC Format and Use.................................38
8.0 Known TTCD Bugs and Anomalies...........................39
iv
1.0 About TTCD
1.1 Background
The Turbo C (tm) compiler is (for the most part) a very complete C
compiler. It fully supports K & R definitions, has library
routines supporting nearly all applicable UNIX "standard C library"
calls, and supports most of the (proposed) ANSI C standard.
Moreover, like the ubiquitous Turbo Pascal (tm) it has several
useful (and high-powered) machine-/DOS-dependant language
extensions and library routines.
As an advanced C programmer, the first thing I did with Turbo C was
to try to re-compile some of my previously written C programs with
it. The C compiler that I have used for several years was not as
close to the "UNIX type" compiler, and did not attempt to emulate
the UNIX environment. I quickly discovered that one thing I really
needed did not come with Turbo C. A tool that no C programmer
should be without - a good debugger. I presume that the people at
Borland expect Turbo C users to use the DOS "DEBUG" program, or
some equivalent product.
1.2 What is TTCD?
TTCD is a symbolic source-level debugger for programs written in
Turbo C.
TTCD allows debugging Turbo C programs via:
o Normal execution to any specified line, procedure, or user-
specified breakpoint(s).
o Single-stepping through execution.
o Program "animation".
TTCD supports:
o All Turbo C models except "Tiny".
o Real-time examination/modification of variables, memory, and
machine registers.
o Variable-speed animation.
o "Conditional" and "looping" breakpoints.
o "Sticky" and "Non-sticky" breakpoints.
o 8087 code, or floating point emulation.
About TTCD Page 1
o Retaining variables, memory locations, or the machine
registers on the screen.
o Symbolic dis-assembly of program code.
o Key-macros.
o Programs that generate CGA and EGA graphics.
o Multiple source-module programs.
o 80186/80286 instructions.
1.3 Files included with TTCD
The files included with this release of TTCD and their descriptions
are:
o TTCD.EXE - This is the TTCD program.
o TTCD.DOC - Users guide for TTCD.
o TTCD.TC - Sample Turbo C configuration file for use when
compiling a program to be debugged with TTCD.
o TTCD.MAC - This is a sample TTCD macro file. It contains
useful definitions for function keys thru . Use
the acro isplay command, or MAC2TEXT to display the
recorded key strokes.
o MAC2TEXT.C - This is the source code to a program that will
convert the TTCD.MAC macro file to readable text. When
compiled, this program will allow you to view TTCD macros
that you have recorded and saved.
1.4 Limitations of this version of TTCD
This version of TTCD has some limitations. They are:
o "Tiny" model programs are not supported.
o Programs that use VGA Graphics are not supported.
o Maximum number of global symbols is 5000.
o Maximum number of modules is 30.
o Maximum number of lines per module is 65000.
About TTCD Page 2
1.5 TTCD and Different Turbo C Versions
I have Turbo C version 1.0 dated 6/3/87. All applicable Borland
patches (TCP1.DIF thru TCP9.DIF) have been applied to it. TTCD was
created with this version of Turbo C, and all my testing was done
using programs compiled with this version of Turbo C. Patched or
later versions may not have some of the problems discussed in
section 5 of this users guide.
I fully expect TTCD to be compatible with future versions of Turbo
C unless radical changes are made in the product. If a new version
of Turbo C is "TTCD incompatible", REGISTERED FULL VERSION TTCD
USERS WILL BE ABLE TO DOWNLOAD TTCD UPGRADES AT NO CHARGE (except
the cost of the phone call).
For information about new versions of TTCD, or download
availability call Pat at (713) 487-8379.
1.6 Future Directions of TTCD
In future releases of TTCD, I plan to support the following:
o Auto-configuration of global variable "types" for the
isplay and nter commands.
o OS/2 (when Borland produces a Turbo C for it).
o Programs that generate VGA graphics.
o Expanded memory use for graphics screen swapping and caching
of source code.
About TTCD Page 3
2.0 What is Required
An understanding of how C utilizes memory is necessary for serious
C program writing, and useful for debugging any C program. Also a
knowledge of 8086 Assembler is recommended.
2.1 Hardware and software required
A fixed disk is recommended, but not required. If a fixed disk is
not available, the use of a RAM disk or disk cache will minimize
the wait for source code to be displayed.
The following hardware and software is required to make use of
TTCD:
o Version 1.0 (or greater) of Turbo C.
o Approximately 128K bytes + the memory required by the target
program. In addition, about 12K more memory is required if
the "-C" command line option is used, and about 108K more if
the "-E" command line option is used. See section 3.1 for
explanations of these options.
2.2 Compile and Link options and settings required
2.2.1 Compile Options
To debug a Turbo C program with TTCD, the program must be compiled
with the following options set:
o "Model": Any model except "Tiny".
(NOTE: THE LIMITED VERSION OF TTCD WILL ONLY HANDLE "SMALL"
MODEL PROGRAMS.)
o "Calling convention": "C".
o "Underbars": On.
o The "Line numbers" option must be on for any modules that
you intend to "step through" or set breakpoints in. The
module that contains 'main()' must be compiled with line
numbers on.
What is Required Page 4
The following option settings are recommended, but not required:
o "Standard Stack Frame": On.
o "Use Register variables": Off.
o "Register Optimization": Off.
o "Jump Optimization": Off.
All other compile options may be set as desired.
2.2.2 Link Options
To debug a Turbo C program with TTCD, the program must be linked
with the following options set:
o A "Map" file must be produced with either the "Publics" or
"Detailed" options on. Preferably the "Publics" option, as
this is smaller, and faster to read.
o The "Class names" must not be changed for code, data, or
BSS.
All other link options may be set as desired.
2.3 Source code requirements
Any source modules that you intend to step through, or set
breakpoints in must be compiled with the "Line numbers" option on.
The default maximum number of modules compiled with line numbers is
10. This may be changed via command line options. See section
3.1.
The source code for any module compiled with line numbers must be
in the current directory when executing TTCD. If it is not found,
an error message to that effect will be displayed. In this case,
you may continue debugging without source code until control is in
a module whose source code can be displayed. The o command may
be useful to get out of this situation and continue debugging as
normal.
2.4 Related files
In order to debug a Turbo C program, TTCD needs quite a bit of
information about it. This information is obtained from the .MAP
file produced by the linker. For instance, to debug a program
named "HELLO.EXE", TTCD will also need "HELLO.MAP" (produced by the
linker) and "HELLO.C", the program source code. If the program
consists of multiple source code modules, these files should also
be available to TTCD if compiled with line numbers.
What is Required Page 5
TTCD will read the .MAP and .EXE files and create a file with the
extension ".DBG". The .DBG file is a relocatable program similar
to an .EXE file, but it will not execute properly outside of TTCD.
The .DBG file will be erased automatically, upon termination of
TTCD.
NOTE: TTCD does not change the .EXE file. If the program works
properly, it does not have to be re-compiled.
Warning: If any of the source code modules are changed, and not
re-compiled, the .EXE file (and consequently the .MAP and .DBG
files) may not reflect the correct line number or procedure
addresses. This could create quite a bit of confusion during the
debugging process.
What is Required Page 6
3.0 Executing TTCD
3.1 The TTCD Command Line
The TTCD command line is as follows:
TTCD [options] PROGRAM
Where PROGRAM is the name of the .EXE file to debug (the "target"
program). The extension need not be specified as it must be an
.EXE file. The target program and its map file must be in the
current directory, on the current drive.
The TTCD options are as follows:
-C (CGA Graphics option on)
This option specifies that buffer space should be allocated for
storage of a 16K "program screen". Note that the program is not
automatically put in any graphics mode if this is specified.
Screen modes are still controlled by the target program. This
option causes TTCD to use about 12K more memory, and causes
slightly slower screen-swapping. THIS OPTION IS NOT AVAILABLE IN
THE LIMITED VERSION OF TTCD.
-E (EGA Graphics option on)
This option specifies that buffer space should be allocated for
storage of a 112K "program screen". This option causes TTCD to use
about 108K more memory. Screen swapping is much slower when the
target program is in any of the EGA graphics modes than when in the
text or CGA modes. THIS OPTION IS NOT AVAILABLE IN THE LIMITED
VERSION OF TTCD.
-S### (Number of global symbols)
This option specifies the size of the global symbol table. The
default is 500 symbols (the limited version default is 300). This
option is for use with programs that have more than 500 symbols.
It may also be used to decrease the symbol table size if the
debugger runs out of memory. THE LIMITED VERSION OF TTCD SUPPORTS
A MAXIMUM OF 300 SYMBOLS. No white space is allowed between the
'S' and the digits.
-M## (Number of modules with line numbers)
This option specifies the size of the 'module table'. The default
is 10 modules. This option is for use with programs that are
broken into many small modules. Only the number of modules
compiled with line numbers use module table space. Modules that
are compiled without line numbers do not need to be included in the
module count. No white space is allowed between the 'M' and the
digits.
Executing TTCD Page 7
3.2 The TTCD Startup Screen
When execution of TTCD starts, it will display status lines showing
that it is reading the map file, and generating the ".DBG" file.
When the program variables and tables are set up, some status
information will be displayed. This should look similar to the
following:
TTCD Version 1.0
Created by Steve York.
Copyright (c) 1987 by SAYSoft, Inc.
Full version.
Reading MCALC.MAP . . .
Creating MCALC.DBG . . .
Map contains:
279/500 global symbols
6/10 module definition(s) with line numbers
1534 lines total
24170 bytes free.
Press to abort, any other key to start.
This tells us:
o There are 279 global symbols in MCALC. This includes
procedure names, global variables, procedure names linked in
from libraries, and the overhead generated by Turbo C. The
symbol table size is set to 500 symbols (default table
size).
o There are 6 program modules compiled with the 'line numbers'
option on. The module table is set to 10 modules.
o There are 1534 executable lines. This is only a sum of the
lines in the modules compiled with line numbers.
o There are about 24K bytes of data space left for MCALC to
"grow", and still fit in TTCD with line numbers for all six
modules. (Enough space for about 2000 more lines in modules
compiled with line numbers.)
TTCD is "small" model program itself. Consequently its own data
space is limited to 64K. This is enough space for fairly large
target programs. Programs of nearly any size can be debugged with
TTCD if only selected modules are compiled with numbers.
Executing TTCD Page 8
3.2 Getting Started
TTCD has several commands and menus, however, it is relatively
straightforward to learn and use. To become acquainted with TTCD,
it is a good idea to "step through" a working program before
actually using it to debug a program with problems.
For a simple example, "MAC2TEXT" can be used to "test drive" TTCD.
MAC2TEXT.C is one of the files distributed with TTCD. Its purpose
is to convert TTCD macros to readable text.
For a more complete example, the "MCALC" program that comes with
Turbo C can be used to "test drive" TTCD.
In either case, compile all source code modules with the "line
numbers" option on. Set all other compile and link options as
described in section 2.2.
When either MAC2TEXT.EXE or MCALC.EXE has been generated, enter (at
the DOS prompt) the corresponding command:
TTCD MAC2TEXT
or
TTCD MCALC
If the target program has been compiled correctly, and the
necessary files are in the current directory, the TTCD startup
screen will be displayed. This will resemble the example shown in
section 3.2. Press any key (excpet ) to go to the TTCD main
menu.
At this point, try each of the commands described in section 4.2 to
become familiar with them, and how they are used.
Executing TTCD Page 9
4.0 The TTCD Commands and Displays
Menus and prompts in TTCD are always on the top line of the screen.
Menu options are selected by pressing the first letter of the
command. The key will always exit a menu with no action, and
return to the Main menu.
The second line of the screen is a status line. The rest of the
screen is used to show source lines, variable, memory and register
values, and other information.
4.1 The Status line
The second line of the screen is the status line. It displays the
current module name, procedure/function name, and source line
number within that module. For instance, the top two lines of the
screen may look like:
- Menu 2 reakpoints alc isplay ...
========= Module: HELLO.C Proc: main() Line: 16 =====...
The status line tells us:
o We are in a source code module named "HELLO.C".
o We are in procedure "main".
o The next line to execute is source line number 16.
The left end of the status line also shows other information. If a
macro-recording is in progress, the leftmost column will have an
'R'. If the rint command is active, the second column will have
a 'P'. If the repeat count value (see section 4.3) is greater than
zero, its value is displayed near the left end.
4.2 The Main Menu
The "Main menu" actually consists of three lines, only one of which
is displayed at a time. The key changes the displayed
line. The three lines are:
- Menu 2 reakpoints alc isplay nter
o
- Menu 3 eep ist acro ptions rint
uit
- Menu 1 creen race nassemble
Options are selected by pressing the letter in the angle-brackets.
The space bar simply toggles the display of these two lines, any
The TTCD Commands and Displays Page 10
option may be selected at any time whether that option is currently
displayed at the top of the screen or not.
Each of the options on the main menu is discussed below.
4.2.1 reakpoints
A breakpoint is a place at which you wish to stop program execution
and return to the debugger menu. TTCD has ten user-definable
breakpoints. They are numbered 0 thru 9. These ten breakpoints
are divided into two types. They are:
o "Non-sticky" breakpoints - these are breakpoints that are
automatically cleared anytime the debugger becomes active
again. When the debugger menu returns, all non-sticky
breakpoints are cleared. Breakpoints 0 thru 4 are non-
sticky breakpoints. acros are useful for repeatedly
setting non-sticky breakpoints selectivly.
o "Sticky" breakpoints - these are breakpoints that are active
until actually cleared, or until the debugger is exited.
All sticky breakpoints will still be active when the o
option is selected again. Breakpoints 5 thru 9 are sticky
breakpoints. acros are useful for "turning on" or
"turning off" sets of sticky breakpoints selectivly.
Breakpoints are not active when tracing (see the race command,
section 4.2.13) through a program, only when the o command is
selected.
When the reakpoint command is selected, the user will be asked
for a breakpoint number. When a number key (<0> thru <9>) is
pressed, the following menu will be displayed:
onditional isplay ine number rocedure eset
Each of these options is discussed below.
All user-defined breakpoints have a loop count assoicated with
them. The repeat count (see section 4.3) specifies the loop count
of any break point. If no repeat count is entered, the loop count
is initialized to 1, except for conditional breakpoints, which are
initialized to 9999. A breakpoint with a loop count of 1 will trap
program execution the first time it is encountered.
4.2.1.1 onditional
This option will allow you to set a condition for any breakpoint.
Breakpoint conditions consist of non-compound statements of the
form:
The TTCD Commands and Displays Page 11
or
or
Where:
is one of the registers listed in section 4.2.4.1.
is a global symbol name. Note the symbol must be a
scaler here. If you need to compare the value of a structure
or array member, its address must be specified.
is an address as specified in section 4.2.3.7.
is one of the following: = != < <= > >=
is a numeric constant.
If a symbol or an address is specified, you will be asked a value
"type". Conditional types are a subset of the type discussed in
section 4.2.3.6. The conditional types are as follows:
har ouble loat nt ong nsigned
These types are identical to their counterparts as discussed in
section 4.2.3.6.
When the condition and type are entered, you will be returned to
the menu in 4.2.1 to complete the breakpoint setting.
4.2.1.2 isplay
This option will display all breakpoint settings. The breakpoint
number specified is not used if this option is selected. The
breakpoint number (0 thru 9), its loop count, condition (if any),
and address is displayed for each active breakpoint. The following
is a sample breakpoint display:
Active Breakpoints:
# Count Condition Address
1 1 None 5565:0176 -> Line: 5
6 1000 AX != 0x2 5565:031A -> Proc: display()
This shows two breakpoints set. Breakpoint #1 (non-sticky) is set
to break the first time we reach line 5 of the current module.
Breakpoint #6 (sticky) will break when we get to the procedure
"display()", and register AX is not equal to 2, or the 1000th time
we get to "display()", which ever occurs first.
The TTCD Commands and Displays Page 12
4.2.1.3 ine number
This option will allow you to set a breakpoint to any valid line
number in the CURRENT module. When selected, you will be asked the
line number. When entered, the specified breakpoint will be set to
break before execution of that line.
4.2.1.4 rocedure
This option will allow you to set a breakpoint to any valid
procedure in any module compiled with line numbers. When selected,
you will be asked the procedure name. When entered, the specified
breakpoint will be set to break before execution of that procedure.
4.2.1.5 eset
This will clear the specified breakpoint. This would only be
necessary for breakpoints 0 thru 4 if you set one then decide to
remove it before execution. These breakpoints are cleared
automatically anytime the debugger menu returns.
4.2.2 alc
The alc command invokes a simple expression calculator. When
selected, you will be asked to enter an expression. The expression
may contain decimal and hexidecimal numbers (prefixed with "0x"),
+, -, *, /, and unary minus. When a valid expression is entered,
its value will be displayed. The resulting value is a signed long,
and is printed both in decimal and hex. For example, the following
may be entered at the expression prompt:
0x3a9 + 51 * 17
The normal mathematical hierarchy is adhered to (i.e. -
multiplication performed before addition).
After evaluating an expression, you may enter another expression to
be evaluated, or press to return to the menu.
The alc command is also useful for converting numbers from hex
to decimal and vice-versa.
The TTCD Commands and Displays Page 13
4.2.3 isplay
The display command allows viewing of variables, memory, the
current "frame storage area" (the stack, and local variables), or
the machine registers. It may also be used to display the list of
public identifiers. When this option is chosen, the following menu
will be displayed:
lobal symbol emory ublics egisters tack
Each of these options is discussed below.
4.2.3.1 lobal symbol
This option allows you to display the value of a public identifier
(function or global variable) by name. When selected, you will be
asked for the identifier name. If the identifier is a function
name, its address will be displayed. If it is any other global
symbol type, you will be asked for a 'type', as described in
section 4.2.3.6. When entered, the variable value will be
displayed.
4.2.3.2 emory
This option allows you to display any memory address as if it were
the location of a C variable, of any type. When selected, you will
be asked for an address (see section 4.2.3.7 for valid TTCD address
specifications), and a 'type' as described in section 4.2.3.6.
When entered, the value at the specified address will be displayed.
NOTE: The value entered, is an address expression. Suppose we have
the following assembler instruction:
MOV AX,[BP+FFFE]
And you wish to see what value will be moved into AX before this is
executed. The isplay emory option may be used to see the
value. Enter the address as:
BP+FFFE
not:
[BP+FFFE]
The former would display the value at 'BP+FFFE'. The latter would
display the value of the address at 'BP+FFFE' - another level of
indirection. The latter is useful if the variable stored at
'BP+FFFE' is a pointer, and you wish to see the value of the object
being pointed to.
The TTCD Commands and Displays Page 14
4.2.3.3 ublics
This option will display all global symbols, along with their
addresses. When selected, all publics found in the .MAP file will
be displayed, one screen at a time. Procedure names will be
displayed with '()' following the name.
4.2.3.4 egisters
This option will display the machine register and flag values, with
a format similar to the following:
AX=0000 BX=049A CX=0000 DX=0014 SP=FFEC BP=FFF6 SI=003B DI=0454
DS=518C ES=518C SS=518C CS=5079 IP=0174
CF=0 SF=0 ZF=0 DF=0 OF=0 IF=1 PF=0 AF=0
4.2.3.5 tack
This option will display the memory in the current 'frame', and the
32 bytes above the current frame (where function parameters are).
The current frame memory is the memory between [BP] and [SP]. When
selected, the frame and parameter areas are displayed in a
hex/ASCII dump format. This display might resemble the following:
0xA bytes local space: (BP=FF82 SP=FF78)
[BP+FFF6] 01 00 00 00 00 00 00 00 24 40
........$@
Parameter space:
[BP+0000] DC FF 26 85 32 00 F8 1D 8C FF 32 2A 35 00 20 0E
..&.2.....2*5. .
[BP+0010] 20 0E 4B 05 7B 22 8C 05 7B 22 4D 00 1E 27 73 03
.K.{"..{"M..'s.
This display shows a hex dump of the 10 bytes of local storage that
the current procedure has allocated on the stack. It also allows a
simple way of displaying procedure parameters, and memory
referenced to the BP register. For example, given the following
assembler instructions:
MOV AX,[BP+4]
ADD AX,[BP+FFF6]
MOV [BP+FFF8],AX
Using the command, the action produced by these
instructions is much easier to trace. These instructions will move
a 0x32 into register AX, add 1 to it, and store the result at
BP+FFF8.
Note: Procedures that do not have any local storage may not set up
a frame, and use the BP register as a frame pointer. The
command may not show anything useful in this case. The "Standard
The TTCD Commands and Displays Page 15
Stack Frame" option can be used to force all procedures to set up a
frame with BP as the frame pointer.
The key will stop the display if it scrolls off the
screen.
4.2.3.6 Display 'Types'
When the option or the option is selected, a
display type must be specified. The display type menu consists of
two lines, only one of which is displayed at a time. They are as
follows:
- Menu 2 har ouble loat ex nt
ong
- Menu 1 ffset <2>-ptr <4>-ptr tring
nsigned
NOTE: The limited version of TTCD does not have the four-byte
pointer option:
<4>-ptr
These specify the size and type of the item to be displayed, as
follows:
o har - the byte at the specified address is displayed as a
character, if printable. Also the hex value is displayed in
parenthesis.
o ouble - the 8 bytes starting at the specified address are
displayed as a 'double' floating point number.
o loat - the four bytes starting at the specified address
are displayed as a floating point number.
o ex - memory starting at the specified address is dumped
in a hex/ASCII format.
o nt - the two bytes at the specified address are displayed
as an integer. Also the hex value is displayed in
parenthesis.
o ong - the four bytes starting at the specified address
are displayed as a signed long integer. Also the hex value
is displayed in parenthesis.
The TTCD Commands and Displays Page 16
o ffset - this option is used to specify the offset in a
structure or array of the object whose value is to be
displayed. When chosen, you will be asked to specify the
offset value. After specifying an offset, another display
type may be selected. The ffset is always specified in
bytes, not in units of data-item size. See section 4.2.3.8
for examples its use.
o <2>-ptr - this tells TTCD that the value at the specified
address is a 2-byte pointer to some data item. When
selected, the user is left at the 'type' menu to specifiy
what type the pointer points to. Another type may then be
specified. The value of the object pointed to is then
displayed. See section 4.2.3.8 for examples its use.
o <4>-ptr - this tells TTCD that the value at the specified
address is a 4-byte pointer to a data item. This command is
the four-byte equivalent to the <2>-ptr option, and operates
in a similar fashion.
o tring - memory starting at the specified address is
displayed as a string. Non-printable and special characters
are converted to their C equivalents. i.e. - a character 9
is displayed as '\t'. The string will be displayed with
vertical bars (|) at each end of it so that leading/trailing
white space may be seen. If the string is longer than 50
characters, it will be truncated, and displayed with an
ellipses (. . .) following it.
o nsigned - the two bytes at the specified address are
displayed as an unsigned integer. Also the hex value is
displayed in parenthesis.
The acro capabilities are very useful for displaying a variable
value after repeated race or o commands.
4.2.3.7 Valid TTCD Addresses
When TTCD prompts for a machine address, any of the following
formats may be used:
o offset
o segment:offset
o [offset]
o segment:[offset]
Where:
Offset is a constant, a register, or a register +/- a constant.
Segment is a constant, or a segment register.
The TTCD Commands and Displays Page 17
NOTE: The address-decoding routine is 'dumb'. In an attempt to be
as flexible and simple as possible, it performs basic syntax
checking only.
4.2.3.8 isplay Command Examples
The isplay command has the ability to display the value of any
scaler, or string variable by global symbol name. This command can
be very complicated due to pointer, array, and/or structure
combinations.
In order to use these capabilities, it is important to understand
each of the display 'types'. The examples shown below should help
clarify the isplay 'types'. Note that all of the 'types'
discussed in 4.2.3.6 apply to the isplay emory command as
well as the isplay lobal command.
Example 1:
Lets suppose I have the following global declaration in a small
model program:
char *ptr={"Steve"};
I may display the value of the POINTER by pressing:
ptr
(isplay lobal "ptr" nteger)
This will display (in decimal and hex) the location of where
"Steve" is stored.
The value of the OBJECT pointed to (the string "Steve") may be
displayed by pressing:
ptr <2>
(isplay lobal "ptr" <2>-ptr tring)
This tells TTCD to display the string pointed to by the 2-byte
pointer "ptr".
The TTCD Commands and Displays Page 18
Example 2:
Lets suppose I have the following declarations in a small model
program:
#include
#include
char *my_equ={"26.34/2"}; /* Pointer to a string. */
struct my_struct {
int type; /* 2 byte integer. */
double value; /* 8 byte double. */
char near *equation; /* 2 byte pointer. */
};
struct my_struct far *my_ptr; /* 4 byte pointer. */
main()
{
my_ptr=malloc(sizeof(struct my_struct));
my_ptr->type=1000;
my_ptr->value=13.17;
my_ptr->equation=malloc(strlen(my_equ)+1);
strcpy(my_ptr->equation,my_equ);
.
.
(Rest of program)
.
.
}
The value of any of the members of "my_ptr->my_struct" can be
displayed using the isplay lobal command.
The integer value "my_ptr->type" may be displayed by pressing:
my_ptr <4>
(isplay lobal "my_ptr" <4>-ptr nteger)
The double precision value "my_ptr->value" may be displayed by
pressing:
my_ptr <4> 2
(isplay lobal "my_ptr" <4>-ptr ffset "2" ouble)
The string "my_ptr->equation" may be displayed by pressing:
my_ptr <4> 10 <2>
(isplay lobal "my_ptr" <4>-ptr ffset "10" <2>-ptr
tring)
The TTCD Commands and Displays Page 19
The third character of the string "my_ptr->equation" may be
displayed by pressing:
my_ptr <4> 10 <2> 3
(isplay lobal "my_ptr" <4>-ptr ffset "10" <2>-ptr
ffset "3" har)
The TTCD key acros are very useful for repeatedly displaying
variable values.
4.2.4 nter
The nter command allows you to change register or memory values.
When selected, the following menu will be displayed:
egister emory
Each of these options is discussed below.
4.2.4.1 egister
This option will allow you to change the value of a machine
register. When selected, you will be asked the register name. The
valid register names are:
Byte: AL CL DL BL AH CH DH BH
Word: AX CX DX BX SP BP SI DI
Segment: ES CS SS DS
When a register name is entered, you will be prompted for a value.
The value must be specified by two or four hex digits. If a byte
register is selected, and a word value is entered, only the lower
byte will be set into the register.
Warning: It is NOT a good idea to change any of the following
registers unless you know exactly what you are doing:
CS SS SP BP
4.2.4.2 emory
If this option is selected you will be asked for an address (see
section 4.2.3.7 for address specifications). Next, you will be
asked for a 'type'. The type-specification menu is as follows:
har ouble loat ex nt ong nsigned
The TTCD Commands and Displays Page 20
Each of these types is similar to its corresponding isplay
'type', except that you will be asked for a value to put at the
specified memory address. The only differences are:
o har - when entering characters, multiple characters may
be entered at one time. These characters will be put in
memory starting at the specified address, continuing for as
long as the input string (up to 50 characters). The C
special characters may be used in the input. i.e. - '\t'
will specify character number 9. This input routine allows
input of any character via '\###'. Where '###' represents
up to 3 hex digits.
NOTE: Due to ambiguities, you should be very careful when
specifying a character via '\###'. For instance:
o "\felix" is 5 characters.
They are: '\f' 'e' 'l' 'i' 'x'.
The '\f' is taken as a formfeed character.
o "\0felix" is 4 characters.
They are: '\0fe' 'l' 'i' 'x'.
The '\0fe' is taken as one character (0xfe).
o "\00felix" is 5 characters.
They are: '\0f' 'e' 'l' 'i' 'x'.
The '\00f' is taken as one character (0xf).
o "\000felix" is 6 characters.
They are: '\0' 'f' 'e' 'l' 'i' 'x'.
The '\000' is a null character.
o ex - multiple bytes may be entered via this option. The
input string may be up to 50 characters long. These values
will be put in memory starting at the specified address.
Hex numbers may be separated by spaces, commas, or periods
when more than one is specified. Any of the following are
valid hex values:
0D0A0D0A
d a d a
0D,0A,0D,0A
0D.0A.0D.0A
4.2.5 o
The o command allows executing the program to a certain point.
When selected, the following menu will be displayed:
orever ine number rocedure
Each of these options is discussed below.
The TTCD Commands and Displays Page 21
4.2.5.1 orever
This option specifies that the o command should execute until