Masm50 Codeview and Utilguide
Masm50 Codeview and Utilguide
axjPdata
C
Fortran
iS the sane Fasca1
Microsoft
pcjs.org
CodeView
And
T Ttilities
SOFTWARE DEVELOPMENT TOOLS
pcjs.org
Information in this document is subject to change without notice and does not
represent a commitment on the part of Microsoft Corporation. The software
described in this document is furnished under a license agreement or nondisclosure
agreement. The software may be used or copied only in accordance with the terms
of the agreement. The purchaser may make one copy for backup purposes. No
part of this manual may be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying and recording, for any
purpose other than the purchaser's personal use without the written permission of
Microsoft Corporation.
Microsoft®, MS-DOS®, MS®, XENIX®, and CodeView® are registered trademarks of Micro
soft Corporation.
AT&T® is a registered trademark of AT&T Information Systems.
IV
pcjs.org
2.2 Using Sequential Mode 66
4 CodeView Expressions 75
4.1 C Expressions 78
4.1.1 C Symbols 79
4.1.2 C Constants 80
4.1.3 C Strings 81
4.2 FORTRAN Expressions 81
4.2.1 FORTRAN Symbols 83
4.2.2 FORTRAN Constants 83
4.2.3 FORTRAN Strings 84
4.2.4 FORTRAN Intrinsic Functions 85
4.3 BASIC Expressions 86
4.3.1 BASIC Symbols 88
4.3.2 BASIC Constants 88
4.3.3 BASIC Strings 89
4.3.4 BASIC Intrinsic Functions 89
4.4 Pascal Expressions 91
4.4.1 Pascal Symbols 92
4.4.2 Pascal Constants 93
4.4.3 Pascal Strings 93
4.4.4 Pascal Intrinsic Functions 93
4.5 Assembly Expressions 95
4.6 Line Numbers 97
4.7 Registers and Addresses 97
4.7.1 Registers 98
4.7.2 Addresses 99
4.7.3 Address Ranges 100
pcjs.org
4.8 Memory Operators 101
4.8.1 Accessing Bytes (BY) 101
4.8.2 Accessing Words (WO) 102
4 . 8 . 3 A c c e s s i n g D o u b l e Wo r d s ( D W ) 103
4.9 Switching Expression Evaluators 104
6 Examining Data
and Expressions 121
6.1 Display Expression Command 123
6.2 Examine Symbols Command 132
6.3 Dump Commands 138
6.3.1 Dump 139
6.3.2 Dump Bytes 140
6.3.3 Dump ASCII 141
6.3.4 Dump Integers 141
6.3.5 Dump Unsigned Integers 142
6.3.6 Dump Words 143
6.3.7 Dump Double Words 144
6.3.8 Dump Short Reals 144
6.3.9 Dump Long Reals 145
6.3.10 Dump 10-Byte Reals 146
6.4 Compare Memory Command 147
6.5 Search Memory Command 148
6.6 Port Input Command 149
V I
pcjs.org
Contents
Vll
pcjs.org
Contents
11 Using CodeView
System-Control Commands 227
11 . 1 Help Command 229
11 . 2 Quit Command 230
11 . 3 Radix Command 231
11 . 4 Redraw Command 233
11 . 5 S c r e e n E x c h a n g e C o m m a n d 233
11 . 6 Search Command 234
11 . 7 S h e l l E s c a p e C o m m a n d 237
11 . 8 Ta b Set Command 239
11 . 9 Option Command 240
Vlll
pcjs.org
Contents
Part 2 O Utilities
12 Linking Object Files
with LINK 253
12.1 Specifying Files for Linking 255
12.1.1 Specifying File Names 255
12.1.2 Linking with the LINK Command Line 256
12.1.3 Linking with the LINK Prompts 258
12.1.4 Linking with a Response File 260
12.1.5 How LINK Searches
for Libraries 261
12.1.6 LINK Memory Requirements 263
12.2 Specifying Linker Options 264
12.2.1 Viewing the Options List (/HE) .265
1 2 . 2 . 2 P a u s i n g d u r i n g L i n k i n g ( / PA U ) 2 6 6
12.2.3 Displaying Linker Process Information (/I) 266
12.2.4 Packing Executable Files (/E) 267
12.2.5 Listing Public Symbols (/M) 268
12.2.6 Including Line Numbers
in the Map File (/LI) 269
12.2.7 Preserving Case Sensitivity (/NOI) 269
12.2.8 Ignoring Default Libraries (/NOD) 269
12.2.9 Controlling Stack Size (/ST) 270
12.2.10 Setting the Maximum Allocation
Space (/CP) 270
12.2.11 Setting Maximum Number
of Segments (/SE) 271
12.2.12 Setting the Overlay Interrupt (/O) 272
IX
pcjs.org
Contents
13 Managing Libraries
with LIB 287
13.1 Managing Libraries 289
13.1.1 Managing Libraries
with the LIB Command Line 290
13.1.1.1 Specifying the Library File 290
13.1.1.2 Specifying a Page Size 291
13.1.1.3 Giving LIB Commands 291
13.1.1.4 Specifying a
Cross-Reference-Listing File Zvo
13.1.1.5 Specifying an Output Library 293
pcjs.org
13.1.2 Managing Libraries
with the LIB Prompts 295
^ ^ 13.1.2.1 Extending Lines 295
13.1.2.2 Using Default Responses 296
13.1.3 Managing Libraries
with a Response File 296
1 3 . 1 . 4 Te r m i n a t i n g t h e L I B S e s s i o n 297
13.2 Performing Library
M a n a g e m e n t Ta s k s w i t h L I B 2 9 7
13.2.1 Creating a Library File 298
13.2.2 Changing a Library File 299
13.2.3 Adding Library Modules 299
13.2.4 Deleting Library Modules 300
13.2.5 Replacing Library Modules 300
13.2.6 Copying Library Modules 300
13.2.7 Moving Library Modules (Extracting) 300
13.2.8 Combining Libraries 300
13.2.9 Creating a Cross-Reference-Listing File 301
13.2.10 Performing Consistency Checks 301
1 3 . 2 . 11 S e t t i n g t h e L i b r a r y P a g e S i z e 3 0 2
14 Automating Program
Development with MAKE 303
14.1 Using MAKE 305
14.2 Creating a MAKE Description File 306
14.3 Automating Program Development 309
14.4 Running MAKE 3 11
14.5 Specifying MAKE Options 312
14.6 Using Macro Definitions with MAKE 312
1 4 . 6 . 1 D e fi n i n g a n d S p e c i f y i n g M a c r o s 3 1 3
14.6.2 Using Macros within Macro Definitions 315
14.6.3 Using Special Macros 315
1 4 . 7 D e fi n i n g I n f e r e n c e R u l e s 3 1 6
X I
pcjs.org
Contents
Appendixes
A Regular Expressions 333
A.1 Introduction 335
A.2 Special Characters in Regular Expressions 335
A.3 Searching for Special Characters 336
A. 4 Using the Period 336
A.5 Using Brackets 336
A.5.1 Using the Dash within Brackets 337
A.5.2 Using the Caret within Brackets 337
A . 5 . 3 Matching Brackets within Brackets 338
A.6 Using the Asterisk 338
A.7 Matching the Start or End of a Line 339
XII
pcjs.org
B.3.4 MAKE Exit Codes 345
B.3.5 E X E PA C K Exit Codes 345
B.3.6 EXEMOD Exit Codes 345
B.3.7 SETENV Exit Codes 345
B.3.8 ERROUTExit Codes 346
Index 385
Xlll
pcjs.org
Contents
Figures
Figure 1.1 CodeView Start-Up Screen
in Window Mode 22
Figure 2.1 Elements of the
CodeView Debugging Screen 40
Figure 2.2 The File Menu 52
Figure 2.3 The View Menu 54
Figure 2.4 The Search Menu 55
Figure 2.5 The Run Menu 57
Figure 2.6 The Watch Menu 58
Figure 2.7 The Options Menu 60
Figure 2.8 The Language Menu 63
Figure 2.9 The Calls Menu 64
Figure 8.1 Watch Statements in the Watch Window.... 173
Figure 8.2 Watchpoints in the Watch Window 176
Figure 8.3 Tracepoints in the Watch Window 180
Figure 8.4 C Watch Statements 184
Figure 8.5 FORTRAN Watch Statements 185
F i g u r e 8 . 6 P a s c a l Wa t c h S t a t e m e n t s 1 8 6
Figure 8.7 Assembly Watch Statements 188
XIV
pcjs.org
Tables
Table 1.1 Default Exchange and Display Modes 30
Table 4.1 CodeView C-Expression Operators 78
Ta b l e 4 . 2 C R a d i x E x a m p l e s 8 1
Table 4.3 CodeView FORTRAN Operators 82
Ta b l e 4 . 4 F O R T R A N R a d i x E x a m p l e s 8 4
Table 4.5 FORTRAN Intrinsic Functions
Supported by the CodeView Debugger 85
Ta b l e 4 . 6 C o d e V i e w B A S I C O p e r a t o r s 8 6
Ta b l e 4 . 7 B A S I C R a d i x E x a m p l e s 8 9
Table 4.8 BASIC Intrinsic Functions
Supported by the CodeView Debugger 90
Ta b l e 4 . 9 C o d e V i e w P a s c a l O p e r a t o r s 9 1
Table 4.10 Pascal Intrinsic Functions
Supported by the CodeView Debugger 94
Ta b l e 4 . 11 Registers 98
Table 6.1 CodeView Format Specifiers 124
Ta b l e 1 0 . 1 F l a g - V a l u e M n e m o n i c s 2 2 4
X V
pcjs.org
Introduction
Welcome to the Microsoft® CodeView® debugger and development utili
ties. These are executable programs that help you develop software writ
ten with the Microsoft BASIC, C, FORTRAN, and Pascal compilers, as
well as with the Mcrosoft Macro Assembler.
Finally, you can use the SETENV and ERROUT utilities to modify the
DOS environment itself.
pcjs.org
Microsoft CodeView and Utilities
• 386 support
The CodeView debugger now supports debugging of code written
specifically for the 386 processor. You can now decode and assem
ble 386 instructions, as well as view 386 registers.
• Expanded memory support
If you have expanded memory, then you can substantially reduce
the amount of main memory required to debug a program. Many
programs that were previously too large can now be run with the
CodeView debugger.
• 8087 emulator support
If you do not have an 8087 coprocessor in your machine, you can
link to a Microsoft emulator library and take advantage of the 7
command. The debugger will display pseudo-8087 registers, as if
you did have a math coprocessor in your machine.
• Overlayed and library modules
The debugger is now fully compatible with programs that use over
lays. You can also debug library modules.
• New commands
The SYMDEB (symbolic debugger) commands Compare, Fill,
Move, Input, and Output have been added to the CodeView
debugger's repertoire. The Option command provides more power
for redirected input and start-up commands.
pcjs.org
Introduction
Information Location
xix
pcjs.org
Microsoft CodeView and Utilities
Important
There may be additional information about the CodeView debugger in
the README.DOC file. This file will describe changes made to the
program after the manual was printed.
Throughout this manual, the term "DOS" is used to refer to both MS-
DOS® and PC-DOS, except when noting features that are unique to one or
the other.
Notational Conventions
The following notational conventions are used throughout this manual
and apply in particular to syntax displays.
Example Description
of Convention of Convention
X X
pcjs.org
Introduction
PASS = PASS + 1
COUNT = 0
xxi
pcjs.org
Microsoft CodeView and Utilities
\choicel | choice2\ The vertical bar indicates that you may enter
one of the entries shown on either side of the
bar. The following command-line syntax illus
trates the use of a vertical bar:
DB faddress \ range}
The bar indicates that following the Dump
Bytes command (DB), you can specify either an
address or a range. Since both are in double
brackets, you can also give the command with
no argument.
XXII
pcjs.org
PartI
CodeView
Debugger
pcjs.org
S>y
Sr)
^
&
h.
a ': \
&
b
>
s iP)
<$ XT
<>$a
,oO <a
4:p.
.0
(3 ^
&
v &A Af t
0° £
;>\ . 0^
53 ^
s^QC\
: &
»
; >
> ,
V
N°, \ .
ap 0p VIV
^ V*
\> &
j &
..<*» SP
^
v^
jsr
&>
y>
3 * ^
V5^ &
<
o
nX
a
^
<y# v55
57
<fc\s*tf
A $K>«
rto-
JS„ & .
^7 v,r\
V
%
^
^
<$>■
<s
!v<K
$5 j£
iW op.p-0 ^
01
<
:s
vO ^p
"V \J"
c^
\\ pcjs.org
Part 1 explains the use of the CodeView
debugger. Commands, display, and interface of
the debugger are presented here, while other
material relevant to the debugger (such as error
messages and exit codes) is presented in the
Appendixes.
Chapter 1 explains how to create a C, FOR
TRAN, BASIC, Pascal or assembly program that
can be run with the CodeView debugger; it also
explains how to start the debugger and select
various command-line options.
Chapter 2 discusses the CodeView display screen
and interface, including function keys, keyboard
commands, and the mouse.
Chapters 3-11 of Part 1 describe how to use
each of the CodeView commands and expres
sions.
pcjs.org
pcjs.org
I
H I
Chapters 1
GETTING STARTED
1.1 Restrictions 7
1.2 Preparing Programs
for the CodeView Debugger 8
1.2.1 Programming Considerations 8
1.2.2 CodeView Compile Options 9
1.2.3 CodeView Link Options 10
1.2.4 Preparing C Programs 11
1.2.5 Preparing FORTRAN Programs 13
1.2.6 Preparing BASIC Programs 14
1.2.7 Preparing Pascal Programs 15
1.2.8 Preparing Assembly Programs 17
1 . 3 S t a r t i n g t h e C o d e Vi e w D e b u g g e r 2 0
1.4 Using CodeView Options 23
1.4.1 Using Two Video Adapters 25
1.4.2 Using the Enhanced Graphics
Adapter's 43-Line Mode 26
1.4.3 Starting with a Black-and-
White Display 26
1.4.4 Specifying Start-Up Commands 27
1.4.5 Handling Interrupt Trapping 28
1.4.6 Using Expanded Memory 29
1.4.7 Setting the Screen-Exchange Mode 29
1.4.8 Turning Off the Mouse 31
1.4.9 Extending EGA Compatibility 32
1.4.10 Enabling Window or Sequential Mode 33
1.5 Debugging Large Programs 34
1.6 Working with Older Versions
of the Assembler 34
pcjs.org
Getting Started
Getting started with the CodeView debugger requires several simple steps.
First you must prepare a special-format executable file for the program
you wish to debug; then you can invoke the debugger. You may also wish
to specify options that will affect the debugger's operation.
1.1 Restrictions
This list briefly describes kinds of files that are not directly supported by
the debugger. The following restrictions apply generally to the use of the
CodeView debugger, regardless of the language being used.
Restriction Explanation
Include files You will not be able to use the CodeView
debugger to debug source code in include files.
Packed files CodeView symbolic information cannot be put
into a packed file.
.COM files Files with the extension .COM can be debugged
in assembly mode only; they can never contain
symbolic information.
Memory-resident The CodeView debugger can only work with
programs disk-resident .EXE and .COM files. Debugging
of memory-resident files is not supported.
Programs that Programs run under the CodeView debugger can
alter the read the DOS environment, but they cannot per
environment manently change it. Upon exit from CodeView,
all changes to the environment are lost.
Program Segment The CodeView debugger automatically
Prefix (PSP) preprocesses a program's PSP the same way a C
program does; quote marks are removed, and
exactly one space is left between command-line
arguments. This preprocessing only creates a
problem if you are debugging a program not
written in C—one that tries to access
command-line arguments.
pcjs.org
Microsoft CodeView and Utilities
Some of the features that are now allowed by CodeView include debugging
of library modules and debugging of overlayed code. CodeView users can
now freely debug library modules and overlays.
You must compile and link with the correct options, in order to use a pro
gram with the CodeView debugger. These options direct the compiler and
the linker to produce an executable file, which contains line-number infor
mation and a symbol table, in addition to the executable code.
Note
For the sake of brevity, this section and its three subsections use the
term "compiling" to refer to the process of producing object modules.
However, almost everything said about compiling in this section
applies equally well to assembling. Exceptions are noted in Section
1.2.8, "Preparing Assembly Programs."
Not all compiler and linker versions support CodeView options. (Consult
the section on the appropriate language below, for information about com
piler versions. Also, you will need to use the Microsoft Overlay Linker,
Version 3.6 or later.) If you try to debug an executable file that was not
compiled and linked with CodeView options, or if you use a compiler that
does not support these options, then you will only be able to use the
debugger in assembly mode. This means that the CodeView debugger will
not be able to display source code or understand source-level symbols,
such as symbols for functions and variables.
8
pcjs.org
Getting Started
Also, the CodeView debugger will be more effective and easier to use if you
put each source statement on a separate line. A number of languages (C
and BASIC in particular) permit you to place more than one statement on
a single line of the source file. This practice does not prevent the Code
View debugger from functioning. However, the debugger must treat the
line as a single unit; it cannot break the line down into separate state
ments. Therefore, if you have three statements on the same line, you will
not be able to put a breakpoint or freeze execution on the individual state
ments. The best you will be able to do is freeze execution at the beginning
of the three statements, or at the beginning of the next line.
Note
Microsoft compilers will accept command-line options that are pre
ceded by either a forward slash (/) or a dash (-). For brevity, this
manual will list only the forward slash when describing options, but
you may use either symbol.
The use of uppercase or lowercase letters is significant for options used
with the C, FORTRAN, BASIC and Pascal compilers; you must type
the letters exactly as given.
When you compile a source file for a program you want to debug, you
must specify the /Zi option on the command line. The /Zi option
instructs the compiler to include line-number and symbolic information in
the object file. If you are using Microsoft QuickBASIC, this option is
entered as /D.
pcjs.org
Microsoft CodeView and Utilities
Note
The /Zd option is not available with QuickBASIC.
In addition, if you are working with a high-level language, you will prob
ably want to use the /Od option, which turns off optimization. Optimized
code may be rearranged for greater efficiency and, as a result, the instruc
tions in your program may not correspond closely to the source lines. After
debugging, you can compile a final version of the program with the optimi
zation level you prefer.
Note
The /Od option is not available with QuickBASIC or the Macro
Assembler.
You cannot debug a program until you compile it successfully. The Code
View debugger will not help you correct syntax or compiler errors. Once
you successfully compile your program, you can then use the debugger to
locate logical errors in the program.
Compiling examples are given in the sections below on compiling and link
ing with specific languages.
10
pcjs.org
Getting Started
Linking examples are given in the sections below on compiling and linking
with specific languages.
c o d e = b u ff e r [ c o u n t ] ;
if (code == '\n')
++lines;
This makes code easier to read and corresponds with what is generally
considered good programming practice.
11
pcjs.org
Microsoft CodeView and Utilities
You cannot easily debug macros with the CodeView debugger. The
debugger will not break down the macro for you. Therefore, if you have
complex macros with potential side effects, you may need to write them
first as regular source statements.
■ Examples
In the first example, CL is used to compile and link the source file
EXAMPLE.C. CL creates an object file in the CodeView format,
EXAMPLE.OBJ, and then automatically invokes the linker with the
/CO option. The second example demonstrates how to compile and link
the source file EXAMPLE.C by using the MSC program provided with
Version 4.0 of the compiler. Since MSC does not invoke the linker, you
must invoke the linker directly, and specify/CO on the command line.
Both examples result in an executable file, EXAMPLE.EXE, which has
the line-number information, symbol table, and unoptimized code required
by the CodeView debugger.
In the third example, the source module MOD1.C is compiled to produce
an object file with full symbolic and line information, while MOD2.C is
compiled to produce an object file with limited information. Then, CL is
used again to link the resulting object files. (This time, CL does not
recompile, because the arguments have no .C extension.) Typing /Zi on
the command line causes the linker to be invoked with the /CO option.
The result is an executable file in which one of the modules, MOD2.C,
will be harder to debug. However, the executable file will take up substan
tially less space on disk than it would if both modules were compiled with
full symbolic information.
12
pcjs.org
Getting Started
■ Examples
In the first example, FL is used to compile and link the source file
EXAMPLE.FOR. FL creates an object file in the CodeView format,
EXAMPLE.OBJ, and then automatically invokes the linker with the
/CO option. The second example demonstrates how to compile and link
the source file EXAMPLE.FOR by using separate steps for compiling
and linking. In this case, the /CO option must be given explicitly to the
linker. Both examples result in an executable file, EXAMPLE.EXE,
which has the line-number information, symbol table, and unoptimized
code required by the CodeView debugger.
13
pcjs.org
Microsoft CodeView and Utilities
SUM=0
FOR 1=1 TO N
SUM=SUM+ARRAY(I)
NEXT I
14
pcjs.org
Getting Started
■ Example
BC /D EXAMPLE;
LINK /CO EXAMPLE;
The example above compiles the source file EXAMPLE.BAS to produce
an object file, EXAMPLE.OBJ, which contains the symbol and line-
number information required by the CodeView debugger. Then the linker
is invoked with the /CO option to create an executable file that can be
used with the debugger.
Note
If you have a version of Mcrosoft Pascal earlier than Version 4.0, you
can use the CodeView debugger to a limited extent. However, the
debugger will not be able to evaluate program symbols in CodeView
commands. Compile a program as you would normally, and then link
with the /CO option as explained below. You will then be able to use
CodeView to step through your program and set breakpoints. The
debugger will also be able to display machine-level code and do
memory dumps.
15
pcjs.org
Microsoft CodeView and Utilities
if i = max then
begin
k := k+1;
i := 0
end;
Writing only one statement on a line makes code easier to read, and
corresponds with what is generally considered good programming practice.
Linking separately with /CO is necessary when you compile with Mcro
soft Pascal.
■ Example
PA S 1 / Z i T E S T;
PAS 2
LINK /CO TEST;
16
pcjs.org
Getting Started
Important
The CodeView debugger correctly recognizes floating-point values only
when they are in the IEEE (Institute of Electrical and Electronics
Engineers, Inc.) format. You should use the IEEE format with any pro
gram that you are going to run with the CodeView debugger if that
program uses floating-point variables. The IEEE format is the default
for Version 5.0 of the Microsoft Macro Assembler. You can always
specify IEEE format by using the .8087 or .287 directive, or by assem
bling with the /R option.
You will not be able to trace through macros while in source mode. Macros
will be treated as single instructions unless you are in assembly or mixed
mode, so you will not see comments or directives within macros. There
fore, you may want to debug code before putting it into a macro.
The Mcrosoft Macro Assembler also supports include files, but you will
not be able to debug code in an include file. You are better off reserving
include files for macro and structure definitions.
17
pcjs.org
Microsoft CodeView and Utilities
Because the assembler does not have its own expression evaluator, you will
have to use either the C-, FORTRAN-, BASIC-, or Pascal-expression
evaluator. C is the default, because it is the closest to assembly language.
To make sure that the expression evaluator recognizes your symbols and
labels, you should observe the following guidelines when you write assem
bly modules:
• The assembler has no explicit way to declare real numbers. How
ever, it will pass the correct symbolic information for reals and
integers if you initialize each real number with a decimal point and
each integer without a decimal point. (The default type is integer.)
For example, the following statements correctly initialize
REALSUM as a real number and COUNTER as an integer:
REALSUM DD 0.0
COUNTER DD 0
You must initialize real number data in data definitions. If you use
?, then the assembler will consider the variable an integer when it
generates symbolic information. The CodeView debugger, in turn,
will not properly evaluate the value of the variable.
• Avoid the use of special characters in symbol names. The C-,
FORTRAN-, BASIC-, and Pascal-expression evaluators each apply
their own standards in determining what is a legal symbol name.
Generally, only alphanumeric characters and the underscore (_)
are recognized. BASIC accepts certain type-declaration characters
at the end of a name, but C, FORTRAN, and Pascal do not.
• Assemble with /MX or /ML to avoid conflicts due to case when
you do mixed-language programming. By default, the assembler
converts all symbols to uppercase when it generates object code. C,
however, does not do this conversion. Therefore, the CodeView
debugger will not recognize that var in a C program and var in
an assembly program are the same variable, unless you leave Case
Sense off when using the debugger.
a If you access command-line data in the Program Segment Prefix
(PSP), note that the CodeView debugger changes the PSP; tabs,
quote marks, and extra spaces are removed so that exactly one
space separates each argument. The debugger retains quote marks
ialong
j command.
with any quoted material) for command lines given with the
18
pcjs.org
Getting Started
After assembling, link with the /CO option to produce an executable file
in the CodeView format.
■ Examples
The first example assembles the source file EXAMPLE.ASM and pro
duces the object file EXAMPLE.OBJ, which is in the CodeView format.
The linker is then invoked with the /CO option and produces an execut
able file with the symbol table and line-number information required by
the debugger.
The second example produces the object file MODI.OBJ, which contains
symbol and line-number information, and the object file MOD2.0BJ,
which contains line-number information but no symbol table. The object
files are then linked. The result is an executable file in which the second
module will be harder to debug. This executable file, however, will be
smaller than it would be if both modules were assembled with the /ZI
option.
The last example demonstrates how to create a mixed-language executable
file that can be used with the CodeView debugger. The debugger will be
able to trace through different source files in the same session, regardless
of the language.
19
pcjs.org
Microsoft CodeView and Utilities
Before starting the debugger, make sure all the files it requires are avail
able in the proper places. The following files are recommended for source-
level debugging:
File Location
20
pcjs.org
Getting Started
N o t a n e x e c u t a b l e fi l e
You must specify an executable file when you start the CodeView
debugger. If you omit the executable file, the debugger displays a message
showing the correct command-line format.
When you give the debugger a valid command line, the executable pro
gram and the source file are loaded, the address data are processed, and
the CodeView display appears. The initial display will be in window mode
21
pcjs.org
Microsoft CodeView and Utilities
or sequential mode, depending on the options you specify and the type of
computer you have.
For example, if you wanted to debug the program BENCHMRK.EXE,
you could start the debugger with the following command line:
CV BENCHMRK
>
File View Search Run Watch Options Language Calls Help | F8=Trace F5=Go
stats,for
1: c**********************************************************************l
2; C STATS,FOR
3; c
4: C Calculates simple statistics (minimum, maximum, mean, median,
5: C variance, and standard deviation) of up to 50 values,
6; C
7: C Reads one value at a time from unit 5, Echoes values and
8: C writes results to unit 6,
9: C
10: c**********************************************************************
11 : I
12;
13:
14: Dl HEMS I Oil BAT(50)
15: 0PEN(5,FILE:' ')
is:
1 7 : 11 = 0
18: DO 10 1:1,50
22
pcjs.org
Getting Started
If you give the same command line on most non-IBM computers, sequential
mode will be selected. The following lines appear:
You can use CodeView options, as described in Section 1.4, to override the
default start-up mode.
If your program is written in a high-level language, the CodeView
debugger is now at the beginning of the start-up code that precedes your
program. In source mode, you can enter an execution command (such as
Trace or Program Step) to execute automatically through the start-up
code to the beginning of your program. At this point, you are ready to
start debugging your program, as described in Chapters 3-11.
A file whose name begins with a dash must be renamed before you use it
with the CodeView debugger, so that the debugger will not interpret the
dash as an option designator. You can use more than one option in a com
mand line, but each option must have its own option designator, and
spaces must separate each option from other elements of the line.
Note
The CodeView debugger's defaults for IBM Personal Computers are
different from the defaults it has for other computers. However, the
debugger may not always recognize the difference between computers,
and defaults may vary accordingly.
23
pcjs.org
Microsoft CodeView and Utilities
The following list suggests some situations in which you might want to use
an option. If more than one condition applies, you can use more than one
option (in any order). If none of the conditions applies, you need not use
any options.
Condition Option
You want to use two monitors with the /2
CodeView debugger.
You want a 43-line display and you have an /43
IBM or IBM-compatible computer with an
enhanced graphics adapter (EGA) and an
enhanced color display.
You have a two-color monitor, a color / B
graphics adapter, and an IBM or IBM-
compatible computer.
You want the CodeView debugger to /C commands
automatically execute a series of commands
when it starts up.
You are using an IBM-compatible computer
that does not support certain IBM-specific
interrupt trapping functions.
You have expanded memory, and want the /E
CodeView debugger to take advantage of it.
You are using an IBM-compatible computer /F
to debug a program that does not use
graphics or multiple video-display pages, and
you want to be able to see the output screen.
You are using a non-IBM-compatible /I
computer, and you want to enable
CONTROL+C and CONTROL+BREAK.
You have a mouse installed in your system, / M
but you do not want to use it during the
debugging session.
You have a non-IBM EGA and have problems
running the debugger.
24
pcjs.org
Getting Started
■ Option
/2
The /2 option permits the use of two monitors with the CodeView
debugger. The program display will appear on the current default monitor,
while the CodeView display appears on the other monitor. You must have
two monitors and two adapters to use the /2 option. For instance, if you
have both a color graphics adapter and a monochrome adapter, you might
want to set the CGA up as the default adapter. You could then debug a
graphics program with the graphics display appearing on the graphics
monitor and the debugging display appearing on the monochrome moni
tor. Mcrosoft Mouse support will be disabled on the debugging display if
you use this option.
25
pcjs.org
Microsoft CodeView and Utilities
■ Option
/43
If you have an enhanced graphics adapter (EGA) and a monochrome moni
tor or an enhanced color display monitor (or a compatible monitor), you
can use the /43 option to enable a 43-line-by-80-column text mode. You
cannot use this mode with other monitors, such as a CGA or a mono
chrome adapter (MA). The CodeView debugger will ignore the option if it
does not detect an EGA.
The EGA's 43-line mode performs the same as the normal 25-line-by-80-
column mode used by default on the EGA, CGA, and MA. The advantage
of the 43-line mode is that more text fits on the CodeView display; the
disadvantage is that the text is smaller and harder to read. If you have an
EGA, you can experiment to see which size you prefer.
■ Example
The example above starts the CodeView debugger in 43-line mode if you
have an EGA video adapter and an enhanced color or monochrome moni
tor. The option will be ignored if you lack the hardware to support it.
■ Option
/B
The /B option forces the CodeView debugger to display in two colors even
if you have a color adapter (CGA, EGA, or compatible). By default, the
debugger checks on start-up to see what kind of display adapter is
attached to your computer. If the debugger detects an MA, it displays in
two colors. If it detects a color adapter, it displays in multiple colors.
If you use a two-color monitor with a CGA or EGA, you may want to dis
able color. Monitors that display in only two colors (usually green and
black, or amber and black) often attempt to show colors with different
cross-hatching patterns, or in gray-scale shades of the display color. In
26
pcjs.org
Getting Started
either case, you may find the display easier to read if you use the /B
option to force black-and-white display. Most two-color monitors still have
four color distinctions: background (black), normal text, high-intensity
text, and reverse-video text.
■ Example
CV /B CALC CALC.DAT
■ Option
/Ccommands
The /C option allows you to specify one or more commands that will be
executed automatically upon start-up. You can use these options to invoke
the debugger from a batch or MAKE file. Each command is separated
from the previous command by a semicolon.
Warning
Any start-up option that uses the less-than (<) or greater-than (>)
symbol must be enclosed in double quotation marks even if it does not
require spaces. This ensures that the redirection command will be
interpreted by the CodeView debugger rather than by DOS.
■ Examples
The example above loads the CodeView debugger with CALC as the exe
cutable file and CALC.DAT as the argument.
27
pcjs.org
Microsoft CodeView and Utilities
The example above loads the same file with the same argument as the first
example, but the command list is more extensive. The debugger starts in
mixed source/assembly mode (S&). It executes to the routine INTEGRAL
(G INTEGRAL), and then dumps 20 short real numbers, starting at the
address of the variable ARRAYX (DS ARRAYX L 20). Since several of the
commands use spaces, the entire option is enclosed in double quotation
marks.
The example above loads the same file and argument as the first example,
but the start-up command directs the debugger to accept input from the
file INPUT.FIL rather than from the keyboard. Although the option does
not include any spaces, it must be enclosed in double quotation marks so
that the less-than symbol will be read by the CodeView debugger rather
than by DOS.
■ Options
/D
/I
The /D option turns off nonmaskable interrupt (NM) trapping and 8259
interrupt trapping. If you are using an IBM PC Convertible, Tandy® 1000,
or the AT&T® 6300 Plus and you are experiencing system crashes while
using the CodeView debugger, try starting with the /D option. To enable
window mode, use /W with /D; otherwise sequential mode is set automat
ically. Note that because this option turns off interrupt trapping,
CONTROL+C and CONTROL+BREAK will not work, and an external interrupt
may occur during a trace operation. If this happens you may find yourself
tracing the interrupt handler instead of your program.
The /I option forces the debugger to handle NM and 8259 interrupt trap
ping. Use this option to enable CONTROL+C and CONTROL+BREAK on com
puters not recognized as being IBM compatible by the debugger, comput
ers such as the Eagle® PC. Window mode is set automatically with the /I
28
pcjs.org
Getting Started
option; you don t have to specify /W. Using the /I option lets you stop
program execution at any point while you are using the CodeView
debugger.
■ Option
/E
"Expanded memory" refers to memory made accessible according to the
Mcrosoft/Lotus®/Intel® EMS specification. This access provides your
system with memory above the 640k MS-DOS limitation on RAM. How
ever, since MS-DOS will not recognize this additional memory, programs
can make use of expanded memory in limited ways.
The /E option enables the use of expanded memory. If expanded memory
is present, the CodeView debugger will use it to store the symbolic infor
mation of the program. This may be as much as 85% of the size of the exe
cutable file for the program, and represents space that would otherwise be
taken up in main memory.
Note
This option enables only expanded memory, not extended memory.
Extended memory makes use of protected-mode instructions, rather
than the Mcrosoft/Lotus/Intel specification for memory paging.
■ Options
/F
/S
The CodeView debugger allows you to move quickly back and forth
between the output screen, which contains the output from your program,
and the debugging screen, which contains the debugging display. The
debugger can handle this screen exchange in two ways: screen flipping or
screen swapping. The /F option (screen flipping) and the /S option
(screen swapping) allow you to choose the method from the command line
29
pcjs.org
Microsoft CodeView and Utilities
When you use screen swapping, the buffer size is 16K for all adapters. The
amount of memory used by the CodeView debugger is increased by the size
of the buffer.
Table 1.1 shows the default exchange mode (swapping or flipping) and the
default display mode (sequential or window) for various configurations.
Display modes are discussed in Section 1.4.10, "Enabling Window or
Sequential Mode."
Table 1.1
Default Exchange and Display Modes
Display Default
Computer Adapter Modes Alternate Modes
30
pcjs.org
Getting Started
If you are not sure if your computer is completely IBM compatible you
can experiment If the basic input/output system (BIOS) of your computer
is not compatible enough, the CodeView debugger may not work with the
/F option.
If you specify the /F option with an MA, the debugger will ignore the
option and use screen swapping. If you try to use screen flipping to debug
a program that produces graphics or uses the video-display pages you
may get unexpected results and have to start over with the /S option.
■ Examples
CV /F CALC CALC.DAT
The example above starts the CodeView debugger with screen flipping
You might use this command line if you have an IBM-compatible com
puter, and you want to override the default screen-exchange mode in order
to use less memory and switch screens more quickly. The option would not
be necessary on an IBM computer, since screen flipping is the default.
■ Example
CV /S GRAFIX
The example above starts the debugger with screen swapping. You might
use this command line if your program uses graphics mode.
■ Option
/M
If you have a mouse installed on your system, you can tell the CodeView
debugger to ignore it, using the /M option. You may need to use this
option if you are debugging a program that uses the mouse and your
mouse is not a Mcrosoft Mouse. This is due to a conflict between the
program's use of the mouse and the debugger's use of it. Use of /M may
possibly disable the program's use of the mouse, as well as CodeView's.
31
pcjs.org
Microsoft CodeView and Utilities
Important
The same conflict between program and debugger applies if you are
not using the current Mcrosoft Mouse driver program
(MOUSE.SYS), which is included on the distribution disks for certain
Mcrosoft products. You may want to replace your old mouse driver
program with the updated version. You will then be able to use the
mouse with both the CodeView debugger and the program you are
debugging. If you did not install a mouse driver when you set up Ver
sion 4.0 of Mcrosoft FORTRAN, Version 5.0 of Mcrosoft C, or Ver
sion 5.0 of Macro Assembler, see your User's Guide for information on
installing MOUSE.SYS. These programs may not work with pointing
devices from other manufacturers.
■ Option
/P
The use of the /P option may enable the CodeView debugger to run prop
erly in window mode on a non-IBM version of the enhanced graphics
adapter (EGA).
Normally, the debugger will save and restore the palette registers of an
enhanced graphics adapter. However, although this procedure works per
fectly well with an IBM EGA, it can create conflicts with other EGAs. The
/P option prevents the saving and restoring of palette registers, and so
may enhance compatibility.
Symptoms that may indicate the need for using /P include the debugging
screen starting in nonstandard colors, and the debugger appearing to
crash in window mode.
Note
The /P option may cause the program being debugged to lose some
colors, whenever you switch back and forth between the debugging
screen and the output screen. Therefore, do not use the /P option
unless necessary.
32
pcjs.org
Getting Started
■ Options
/T
/W
Th j G°w VieW debu§Ser can operate in window mode or in sequential
mode. Window mode displays up to four windows, enabling you to see
different aspects of the debugging-session program simultaneously. You
can also use a mouse in window mode. Window mode requires an IBM or
IBM-compatible microcomputer.
Sequential mode works with any computer and is useful with redirection
commands. Debugging information is displayed sequentially on the screen.
Note
Although window mode is more convenient, any debugging operation
that can be done in window mode can also be done in sequential mode.
■ Examples
CV /W SIEVE
The example above starts the CodeView debugger in window mode You
will probably want to use the /W option if you have an IBM-compatible
computer, since the default sequential mode is less convenient for most
debugging tasks.
CV /T SIEVE
The example above starts the debugger in sequential mode. You might
want to use this option if you have an IBM computer, and you have a
specific reason for using sequential mode. For instance, sequential mode
usually works better if you are redirecting your debugging output to a
remote terminal. r
33
pcjs.org
Microsoft CodeView and Utilities
Because the CodeView debugger must reside in memory along with the
program you are debugging, there may not be enough room to debug some
large programs that could otherwise run in memory alone. However, there
are at least three ways to get around memory limitations:
You can run the CodeView debugger with files developed using older ver
sions of the Mcrosoft or IBM assemblers (prior to 5.0). Since older versions
do not write line numbers to object files, some of the CodeView debugger's
features will not be available when you debug programs developed with
the older assemblers. The following considerations apply, in addition to
the considerations mentioned in Section 1.2.8, "Preparing Assembly Pro
grams."
The procedure for assembling and debugging .EXE files by using older
versions of the assembler is summarized below. The debugger can be used
on either .EXE or .COM files, but you can only view symbolic informa
tion in .EXE files.
1. In your source file, declare public any symbols, such as labels and
variables, that you want to reference in the debugger. If the file is
small, you may want to declare all symbols public.
2. As mentioned earlier, make sure that the code segment has class
name CODE.
34
pcjs.org
Getting Started
35
pcjs.org
Chapter/ 2
THE CQDEVIEW DISPLAY
2.1 Using Window Mode 39
2.1.1 Executing Window
Commands with the Keyboard 41
2.1.1.1 Moving the Cursor
with Keyboard Commands 41
2.1.1.2 Changing the Screen
with Keyboard Commands 43
2.1.1.3 Controlling Program Execution
with Keyboard Commands 44
2.1.1.4 Selecting from Menus
with the Keyboard 45
2.1.2 Executing Window Commands
with the Mouse 47
2.1.2.1 Changing the Screen
with the Mouse 47
2.1.2.2 Controlling Program
Execution with the Mouse 48
2.1.2.3 Selecting from Menus
with the Mouse 50
2.1.3 Using Menu Selections 52
2.1.3.1 The File Menu 52
2.1.3.2 The View Menu 54
2.1.3.3 The Search Menu 55
2.1.3.4 The Run Menu 57
2.1.3.5 The Watch Menu 58
2.1.3.6 The Options Menu 60
2.1.3.7 The Language Menu 62
2.1.3.8 The Calls Menu 63
2.1.3.9 The Help Menu 65
2.1.4 Using the Help System 65
2.2 Using Sequential Mode 66
pcjs.org
The CodeView Display
You will probably want to use window mode, if you have the hardware to
support it. In window mode, the pull-down menus, function keys, and
mouse support offer fast access to the most common commands. Different
aspects of the program and debugging environment can be seen in different
windows simultaneously. Window mode is described in Section 2.1.
The elements of the CodeView display marked in Figure 2.1 below include
the following:
39
pcjs.org
Microsoft CodeView and Utilities
40
pcjs.org
The CodeView Display
41
pcjs.org
Microsoft CodeView and Utilities
Key Function
42
pcjs.org
The CodeView Display
Key Function
43
pcjs.org
Microsoft CodeView and Utilities
The following keys set and clear breakpoints, trace through your program,
or execute to a breakpoint.
Key Function
44
pcjs.org
The CodeView Display
Important
You can usually interrupt program execution by pressing either
CONTROL+BREAK or CONTROL+C. These key combinations can be used
to exit endless loops or to interrupt loops that are slowed by the
Watchpoint or Tracepoint commands (see Chapter 8, "Managing
Watch Statements"). CONTROL+BREAK or CONTROL+C may not work
if your program has a special use for one or both of these key combina
tions. If you have an IBM Personal Computer AT (or an AT-
compatible), you can use the SYSTEM-REQUEST key to interrupt execu
tion regardless of your program's use of CONTROL+BREAK and
CONTROL+C.
This section discusses how to make selections from menus with the key
board. The effects of the selections are discussed in Section 2.1.3, "Using
Menu Selections."
The menu bar at the top of the screen has eleven titles: File, View, Search,
Run, Watch, Options, Language, Calls, Help, Trace, and Go. The first nine
titles are menus, and the last two are commands. The Trace and Go titles
are provided primarily for mouse users.
The four steps for opening a menu and making a selection are described
below.
1. To open a menu, press the ALT key and the mnemonic (the first
letter) of the menu title. This can be accomplished either by press
ing the ALT key first, releasing the key, and pressing the letter; or
you can hold down the ALT key and then press the letter. For
example, press ALT+S to open the Search menu. The menu title is
highlighted, and a menu box listing the selections pops up below
the title.
45
pcjs.org
Microsoft CodeView and Utilities
At any point during the process of selecting a menu item, you can press
the ESCAPE key to cancel the menu. While a menu is open, you can press
the LEFT ARROW or RIGHT ARROW key to move from one menu to an adja
cent menu, or to one of the command titles on the menu bar.
46
pcjs.org
The CodeView Display
T e r m D e fi n i t i o n
Point Move the mouse until the mouse pointer rests on the item
you want to select.
Click Quickly press and release a mouse button while pointing
at an item you want to select.
Drag Press a mouse button while on a selected item, then hold
the button down while moving the mouse. The item moves
in the direction of the mouse movement. When the item
you are moving is where you want it, release the button;
the item will stay at that place.
The CodeView debugger uses two mouse buttons. The terms "click right,"
"click left," "click both," and "click either" are sometimes used to desig
nate which buttons to use. When dragging, either button can be used.
You can change various aspects of the screen display by pointing to one of
the following elements and then either clicking or dragging.
Item Action
47
pcjs.org
Microsoft CodeView and Utilities
By clicking the following mouse items, you can set and clear breakpoints,
trace through your program, execute to a breakpoint, or change flag bits.
Item Action
48
pcjs.org
The CodeView Display
Button Result
Button Result
49
pcjs.org
Microsoft CodeView and Utilities
Important
You can usually interrupt program execution by pressing either
CONTROL+BREAK or CONTROL+C. See the note in Section 2.1.1.3,
"Controlling Program Execution with Keyboard Commands," for
more information.
This section discusses how to make selections from menus with the mouse.
The effect of each selection is discussed in Section 2.1.3, "Using Menu
Selections."
The menu bar at the top of the screen has nine titles: File, View, Search,
Run, Watch, Options, Language, Calls, Help, Trace, and Go. The first
nine titles are menus, and the last two are commands that you can execute
by clicking with the mouse. The five steps for opening a menu and making
50
pcjs.org
The CodeView Display
1. To open a menu, point to the title of the menu you want to select.
For example, move the pointer onto File on the menu bar if you
want to open the File menu.
2. With the mouse pointer on the title, press and hold down either
mouse button. The selected title is highlighted and a menu box
with a list of selections pops up below the title. For example, if you
point to Search and press a button, the Search menu pops up.
3. With the button held down, move the mouse toward you. The
highlight follows the mouse movement. You can move the highlight
up or down in the menu box. For example, to select Find from the
Search menu, move the highlight down the menu to Find.
If you move off the box, the highlight will disappear. However, as
long as you do not release the button, you can move the pointer
back onto the menu to make the highlight reappear.
4. When the selection you want is highlighted, release the mouse but
ton. For example, release the button with the highlight on Find.
When you release the button, the menu selection is executed. One
of three things will happen:
a. For most menu selections, the choice is executed immediately.
b. The items on the View, Options, and Language menus have
small double arrows next to them if the option is on, or no
arrows if the option is off. Choosing the item toggles the
option. The status of the arrows on a chosen item will appear
reversed the next time you open the menu.
c. Some items require a response. In this case, there is another
step in the menu-selection process.
5. If the item you select requires a response, a dialog box with a
prompt appears. Type your response and press the ENTER key or a
mouse button. For example, if you selected Find, the prompt will
ask you to enter a regular expression (see Section 2.1.3.3, "The
Search Menu," or Appendix A, "Regular Expressions," for an
explanation of regular expressions).
If your response is valid, the command will be executed. If you
enter an invalid response in the dialog box, a message box will
appear telling you the problem and asking you to press a key.
Press any key or click a mouse button to make the message box
disappear.
Also, if you press ENTER without entering any characters, the mes
sage box will disappear.
51
pcjs.org
Microsoft CodeView and Utilities
There are several shortcuts you can take when selecting menu items with
the mouse. If you change your mind and decide not to select an item from
a menu, just move off the menu and release the mouse button—the menu
will disappear. You can move from one menu to another by dragging the
pointer directly from any point on the current menu to the title of the
new menu.
y ^
>
IfflE View Search Run Watch Options Language Calls Help F8=Trace F5=Gc
1 cuue.i. |
Open,,,
Dos Shell
Exit
i
59!
ft
Selection Action
52
pcjs.org
The CodeView Display
you can reopen the original file. The last location and
breakpoints will still be marked when you return.
You may not need to open a new file to see source
files for a different module of your program. The
CodeView debugger automatically switches to the
source file of a module when program execution
enters that module. Although switching source files is
never necessary, it may be desirable if you want to
set breakpoints or execute to a line in a module not
currently being executed.
Note
If the debugger cannot find the source file when it
switches modules, a dialog box appears asking for
a file specification for the source file. You can
either enter a new file specification if the file is in
another directory, or press the ENTER key if no
source file exists. If you press the ENTER key, the
module can only be debugged in assembly mode.
DOS Shell Exits to a DOS shell. This brings up the DOS screen,
where you can execute DOS commands or executable
files. To return to the CodeView debugger, type
exit at the DOS command prompt. The CodeView
screen reappears with the same status it had when
you left it.
The Shell Escape command works by saving the
current processes in memory and then executing a
second copy of COMMAND.COM. This requires
more than 200K of free memory, since the debugger,
COMMAND.COM, symbol tables, and the
debugged program must all be saved in memory. If
you do not have enough memory to execute the Shell
Escape command, an error message appears. Even if
you have enough memory to execute the command,
you may not have enough memory left to execute
large programs from the shell.
The Shell Escape command does not work under cer
tain conditions. See Section 11.7 for additional infor
mation.
53
pcjs.org
Microsoft CodeView and Utilities
The View menu includes selections for switching between source and as
sembly modes, and for switching between the debugging screen and the
output screen. The corresponding function keys for menu selection are
shown on the right side of the menu where appropriate. The View menu is
shown in Figure 2.3, and the selections are explained below.
Note
The terms "source mode" and "assembly mode" apply to Mcrosoft
Macro Assembler programs as well as to high-level-language programs.
Source mode used with assembler programs shows the source code as
originally written, including comments and directives. Assembly mode
displays unassembled machine code, without symbolic information.
The use of one mode or another affects Trace and Program Step com
mands, as explained in Chapter 5, "Executing Code."
At all times exactly one of the following selections will have a small double
arrow to the left of the name: Source, Mixed, and Assembly. This arrow
indicates which of the three display modes is in use. If you select a mode
when you are already in that mode, the selection will be ignored. The
Registers selection may or may not have a double arrow to the left,
depending on whether or not the register window is being displayed.
54
pcjs.org
The CodeView Display
Selection Action
The Search menu includes selections for searching through text files for
text strings and for searching executable code for labels. The Search menu
is shown in Figure 2.4, and the selections are explained below.
Selection Action
Find... Searches the current source file or other text file for a
specified regular expression. (This selection can also
be made without pulling down a menu, simply by
pressing CONTROL+F.)
55
pcjs.org
Microsoft CodeView and Utilities
56
pcjs.org
The CodeView Display
File View Search \M\ Watch Options Language Calls Help | F8=Trace F5=Go
1
55 Start
56 Restart
57 Execute
58 Clear Breakpoints
59
@
6
61 1
Figure 2.5 The Run Menu
Selection Action
Start Starts the program from the beginning and runs it.
Any previously set breakpoints or watch statements
will still be in effect. The CodeView debugger will run
your program from the beginning to the first break
point, or to the end of the program if no breakpoint
is encountered. This has the same effect as selecting
Restart (see the next selection), then entering the Go
command.
57
pcjs.org
Microsoft CodeView and Utilities
Note
Although "Start" and "Restart" retain breakpoints, along with pass
count and arguments (see Chapter 5, "Executing Code"), any instruc
tions entered with the Assemble command will be overwritten by the
original program.
f File View Search Run Options Language Calls Help | FS=Trace F5=Go
55: ftdd Uatch,,, CtrlH
56: Watchpoint,,,
57: Tracepoint,,,
58: Delete Uatch,,, Ctrl+L
59; Delete fill Uatch
68:
61;
62:
58
pcjs.org
The CodeView Display
Selection Action
59
pcjs.org
Microsoft CodeView and Utilities
The Options menu allows you to set options that affect various aspects of
the behavior of the CodeView debugger. The Options menu is shown in
Figure 2.7, and the selections are explained below.
A
File View Search Run Watch Language Calls Help | F8=Trace F5=Go
I
55: » Flip/Swap
56; » Bytes Coded
■Ji, » Case Sense
58: 386
59;
60:
61:
60
pcjs.org
The CodeView Display
Selections on the Options menu have small double arrows to the left of the
selection name when the option is on. The status of the option (and the
presence of the double arrows) is reversed each time you select the option.
By default, the Flip/Swap and Bytes Coded options are on, and the 386
option is off, when you start the CodeView debugger. Depending on which
language your main program is in, the debugger will automatically turn
Case Sense on (if your program is in C) or off (if your program is in
another language) when you start debugging.
Selection Action
Warning
Any time your program writes to the screen,
make sure that flipping or swapping is on. If
swapping and flipping are off, your program will
write the output at the location of the cursor.
The CodeView debugger will detect that the
screen has changed and will redraw the screen,
thus destroying the program output. An error
message is also displayed: Flip/Swap option
off — application output lost.
61
pcjs.org
Microsoft CodeView and Utilities
386 When on, the register window will display the regis
ters in the wider, 386 format. Furthermore, this
option will enable you to assemble and execute
instructions that reference 32-bit registers. If the 386
option is not on, then any data stored in the high-
order word of a 32-bit register will be lost.
To use this option, you should have a 386 processor
running in 386 mode. If you do not have a 386 pro
cessor, then the debugger will respond with the mes
sage, CPU is not an 80386, and leave the option
turned off.
The Language menu allows you either to select the expression evaluator,
or to instruct the CodeView debugger to select it for you automatically.
62
pcjs.org
The CodeView Display
The Language menu is shown in Figure 2.8, and the selections are
explained below.
File Diem Search Run Watch Option mm Calls Help | F8=Trace F5=Go
I dice.C (=
5 »Auto
56 Basic
57 C
53 Fortran
59 Pascal
69
6
1
6
2
The Calls menu is different from other menus in that its contents and size
change, depending on the status of your program. The Calls menu is
shown in Figure 2.9.
63
pcjs.org
Microsoft CodeView and Utilities
File View Search Run Hatch Options Language |HII| Help 1 F8=Trace F5=Go
1 diceA F
68: doub le roll(n) 4 roll(4)
69: int ni 3 make(4)
70: { 2 calc(27865:4492,27865:4484)
71! double odds; 1 mainO
72: int ways;
73:
75^ ways : n - lj_
The mnemonic for each item in the Calls menu is a number. Type the
number displayed immediately to the left of a routine in order to select it.
You can also use the UP ARROW or DOWN ARROW key to move to your selec
tion, and then press the ENTER key. You can use the mouse to select from
the Calls menu as well.
The effect of making a selection from the Calls menu is to view a routine.
The cursor will go to the line at which the selected routine was last execut
ing. For example, selecting main in the example above will cause Code
View to display main, at the point at which main made a call to calc
(the function immediately above it). Note that selecting a routine from the
Calls menu does not (by itself) affect program execution. It simply pro
vides a convenient way to view previously called routines.
It is not required that one of the routines be selected. The Calls menu is
useful simply for viewing the list of previously called routines.
The Calls menu shows the current routine and the trail of routines from
which it was called. The current routine is always at the top. The routine
from which the current routine was called is directly below. Other active
routines are shown in the reverse order in which they were called. With C
and FORTRAN programs, the bottom routine should always be main.
(The only time when main will not be the bottom routine is when you are
tracing through the standard library's start-up or termination routines.)
The current value of each argument, if any, is shown in parentheses fol
lowing the routine. The menu expands to accommodate the arguments of
the widest routine. Arguments are shown in the current radix (the default
is decimal). If there are more active routines than will fit on the screen, or
if the routine arguments are too wide, the display will expand to both the
left and right. The Stack Trace dialog command (K) also shows all the
routines and arguments.
64
pcjs.org
The CodeView Display
Note
If you are using the CodeView debugger to debug assembly-language
programs, routines will be shown in the Calls menu only if they use one
of the Mcrosoft calling conventions. These calling conventions are
explained in the Microsoft Mixed-Language Programming Guide.
The Help menu lists the major topics in the help system. For help, open
the Help menu and then select the topic you want to view.
Each topic may have any number of subtopics. You must go to the major
topic first. Information on how to move around within the help system is
provided in the next section.
The bottom selection on the Help menu is the About command. When you
make this selection, the debugger will display a small box at the center of
the screen that gives the time, the name of the product, and the version
number.
The help file is called CV.HLP. It must be present in the current direc
tory or in one of the directories specified with the DOS PATH command.
If the help file is not found, the CodeView debugger will still operate, but
you will not be able to use the help system. An error message will appear if
you try to use a help command.
When you request help, either by pressing the Fi key, by using the H dia
log command, or by selecting the Help menu, the first help screen appears.
You can select Next and Previous buttons to page through the screens.
The screens are arranged in a circular fashion, so that selecting Next on
the last screen get you to the first screen. Select the Cancel button to
return to the CodeView screen.
65
pcjs.org
Microsoft CodeView and Utilities
Pressing the PGDN, PGUP, and ESC keys achieves the same results as select
ing Next, Previous, and Cancel, respectively, with the mouse.
You can enter the help system at a particular topic by selecting the topic
from the Help menu. Once into the system, use Next and Previous to page
to other screens.
F l D i s p l a y s a c o m m a n d - s y n t a x s u m m a r y.
F2 Displays the registers.
This is equivalent to the Register (R) dialog command.
66
pcjs.org
The CodeView Display
67
pcjs.org
Chapter/ 3
ITSING DIALOG COMMANDS
3.1 Entering Commands and Arguments 71
3.1.1 Using Special Keys 71
3.1.2 Using the Command Buffer 72
3.2 Format for CodeView
Commands and Arguments 73
pcjs.org
Using Dialog Commands
Dialog commands are entered at the CodeView prompt (>). Type the com
mand and arguments, and then press the ENTER key.
In window mode, you can enter commands whether or not the cursor is at
the CodeView prompt. If the cursor is in the display window, the text you
type will appear after the prompt in the dialog window, even though the
cursor remains in the display window.
Key Action
CONTROL+C Stops the current output or cancels the current
command line. For example, if you are watching a
long display from a Dump command, you can press
CONTROL+C to interrupt the output and return to
the CodeView prompt. If you make a mistake
while entering a command, you can press
CONTROL+C to cancel the command without exe
cuting it. A new prompt appears, and you can
reenter the command.
CONTROL+S Pauses during output of a command. You can
press any key to continue output. For example, if
71
pcjs.org
Microsoft CodeView and Utilities
When the cursor is in the dialog window, you can scroll up or down to
view the commands you have entered earlier in the session. The com
mands for moving the cursor and scrolling through the buffer are
explained in sections 2.1.1.1 and 2.1.2.1.
Scrolling through the buffer is particularly useful for viewing the output
from commands, such as Dump or Examine Symbols, whose output may
scroll off the top of the dialog window.
If you have scrolled through the dialog buffer to look at previous com
mands and output, you can still enter new commands. When you type a
command, it will appear to be overwriting the previous line where the cur
sor is located, but when you press the ENTER key, the new command will
be entered at the end of the buffer. For example, if you enter a command
while the cursor is at the start of the buffer and then scroll to the end of
the buffer, you will see the command you just entered. If you scroll back
to the point where you entered the command, you will see the original
characters rather than the characters you typed over the originals.
When you start the debugger, the buffer is empty except for the copyright
message. As you enter commands during the session, the buffer is gradu
ally filled from the bottom to the top. If you have not filled the entire
buffer and you press the HOME key to go to the top of the buffer, you will
not see the first commands of the session. Instead you will see blank lines,
since there is nothing at the top of the buffer.
72
pcjs.org
Using Dialog Commands
■ Examples
73
pcjs.org
Microsoft CodeView and Utilities
74
pcjs.org
Chapter/ 4
CODE VIEW RXPRESSIONS
4.1 C Expressions 78
4.1.1 C Symbols 79
4.1.2 C Constants 80
4.1.3 C Strings 81
4.2 FORTRAN Expressions 81
4.2.1 FORTRAN Symbols 83
4.2.2 FORTRAN Constants 83
4.2.3 FORTRAN Strings 84
4.2.4 FORTRAN Intrinsic Functions 85
4.3 BASIC Expressions 86
4.3.1 BASIC Symbols 88
4.3.2 BASIC Constants 88
4.3.3 BASIC Strings 89
4.3.4 BASIC Intrinsic Functions 89
4.4 Pascal Expressions 91
4.4.1 Pascal Symbols 92
4.4.2 Pascal Constants 93
4.4.3 Pascal Strings 93
4.4.4 Pascal Intrinsic Functions 93
4.5 Assembly Expressions 95
4.6 Line Numbers 97
4.7 Registers and Addresses 97
4.7.1 Registers 98
4.7.2 Addresses 99
4.7.3 Address Ranges 100
pcjs.org
Chapter
76
pcjs.org
CodeView Expressions
Each of the four expression evaluators has a different set of operators and
rules of precedence. However, the basic syntax for registers, addresses, and
line numbers is the same regardless of the language. You can always
change the expression evaluator. If you specify a language other than the
one used in the source file, then the expression evaluator will still recog
nize your program symbols, if possible. (C and FORTRAN, however, will
not accept BASIC type tags.) If you are debugging an assembly routine
called from BASIC or FORTRAN, then you may want to choose the
language of the main program, rather than C, which is default for assem
bly programs.
If the Auto option is on, then the debugger examines the file extension of
each new source file you trace through. Both C and assembly modules
cause the debugger to select C as the expression evaluator.
This chapter deals first with the expressions specific to each language.
Line-number expressions are presented next; they work the same way
regardless of the language. Then, register and address expressions are
presented; generally, these do not have to be mastered unless you are
doing assembly-level debugging. Finally, the chapter describes how to
switch the expression evaluator.
Note
When you use a variable in an expression where that variable is not
defined, the CodeView debugger displays the message UNKNOWN SYM
BOL. For example, the message appears if you reference a local vari
able outside the function where the variable is defined.
77
pcjs.org
Microsoft CodeView and Utilities
4.1 C Expressions
Table 4.1
CodeView C-Expression Operators
Precedence Operators
(Highest)
1 0 [] -> •
2 ! " -a (type) ++ -- *b &c sizeof
3 *b / % :
4 + -a
5 < > < = > =
6 = = !=
7 &&
8 I
9 = += -= - /= %=
10 BY WO DW
(Lowest)
The minus sign with precedence 2 is the unary minus indicating the sign of a
number; the minus sign with precedence 4 is a binary minus indicating
subtraction.
The asterisk with precedence 2 is the pointer operator; the asterisk with
precedence 3 is the multiplication operator.
c The ampersand with precedence 2 is the address-of operator. The amper
sand as a bitwise AND operator is not supported by the CodeView
debugger.
78
pcjs.org
CodeView Expressions
With the C-expression evaluator, the period (.) has its normal use as a
member selection operator, but it also has an extended use as a specifier of
local variables in parent functions. The syntax is shown below:
function.variable
The function must be a high-level-language function, and the variable must
be a local variable within the specified function. The variable cannot be a
register variable. For example, you can use the expression main, argc to
refer to the local variable argc when you are in a function that has been
called by main.
The type operator (used in type casting) can be any of the predefined C
types. The CodeView debugger limits casts of pointer types to one level of
indirection. For example, (char *) sym is accepted, but (char
**) sym is not.
When a C expression is used as an argument with a command that takes
multiple arguments, the expression should not have any internal spaces.
For example, count+6 is allowed, but count + 6 may be interpreted
as three separate arguments. Some commands (such as the Display
Expression command) do permit spaces in expressions.
4.1.1 C Symbols
■ Syntax
name
A symbol is a name that represents a register, a segment address, an offset
address, or a full 32-bit address. At the C source level, a symbol is a vari
able name or the name of a function. Symbols (also called identifiers) fol
low the naming rules of the C compiler. Note that although CodeView
command letters are not case sensitive, symbols given as arguments are
case sensitive (unless you have turned off case sensitivity with the Case
Sense selection from the Options menu).
79
pcjs.org
Microsoft CodeView and Utilities
format. You do not need to include the underscore when specifying such a
symbol in CodeView commands. Labels within library routines are some
times displayed with a double underscore ( chkstk). You must use two
leading underscores when accessing these labels with CodeView com
mands.
4.1.2 C Constants
■ Syntax
The default radix for the C expression evaluator is decimal. However, you
can use the Radix command (N) to specify an octal or hexadecimal radix,
as explained in Section 11.3, "Radix Command."
80
pcjs.org
CodeView Expressions
Table 4.2
C Radix Examples
4.1.3 C Strings
■ Syntax
"null-terminated-string"
■ Example
The example uses the Enter ASCII command (EA) to enter the given
string into memory starting at the address of the variable message.
81
pcjs.org
Microsoft CodeView and Utilities
Table 4.3
CodeView FORTRAN Operators
Precedence Operator
(Highest)
1 0
2
3 Unary + —
4 * /
5 Binary + —
6 XT. .LE. .EQ. .NE. . G T. .GE.
7 . N O T.
8 •AND.
9 .OR.
10 .EQV. .NEQV.
11
(Lowest)
In the CodeView debugger, the period (.) has an extended use as a specifier
of local variables in parent routines. The syntax is shown below:
routine.variable
82
pcjs.org
CodeView Expressions
■ Syntax
name
A symbol is a name that represents a register, a segment address, an offset
address, or a full 32-bit address. At the FORTRAN source level, a symbol
is simply a variable name or the name of a routine; you do not necessarily
need to know what kind of address it represents. Note that when given as
arguments, symbols are never case sensitive with the FORTRAN-
expression evaluator. If you have turned on case sensitivity with the Case
Sense selection from the Options menu, it is turned off automatically when
a symbol is used.
■ Syntax
83
pcjs.org
Microsoft CodeView and Utilities
For example, if you enter ABC as an argument when the program contains
a variable or function named ABC, the CodeView debugger interprets the
argument as the symbol. If you want to enter ABC as a number, enter it
as #ABC.
Table 4.4 shows how a sample number (63 decimal) would be represented
in the octal, decimal, and hexadecimal radixes.
Table 4.4
F O RT R A N R a d i x E x a m p l e s
8 77 10#63 #3F
10 8#77 63 #3F
16 8#77 10#63 3F
■ Syntax
'string1
■ Example
84
pcjs.org
CodeView Expressions
Table 4.5
F O RT R A N I n t r i n s i c F u n c t i o n s
Supported by the CodeView Debugger
Argument Function
Name Definition Ty p e Ty p e
85
pcjs.org
Microsoft CodeView and Utilities
Table 4.6
CodeView BASIC Operators
Precedence Operator
(Highest)
1 0
2
3 * /
4 \ MOD
5 + -
6 = <> < > <= >=
7 NOT
8 AND
9 OR
10 XOR
11 EQV
12 IMP
13 L E T -
(Lowest)
86
pcjs.org
CodeView Expressions
used with strings. However, arrays, records, and user-defined types are all
supported.
The order and precedence with which the CodeView debugger evaluates
BASIC expressions are the same as in the Microsoft BASIC language. See
your BASIC documentation for a description of how BASIC operators can
be combined with symbols and constants to form expressions.
Important
The BASIC-expression evaluator supports arrays and array indexing
but not multidimensional arrays. This is a limitation only of the
BASIC-expression evaluator and does not apply to the other languages.
routine.variable
87
pcjs.org
Microsoft CodeView and Utilities
■ Syntax
name
■ Syntax
Integer constants are entered in the system radix and are made up of
octal, decimal, or hexadecimal digits. You may override the system radix
by using the octal, or hexadecimal prefix. In addition, you can use the &
suffix on any integer constant to indicate that the integer is to be stored as
a long (four-byte) integer, rather than as a short (two-byte) integer. To
enter integers in the decimal format, the system radix must be 10, and you
use the default radix. There is no way to enter decimal integers when the
system radix is other than 10, unless you switch to another expression
evaluator.
pcjs.org
CodeView Expressions
For example, if you enter ABC as an argument when the program contains
a variable or function named ABC, the CodeView debugger interprets the
argument as the symbol. If you want to enter ABC as a number, enter it
as &HABC.
Table 4.7 shows how a sample number (63 decimal) would be represented
in the octal, decimal, and hexadecimal radixes.
Table 4.7
BASIC Radix Examples
89
pcjs.org
Microsoft CodeView and Utilities
the CodeView debugger are listed in Table 4.8. See your BASIC compiler
manual for a complete description of the BASIC intrinsic functions.
Table 4.8
BASIC Intrinsic Functions
Supported by the CodeView Debugger
Argument Function
Name D e fi n i t i o n Ty p e Type
Except where noted, each of the functions in this table takes exactly one argument of the
type indicated in the third column.
90
pcjs.org
CodeView Expressions
Table 4.9
CodeView Pascal Operators
Precedence Operators
See the Microsoft Pascal Reference Manual to learn how Pascal operators
can be combined with identifiers and constants to form expressions.
The asterisk (*) is supported as both the multiplication and string con
catenation operator.
Set variables and set operations are not supported. The colon operator (:),
which the other expression evaluators support, is not supported by the
Pascal-expression evaluator.
Enumerated constants and variables can appear in expressions when used
with the ORD, PRED, or SUCC functions listed in Table 4.10. With
the Pascal-expression evaluator, the period (.) has its normal use as a
field-selection operator, but it also has an extended use as a specifier of
local variables in parent functions. The syntax is shown below:
routine.variable
91
pcjs.org
Microsoft CodeView and Utilities
access to the local variables of the routine that called it. But with the
Pascal-expression evaluator for CodeView, there is no nested scope. You
must use the period operator (.) to access any local variable not declared
in the currently executing routine. For example, consider this code:
procedure testl;
var a, b: integer;
procedure test2;
var m, n : integer;
procedure test3;
var x, y : integer;
begin
x : = m + n + a + b ;
In the example above, the procedure test3 has access to the variables a,
m, n, and d, as well as x and y. However, if we are in CodeView execut
ing test3, then variables declared outside of test3 can be accessed in
CodeView commands only with the aid of the period operator, as in:
testl.a
■ Syntax
name
92
pcjs.org
CodeView Expressions
■ Syntax
■ Syntax
'string'
■ Example
The example uses the Enter ASCII command (EA) to enter the given
string into memory, starting at the address of the variable message.
93
pcjs.org
Microsoft CodeView and Utilities
enumerated types, to access array bounds, and to convert one type of data
to another. The Pascal intrinsic functions recognized by the CodeView
debugger are listed in Table 4.10. See the Microsoft Pascal Reference Guide
for a complete description of the Pascal intrinsic functions.
Table 4.10
Pascal Intrinsic Functions
Supported by the CodeView Debugger
Argument Function
Name D e fi n i t i o n Ty p e Ty p e
94
pcjs.org
CodeView Expressions
The /ZI option, available with Version 5.0 and later of the Microsoft
Macro Assembler, provides variable size information for the CodeView
debugger. This makes for correct evaluation of expressions derived from
assembly code (except with arrays, which are discussed later in this sec
tion). If you have an earlier version of the Macro Assembler, you will need
to use C type casts to get correct evaluation.
When a program assembles or when the Auto switch is on, source files with
an .ASM extension will cause CodeView to select the C-expression evalua
tor. However, the following options will be set differently from the C
default options:
• System radix is hexadecimal (not decimal).
• Register window is on.
• Case Sense is off.
Note
The examples below present expressions, not CodeView commands.
You can see the results of these expressions by using them as operands
for the Display Expression command (?), described in Chapter 6,
"Examining Data and Expressions."
In the following list, examples of assembly source code are shown in the
left-hand column. Corresponding CodeView expressions (with the C-
expression evaluator) are shown in the right-hand column.
1. Register indirection.
The C-expression evaluator does not extend the use of brackets to
registers. To refer to the byte, word, or double word pointed to by
a register, use the BY, WO, or DW operator.
95
pcjs.org
Microsoft CodeView and Utilities
96
pcjs.org
CodeView Expressions
■ Syntax
• Ifilenametllinenumber
■ Examples
>V .100
The example above uses the View command (V) to display code starting at
the source line 100. Since no file is indicated, the current source file is
assumed.
>V .SAMPLE.FOR:10
>V .EXAMPLE.BAS:22
>V .DEMO.C:301
97
pcjs.org
Microsoft CodeView and Utilities
4.7.1 Registers
■ Syntax
{©^register
You can specify a register name if you want to use the current value stored
in the register. Registers are rarely needed in source-level debugging, but
they are used frequently for assembly-language debugging.
When you specify an identifier, the CodeView debugger first checks the
symbol table for a symbol with that name. If the debugger does not find a
symbol, it checks to see if the identifier is a valid register name. If you
want the identifier to be considered a register, regardless of any name in
the symbol table, use the "at" sign (@) as a prefix to the register name.
For example, if your program has a symbol called AX, you could specify
@AX to refer to the AX register. You can avoid this problem entirely by
making sure that identifier names in your program do not conflict with
register names.
The register names known to the CodeView debugger are shown in Table
4.11. Note that the 32-bit registers are available only if the 386 option is
on and if the computer is a 386 machine running in 386 mode.
Table 4.11
Registers
Type Names
pcjs.org
98
CodeView Expressions
4.7.2 Addresses
■ Syntax
Isegment:^ offset
Addresses can be specified in the CodeView debugger through the use of
the colon operator as a segment:offset connector. Both the segment and the
offset are made up of expressions.
A full address has a segment and an offset, separated by a colon. A partial
address has just an offset; a default segment is assumed. The default seg
ment varies, depending on the command with which the address is used.
Commands that refer to data (Dump, Enter, Watch, and Tracepoint) use
the contents of the DS register. Commands that refer to code (Assemble,
Breakpoint Set, Go, Unassemble, and View) use the contents of the CS
register.
Full addresses are seldom necessary in source-level debugging. Occasion
ally they may be convenient for referring to addresses outside the pro
gram, such as BIOS (basic input/output system) or DOS addresses.
■ Examples
>DB 100
In the example above, the Dump Bytes command (DB) is used to dump
memory starting at offset address 100. Since no segment is given, the
data segment (the default for Dump commands) is assumed.
> D B A R R AY ( C O U N T ) ; * F O R T R A N / B A S I C e x a m p l e
In the example above, the Dump Bytes command is used to dump memory
starting at the address of the variable ARRAY (COUNT). In C, a similar
variable might be denoted as array [count] .
>DB label+10
In the example above, the Dump Bytes command is used to dump memory
starting at a point 10 bytes beyond the symbol label.
>DB ES:200
In the example above, the Dump Bytes command is used to dump memory
at the address having the segment value stored in ES and the offset
address 200.
99
pcjs.org
Microsoft CodeView and Utilities
■ Syntax
startaddress endaddress
startaddress L count
A range is a pair of memory addresses that bound a sequence of contigu
ous memory locations.
You can specify a range in two ways. One way is to give the start and end
points. In this case the range covers startaddress to endaddress, inclusively.
If a command takes a range, but you do not supply a second address, the
CodeView debugger usually assumes the default range. Each command has
its own default range. (The most common default range is 128 bytes.)
You can also specify a range by giving its starting point and the number of
objects you want included in the range. This type of range is called an
object range. In specifying an object range, startaddress is the address of
the first object in the list, L indicates that this is an object range rather
than an ordinary range, and count specifies the number of objects in the
range.
The size of the objects is the size taken by the command. For example, the
Dump Bytes command (DB) has byte objects, the Dump Words command
(DW) has words, the Unassemble command (U) has instructions, and
so on.
■ Examples
>DB buffer
100
pcjs.org
CodeView Expressions
>DB buffer L 20
The example above uses an object range to dump the same range as in the
previous example. The L indicates that the range is an object range, and
20 is the number of objects in the range. Each object has a size of 1 byte,
since that is the command size.
The example above uses the Unassemble command (u) to list the
assembly-language statements starting 30 instructions before funcname
and continuing to funcname.
All of the operators listed in this section are part of the CodeView C-
expression evaluator and should not be confused with CodeView com
mands. As operators, they can only build expressions, which in turn are
used as arguments in commands.
Note
The memory operators discussed in this section are only available with
the C-expression evaluator, and have lowest precedence of any C
operators.
101
pcjs.org
Microsoft CodeView and Utilities
Note
The examples that follow in Section 4.8 make use of the Display
Expression (?) Command, which is described in Section 6.1. The x for
mat specifier causes the debugger to produce output in hexadecimal.
■ Syntax
BY address
The result is a short integer that contains the value of the first byte stored
at address.
■ Examples
>? BY sum
101
The example above returns the first byte at the address of sum.
>? BY bp+6
42
This example returns the byte pointed to by the BP register, with a dis
placement of 6.
■ Syntax
WO address
The result is a short integer that contains the value of the first two bytes
stored at address.
102
pcjs.org
CodeView Expressions
Examples
>? WO sum
>13120
The example above returns the first word at the address of sum.
>? WO sp,x
>2F38
This example returns the word pointed to by the stack pointer; the word
therefore represents the last word pushed (the "top" of the stack).
■ Syntax
DW address
The result is a long integer that contains the value of the first four bytes
stored at address.
Note
Be careful not to confuse the DW operator with the DW command.
The operator is only useful for building expressions; it occurs within a
CodeView command line, but never at the beginning. The second use
of DW mentioned above, the Dump Words Command, occurs only at
the beginning of a CodeView command line. It displays an entire range
of memory (in words, not double words) rather than returning a single
result.
Examples
>? DW sum
>132120365
The example above returns the first double word at the address of sum.
103
pcjs.org
Microsoft CodeView and Utilities
>? DW si,x
>3E880000
■ Mouse
To switch expression evaluators with the mouse, open the Language menu
and click the appropriate language selection.
■ Keyboard
■ Dialog
USE {language}
104
pcjs.org
CodeView Expressions
displays the name of the current expression evaluator. The USE command
always displays the name of the current expression evaluator or the new
expression evaluator (if specified).
■ Examples
>USE fortran
FORTRAN
>USE
BASIC
The example above displays the name of the current expression evaluator,
which in this case happens to be BASIC.
105
pcjs.org
Chapters 5
F.XECUTING CODE
5.1 Trace Command 11 0
5.2 Program Step Command 11 3
5.3 Go Command 11 5
5.4 Execute Command 11 8
5.5 Restart Command 11 9
pcjs.org
Executing Code
Command Action
Note
If you are executing a section of code with the Go or Program Step
command, you can usually interrupt program execution by pressing
CONTROL+BREAK or CONTROL+C. This can terminate endless loops, or it
can interrupt loops that are delayed by the Watchpoint or Tracepoint
command (see Chapter 8, "Managing Watch Statements").
109
pcjs.org
Microsoft CodeView and Utilities
The Trace command executes the current source line in source mode, or
the current instruction in assembly mode. The current source line or
instruction is the one pointed to by the CS and IP registers. In window
mode, the current instruction is shown in reverse video or in a contrasting
color.
In source mode, if the current source line contains a call, the CodeView
debugger executes the first source line of the called routine. In this mode,
the CodeView debugger will only trace into functions and routines that
have source code. For example, if the current line contains a call to an
intrinsic function or a standard C library function, the debugger will sim
ply execute the function if you are in source mode, since the source code
for Microsoft standard libraries is not available.
If you are in assembly or mixed mode, the debugger will trace into the
function. In this mode, if the current instruction is CALL, INT or REP,
the debugger executes the first instruction of the procedure, interrupt, or
repeated string sequence.
Note
When you debug Microsoft Macro Assembler programs in source mode,
the paragraph above still applies. The debugger will not trace into an
LNT or REP sequence when you are in source mode.
Use the Trace command if you want to trace into calls. To execute calls
without tracing into them, you should use the Program Step command (P)
110
pcjs.org
Executing Code
instead. Both commands execute DOS function calls without tracing into
them. There is no direct way to trace into DOS function calls. However,
you can trace through BIOS calls in assembly or mixed mode.
Note
The Trace command (T) uses the hardware trace mode of the 8086
family of processors. Consequently, you can also trace instructions
stored in ROM (read-only memory). However, the Program Step com
mand (P) will not work in ROM. Using the Program Step command
has the same effect as using the Go command (G).
■ Mouse
To execute the Trace command with the mouse, point to Trace on the
menu bar and click the left button.
■ Keyboard
■ Dialog
T {count}
If the optional count is specified, the command executes count times before
stopping.
■ Example
The following example shows the Trace command in sequential mode. (In
window mode, there would be no output from the commands, but the
display would be updated to show changes caused by the command.)
I l l
pcjs.org
Microsoft CodeView and Utilities
The FORTRAN example above sets the display mode to source, and then
uses the Source Line command to display the current source line. (See
Chapter 9, "Examining Code," for a further explanation of the Set Source
and Source Line commands.) Note that the current source line calls the
subroutine INPUT. The Trace command is then used to execute the next
three source lines. These lines will be the first three lines of the subroutine
I N P U T.
Debugging C and BASIC source code is very similar. If you execute the
Trace command when the current source line contains a C function call or
a BASIC subprogram call, then the debugger will execute the first line of
the called routine.
>s-
assembly
>T
AX=0058 BX=3050 CX=000B DX=3FB0 SP=304C BP=3056 SI=00CC DI=40E0
DS=49B7 ES=49B7 SS=49B7 CS=3FB0 IP=0013 NV UP EI PL NZ AC PO NC
3FB0:CO13 50 PUSH AX
>
The example above sets the display mode to assembly and traces the
current instruction. This example and the next example are the same as
the examples of the Program Step command in Section 5.2. The Trace and
Program Step commands behave differently only when the current instruc
tion is a CALL, INT, or REP instruction.
>s&
mixed
>T
AX=0000 BX=319C CX=0028 DX=0000 SP=304C BP=3056 SI=OOCC DI=40E0
DS=49B7 ES=49B7 SS=49B7 CS=3FB0 IP=003C NV UP EI PL NZ NA PO NC
8 : I F ( N . LT. l . O R . N . G T. 1 0 0 0 ) G O T O 1 0 0
3FB0:003C 833ECE2101 CMP Word Ptr [21CE],+01 DS:21CE=0O28
>
The example above sets the display mode to mixed and traces the current
instruction.
112
pcjs.org
Executing Code
The Program Step command executes the current source line in source
mode, or the current instruction in assembly mode. The current source line
or instruction is the one pointed to by the CS and TP registers. In window
mode, the current instruction is shown in reverse video or in a contrasting
color.
In source mode, if the current source line contains a call, the CodeView
debugger executes the entire routine and is ready to execute the line after
the call. In assembly mode, if the current instruction is CALL, INT, or
REP, the debugger executes the entire procedure, interrupt, or repeated
string sequence.
Use the Program Step command if you want to execute over routine, func
tion, procedure, and interrupt calls. If you want to trace into calls, you
should use the Trace command (T) instead. Both commands execute DOS
function calls without tracing into them. There is no direct way to trace
into DOS function calls.
■ Mouse
To execute the Program Step command with the mouse, point to Trace on
the menu bar and click the right button.
■ Keyboard
■ Dialog
P {count}
If the optional count is specified, the command executes count times before
stopping.
■ Example
113
pcjs.org
Microsoft CodeView and Utilities
The example above (in FORTRAN or BASIC) sets the display mode to
source, and then uses the Source Line command to display the current
source line. (See Chapter 9, "Examining Code," for a further explanation
of the Set Source and Source Line commands.) Notice that the current
source line calls the subprogram INPUT. The Program Step command is
then used to execute the next three source lines. The first program step
executes the entire subprogram INPUT. The next two steps execute the
subprograms BUBBLE and STATS, also in their entirety.
The same program, written in C, would behave exactly the same way with
the Program Step command. The Program Step command will not trace
into a C function call.
>s-
assembly
>P
AX=O058 BX=3050 CX=OOOB DX=3FB0 SP=304C BP=3056 SI=OOCC DI=40E0
DS=49B7 ES=49B7 SS=49B7 CS=3FB0 IP=0013 NV UP EI PL NZ AC PO NC
3FB0:O013 50 PUSH AX
>
The example above sets the display mode to assembly and steps through
the current instruction. This example and the next example are the same
as the examples of the Trace command in Section 5.1. The Trace and Pro
gram Step commands behave differently only when the current instruction
is a CALL, INT, or REP instruction.
>s&
mixed
>P
AX=0000 BX=319C CX=O028 DX=0000 SP=304C BP=3056 SI=O0CC DI=40E0
DS=49B7 ES=49B7 SS=49B7 CS=3FB0 IP=003C NV UP EI PL NZ NA PO NC
8 : I F ( N . LT. l . O R . N . G T. 1 0 0 0 ) G O T O 1 0 0
3FB0:O03C 833ECE2101 CMP Word Ptr [21CE],+01 DS:21CE=0028
>
The example above sets the display mode to mixed and steps through the
current instruction.
114
pcjs.org
Executing Code
5.3 Go Command
The Go command starts execution at the current address. There are two
variations of the Go command, Go and Goto. The Go variation simply
starts execution and continues to the end of the program or until a break
point set earlier with the Breakpoint Set (BP), Watchpoint (WP), or
Tracepoint (TP) command is encountered. The other variation is a Goto
command, in which a destination is given with the command.
If a destination address is given but never encountered (for example, if the
destination is on a program branch that is never taken), the CodeView
debugger executes to the end of the program.
If you enter the Go command and the debugger does not encounter a
breakpoint, the entire program is executed and the following message is
displayed:
■ Mouse
To execute the Goto variation of the Go command, point to the source line
or instruction you wish to go to; then press the right button. The highlight
marking the current location will move to the source line or instruction
you pointed to (unless a breakpoint is encountered first). The CodeView
debugger will sound a warning and take no action if you try to go to a
comment line or other source line that does not correspond to code.
If the line you wish to go to is in another module, you can use the Load
command from the Files menu to load the source file for the other module.
Then point to the destination line and press the right button.
■ Keyboard
115
pcjs.org
Microsoft CodeView and Utilities
When the cursor is at the appropriate line in the display window, press the
F7 key. The highlight marking the current location will move to the source
line or instruction you pointed to (unless a breakpoint is encountered
first). The CodeView debugger will sound a warning and take no action if
you try to go to a comment line or other source line that does not
correspond to code.
If the line you wish to go to is in another module, you can use the Load
command from the Files menu to load the source file for the other module.
Then move the cursor to the destination line and press the F7 key.
■ Dialog
■ Examples
116
pcjs.org
Executing Code
In the example above, the display mode is first set to source (S+). (See
Chapter 9, "Examining Code," for information on setting the display
mode.) When the Go command is entered, the CodeView debugger starts
program execution at the current address and continues until it reaches
the start of the subprogram BUBBLE.
The example above passes execution control to the program at the current
address and executes to the address of source line 22. If the address with
the breakpoint is never encountered (for example, if the program has less
than 22 lines, or if the breakpoint is on a program branch that is never
taken), the CodeView debugger executes to the end of the program.
Note
Mixed and source mode can be used equally well with all three
languages. The examples alternate languages in this chapter simply to
be accessible to more users.
>s-
assembly
>G #2A8
AX=0049 BX=0049 CX=028F DX=CO00 SP=12F2 BP=12F6 SI=04BA DI=1344
DS=5DAF ES=5DAF SS=5DAF CS=58BB IP=02A8 NV UP EI PL NZ NA PE NC
58BB:02A8 98 CBW
>
117
pcjs.org
Microsoft CodeView and Utilities
■ Mouse
To execute code in slow motion with the mouse, point to Run on the menu
bar, press a mouse button and drag the highlight down to the Execute
selection, and then release the button.
■ Keyboard
■ Dialog
E
You cannot set a destination for the Execute command as you can for the
Go command.
In sequential mode, the output from the Execute command depends on the
display mode (source, assembly, or mixed). In assembly or mixed mode, the
command executes one instruction at a time. The command displays the
current status of the registers and the instruction. In mixed mode, it will
also show a source line if there is one at the instruction. In source mode,
the command executes one source line at a time, displaying the lines as it
executes them.
Important
The Execute command has the same command letter (E) as the Enter
command. If the command has at least one argument, it is interpreted
as Enter; if not, it is interpreted as Execute.
118
pcjs.org
Executing Code
The Restart command restarts the current program. The program is ready
to be executed just as if you had restarted the CodeView debugger. Pro
gram variables are reinitialized, but any existing breakpoints or watch
statements are retained. The pass count for all breakpoints is reset to 1.
Any program arguments are also retained, though they can be changed
with the dialog version of the command.
The Restart command can only be used to restart the current program. If
you wish to load a new program, you must exit and restart the CodeView
debugger with the new program name.
■ Mouse
To restart the program with the mouse, point to Run on the menu bar,
press a mouse button and drag the highlight down to the Restart or Start
selection, and then release the button. The program will be restarted. If
the Restart selection is chosen, the program will be ready to start execut
ing from the beginning (but not actually running). If the Start selection is
chosen, the program starts executing from the beginning and continues
until a breakpoint or the end of the program is encountered.
■ Keyboard
■ Dialog
When you restart using the dialog version of the command, the program
will be ready to start executing from the beginning. If you want to restart
with new program arguments, you can give optional arguments. You can
not specify new arguments with the mouse or keyboard version of the
command.
119
pcjs.org
Microsoft CodeView and Utilities
Note
The command letter L is a mnemonic for Load, but the command
should not be confused with the Load selection from the File menu,
since that selection only loads a source file without restarting the
program.
Examples
>L
>
The example above starts the current executable file, retaining any break
points, watchpoints, tracepoints, and arguments.
>L 6
>
The example above restarts the current executable file, but with 6 as the
new program argument.
120
pcjs.org
Chapters 6
R X A M I N I N G D ATA _
AND EXPRESSIONS ^
6.1 Display Expression Command 123
6.2 Examine Symbols Command 132
6.3 Dump Commands 138
6.3.1 Dump 139
6.3.2 Dump Bytes .140
6.3.3 Dump ASCII 141
6.3.4 Dump Integers 141
6.3.5 Dump Unsigned Integers 142
6.3.6 Dump Words 143
6.3.7 Dump Double Words 144
6.3.8 Dump Short Reals 144
6.3.9 Dump Long Reals 145
6.3.10 Dump 10-Byte Reals 146
6.4 Compare Memory Command 147
6.5 Search Memory Command 148
6.6 Port Input Command 149
6.7 Register Command 150
6.8 8087 Command 152
pcjs.org
Examining Data and Expressions
Command Action
Note
FORTRAN subroutines and BASIC subprograms do not return values
as functions do. They can be used in expressions, and in fact may be
useful for observing side effects. However, the value returned by the
expression will be meaningless.
123
pcjs.org
Microsoft CodeView and Utilities
Table 6.1
CodeView Format Specifiers
124
pcjs.org
Examining Data and Expressions
Hexadecimal letters are uppercase if the type is X and lowercase if the type is x.
The "E" is uppercase if the type is E or G; lowercase if the type is e or g.
The s string format is used only with the C-expression evaluator: it prints characters up
to the first null.
The prefix h can be used with the integer format specifiers (d, o, u, x, and
X) to specify a two-byte integer. The prefix 1 can be used with the same
types to specify a four-byte integer. For example, the command
7100000, Id produces the output 100000. However, the command
7100000, hd evaluates only the low-order two bytes, producing; the out
put -31072.
The Display Expression command does not work for programs assembled
with Microsoft Macro Assembler Versions 4.0 and earlier, because the
assembler does not write information to the object file about the type size
of each variable. Use the Dump command instead.
Note
Do not use a type specifier when evaluating strings in FORTRAN,
BASIC, or Pascal. Simply leave off the type specifier, and the expres
sion evaluator will display the string correctly. The s type specifier
assumes the C language string format, with which other languages
conflict; if you use s, then the debugger will simply display characters
at the given address until a null is encountered.
125
pcjs.org
Microsoft CodeView and Utilities
■ Mouse
■ Keyboard
■ Dialog
? expression{,format}
The expression is any valid CodeView expression, and the optional format
is a CodeView format specifier.
The remainder of this section first gives examples that are relevant to all
languages, and then gives examples specific to C, FORTRAN, BASIC and
Pascal.
If you are debugging code written with the assembler, you will use the C-
expression evaluator by default. Consult Section 4.5 for guidelines on how
to use the C-expression evaluator with assembly code.
■ Examples
>? amount
50C
>? amount,x
If 4
>? amount,o
764
>
The example above displays the value stored in the variable amount, an
integer. This value is first displayed in the system radix (in this case,
decimal), then in hexadecimal, and then in octal.
>? 92,x
5c
>? 109*(35+2) ,o
7701
>? 118,c
v
>
126
pcjs.org
Examining Data and Expressions
The example above shows how the CodeView debugger can be used as a
calculator. You can convert between radixes, calculate the value of con
stant expressions, or check ASCII equivalences.
>? chance,f
0.083333
>? chance,e
8.333333e-002
>? chance,E
8.333333E-002
■ C Examples
The following examples assume that a C source file is being debugged, and
that it contains the following declarations:
Assume also that the program has been executed to the point where the
above variables have been assigned values, and that the C-expression
evaluator is in use.
>? text, X
13F3
>DA 0xl3F3
3D83:13F0 Here is a string.
>? text,s
Here is a string.
>
The example above shows how to examine strings. One method is to evalu
ate the variable that points to the string, and then dump the values at
that address (the Dump commands are explained in Section 6.3). A more
direct method is to use the s type specifier.
127
pcjs.org
Microsoft CodeView and Utilities
>? student.id
19643
>? pstudent->id
19643
>
>? amount
500
>? ++amount
501
>? amount=600
600
>
The example above shows how the Display Expression command can be
used with the C-expression evaluator to change the values of variables.
>? square(9)
81
>
■ FORTRAN Examples
The examples below assume that the FORTRAN source file contains the
following variable declarations, in which SQUARE is a function:
INTEGER*2 SQUARE
INTEGER*2 AMOUNT
CHARACTER*16 STR
STR = 'Here is a string'
Assume also that the program has executed to the point where these vari
ables have been assigned values, and that the FORTRAN-expression
evaluator has been selected.
>? STR
'Here is a string'
The example above shows how to examine strings with the FORTRAN-
expression evaluator. The s format specifier is not required.
128
pcjs.org
Examining Data and Expressions
>? AMOUNT
500
>? AM0UNT=AM0UNT+1
501
>? AM0UNT=600
600
>? AMOUNT
600
>
The example above shows how the Display Expression command can be
used to change values with the FORTRAN-expression evaluator.
>? SQUARE(9)
81
>
■ BASIC Examples
These examples assume that the BASIC source file contains the following
statements:
amount% = 500
str$ = "H e re i s a stri n g "
Assume also that the program has been executed up to these statements
and that the BASIC-expression evaluator is in use.
>? str$
Here is a string
The first example above shows how to examine strings with the BASIC-
expression evaluator. The s format specifier should not be used.
>? ASC(str$)
72
129
pcjs.org
Microsoft CodeView and Utilities
>? amount%
500
>? LET amount%=amount%+l
501
>? LET amount%=600
600
> ? amount%
600
>
The example above shows how the Display Expression command can be
used to change values with the BASIC-expression evaluator. With BASIC,
the LET command can only be applied to numeric data, not strings.
Note
The BASIC-expression evaluator cannot evaluate functions defined in
the program, as the C- and FORTRAN-expression evaluators can.
■ Pascal Examples
The following examples assume that a Pascal source file has the following
declarations:
Assume also that the program has been executed to the point where all
these variables have been assigned values, and that the Pascal-expression
evaluator is in use.
130
pcjs.org
Examining Data and Expressions
>? str
This is a string
>? torn.id
19643
>? ORD(mycard)
2
>? ORD(SUCC(mycard))
3
The example above shows how various Pascal types can be evaluated. Note
that the s type specifier must not be used to evaluate strings.
>? amount
500
>? amount := amount+1
501
>? amount := 600
600
>? amount
600
>
>? square(3)+1
10
>
The example above shows how a function defined in the source code can be
used in a CodeView expression.
■ Assembly Examples
The example above displays the first byte at the location pointed to by
BX, and is equivalent to the assembly expression BYTE PTR [bx].
131
pcjs.org
Microsoft CodeView and Utilities
>? WO bp+8
9359
>
The example above displays the first word at the location pointed to by
[bp+8] .
>? DW si+12
12555324
>
The example above displays the first double word at the location pointed
toby [si + 12].
>? (ch a r) va r
5
>? (int) var
1005
>
The last two examples use type casts, which are similar to the assembler
PTR operator. The expression (char) var displays the byte at the
address of var, in signed format. The expression (int) var displays
the word at the same address, also in signed format. You can alter either
of these commands to display results in unsigned format simply by using
the u format specifier.
> ? ( c h a r ) v a r, u
> ? ( i n t ) v a r, u
The Examine Symbols command displays the names and addresses of sym
bols, and the names of modules, defined within a program. You can specify
the symbol or group of symbols you want to examine by module, pro
cedure, or symbol name.
■ Mouse
■ Keyboard
■ Dialog
Syntax Display
133
pcjs.org
Microsoft CodeView and Utilities
Note
When you debug an assembly module, you cannot use the routine field;
you must use the module field. Therefore, the only versions of this com
mand that work with assembly modules are the following:
~Ktmodule\*
Xlmodulelsymbol
■ C Examples
For the following examples, assume that the program being examined is
called pi . exe, and that it consists of two modules: pi . c and math. c.
The pi . c module is a skeleton consisting only of the main function,
whereas the math, c module has several functions. Assume that the
current function is div within the math module.
>X* ;*Example 1
PI.OBJ
MATH.OBJ
C:B(chkstk)
C:B(crtO)
C:B(itoa)
C:B(unlink)
>
>X?* ;*Example 2
DI int b
[BP-0006] int quotient
SI int i
[BP-0002] int remainder
[BP+0004] int divisor
134
pcjs.org
Examining Data and Expressions
Example 2 lists the symbols in the current function (div). Local variables
are shown as being stored either in a register (b in register DI) or at a
memory location specified as an offset from a register (divisor at loca
tion [BP+0004]).
>X?pi! * ;* Example 3
3D37:19B2 int _scratchO 3D37:0A10 char -p[]
3D37:2954 int _scratchl 3D37:19B4 char -t[]
3D37:2956 int _scratch2 3D37:19BO int -q
3A79:0010 int jiain() 3A79:0010 int main ()
3D37:19B2 int scratchO
3D37: 0A10 char P[]
3D37:2954 int scratchl
3D37:19B4 char t[]
3D37:2956 int scratch2
3D37:19BO int q
>
>X?math!arctan.s ;* Example 5
3A79:00FA int arctan()
[BP+0004] int ' s
>
Example 5 shows one specific variable (s) within the arctan function.
■ FORTRAN Examples
For the following examples, assume that the program being examined is
called FRUST. EXE, and that it consists of four modules: FRUST. FOR
FRUST1. FOR, FRUST2 . FOR, and FRUST3 . FOR. Assume that the
current routine is main within the FRUST.FOR module.
135
pcjs.org
Microsoft CodeView and Utilities
>X*
FRUST.OBJ
FRUST1.OBJ
FRUST2.OBJ
FRUST3.OBJ
c : \ l i b \ L L I B F O R E . L I B ( fi x u p s )
c:\lib\LLIBFORE.LIB(crtO)
c:\lib\LLIBFORE.LIB(chkstk)
c:\lib\LLIBFORE.LIB(wr)
c:\lib\LLIBFORE.LIB(txtmode)
c:\lib\LLIBFORE.LIB(_creat)
The example above lists the four modules called by the program. The
library files called by the program are also listed.
>X?T
520D:0DE4 REAL*4 T
The example above shows the address of the variable T in the current
module.
>X?FRUST3 '.MULTPI. *
4B28:0005 INTEGER*4 MULTPI ()
[BP+OOOA] V
[BP+0006] X
[BP-0004] INTEGER*4 MULTPI
The example above lists the symbols in the function MULTPI, located in
module FRUST3. Variables local to the function are indented under the
function. You wouldn't need to specify the module if FRUST3 were the
current module.
>X?FRUST2!SAREA.*
4B15:000E void SAREA()
[BP+0012] Rl
[BP+OOOE] R2
[BP+OOOA] H
[BP+0006] T
520D:0DEC REAL*4 S12
520D:0DE8 REAL*4 U
The example above shows all the symbols in the routine SAREA in the
module FRUST2. Because SAREA is a subroutine instead of a function,
the word void appears where function return-value types are shown.
136
pcjs.org
Examining Data and Expressions
■ BASIC Examples
For the following examples, assume that the program being examined is
called PROG.EXE, and that it consists of the following modules:
PROG. BAS and SORT. BAS. Assume that the current routine is the main
program (which, unlike subprograms, has no name in a BASIC program),
and that the module SORT. BAS contains two subprograms, SORT and
SWITCH.
>X*
PROG.OBJ
SORT.OBJ
BRUN303.LIB(ftmdata)
BRUN303.LIB(crtO)
BRUN303.LIB(crtOdat)
BRUN303.LIB(doexec)
BRUN303.LIB(execmsg)
The example above lists the two modules of the program, including
PROG.OBJ, which is the main module. The BASIC library files called by
the program are also listed.
>X?*
5825:17BE integer A%[array]
5825:1780 single HOURS!
5825:1784 integer 1%
The example above lists the symbols in the current routine, which happens
to be the main program. Although the main program has no label and
therefore will not show up in a stack trace, it is still an independent rou
tine and has its own local variables. In BASIC, local variables are not put
on the stack unless they are subprogram parameters.
>X?*S0RT»*
572F:0033 integer SORTQ
572F:00E1 integer SWITCH()
The example above lists the routines in the module SORT. OBJ. This
form of the Display Symbols command lists routines only, not variables.
Note that SORT () and SWITCH () are given with the addresses of the
two subprograms by that name.
>X?SORT!SWITCH.*
[BP+0008] integer B%
[BP+0006] integer C%
5824:1798 integer TEMP%
The example above shows all the symbols in the routine SWITCH, which is
in the SORT. OBJ module. Each represents an integer. However, B% and
137
pcjs.org
Microsoft CodeView and Utilities
The CodeView debugger has several commands for dumping data from
memory to the screen (or other output device). The Dump commands are
listed below.
Command Command Name
■ Mouse
■ Keyboard
■ Dialog
138
pcjs.org
Examining Data and Expressions
The type is a one-letter specifier that indicates the type of the data to be
dumped. The Dump commands expect either a starting address or a range
of memory. If the starting address is given, the commands assume a
default range (usually determined by the size of the dialog window) start
ing at address. If range is given, the commands dump from the start to the
end of range. The maximum size of range is 32K.
If neither address nor range is given, the commands assume the current
dump address as the start of the range and the default size associated with
the size of the object as the length of the range. The Dump Real com
mands have a default range size of one real number. The other Dump com
mands have a default size determined by the size of the dialog window (if
you are in window mode), or a default size of 128 bytes otherwise.
The current dump address is the byte following the last byte specified in
the previous Dump command. If no Dump command has been used during
the session, the dump address is the start of the data segment (DS). For
example, if you enter the Dump Words command with no argument as the
first command of a session, the CodeView debugger displays the first 64
words (128 bytes) of data declared in the data segment. If you repeat the
same command, the debugger displays the next 64 words following the
ones dumped by the first command.
Note
If the value in memory cannot be evaluated as a real number, the
Dump commands that display real numbers (Dump Short Reals, Dump
Long Reals, or Dump 10-Byte Reals) will display a number containing
one of the following character sequences: #NAN, #INF, or #IND. NAN
(not a number) indicates that the data cannot be evaluated as a real
number. INF (infinity) indicates that the data evaluates to infinity.
IND (indefinite) indicates that the data evaluates to an indefinite
number.
6.3.1 Dump
■ Syntax
D {address \ range}
139
pcjs.org
Microsoft CodeView and Utilities
the format of the default type. The default type is the last type specified
with a Dump, Enter, Watch Memory, or Tracepoint Memory command. If
none of these commands has been entered during the session, the default
type is bytes.
The Dump command displays one or more lines, depending on the address
or range specified. Each line displays the address of the first item dis
played. The Dump command must be separated by at least one space from
any address or range value. For example, to dump memory starting at
symbol a, use the command D a, not Da. The second syntax would be
interpreted as the Dump ASCII command.
■ Syntax
DB {address \ range}
The Dump Bytes command displays the hexadecimal and ASCII values of
the bytes at the specified address or in the specified range of addresses.
The command displays one or more lines, depending on the address or
range supplied.
Each line displays the address of the first byte in the line, followed by up
to 16 hexadecimal byte values. The byte values are immediately followed
by the corresponding ASCII values. The hexadecimal values are separated
by spaces, except the eighth and ninth values, which are separated by a
dash (-). ASCII values are printed without separation. Unprintable ASCII
values (less than 32 or greater than 126) are displayed as dots. No more
than 16 hexadecimal values are displayed in a line. The command displays
values and characters until the end of the range or, if no range is given,
until the first 128 bytes have been displayed.
■ Example
>DB O 36
3D5E:0O00 53 6F 6D 65 20 6C 65 74-74 65 72 73 20 61 6E 64 Some letters and
3D5E:0010 20 6E 75 6D 62 65 72 73-3A 00 10 EA 89 FC FF EF numbers:
3D5E:0020 00 FO 00 CA E4 -
>
140
pcjs.org
Examining Data and Expressions
6.3.3 DumpASCE
■ Syntax
DA {address \ range}
■ Examples
>DA O
3D7C:0000 Some letters and numbers:
>
The example above displays the ASCII values of the bytes starting at
DS: 0. Since no ending address is given, values are displayed up to the first
null byte.
>DA O 36
3D7C:0000 Some letters and numbers:
>
■ Syntax
DI {address \ range}
The Dump Integers command displays the signed decimal values of the
words (two-byte values) starting at address or in the specified range of
141
pcjs.org
Microsoft CodeView and Utilities
Note
In this manual an integer is considered a two-byte value, since the
CodeView debugger assumes that integer size. Note that a default
FORTRAN integer is a four-byte value.
■ Example
>DI O 36
3D5E:0000 28499 25965 27680 29797 25972 29554 24864 25710
3D5E:O010 28192 28021 25954 29554 58 -5616 -887 -4097
3D5E:0020 -4096 -13824 2532
>
The example above displays the byte values from DS :0 to DS : 36 (24 hex
adecimal). Compare the signed decimal numbers at the end of this dump
with the same values shown as unsigned integers in Section 6.3.5 below.
■ Syntax
DU {address \ range}
142
pcjs.org
Examining Data and Expressions
of the range or until the first 64 unsigned integers have been displayed,
whichever comes first.
■ Example
>DU O 36
3D5E:0OOO 28499 25965 27680 29797 25972 29554 24864 25710
3D5E:0010 28192 28021 25954 29554 58 59920 64649 61439
3D5E:0O20 61440 51712 2532
>
The example above displays the byte values from DS : O to DS : 36 (24 hex
adecimal). Compare the unsigned decimal numbers at the end of this
dump with the same values shown as signed integers in Section 6.3.4
above.
■ Syntax
DW {address \ range}
The Dump Words command displays the hexadecimal values of the words
(two-byte values) starting at address or in the specified range of addresses.
The command displays one or more lines, depending on the address or
range specified. Each line displays the address of the first word in the line,
followed by up to eight hexadecimal words. The hexadecimal values are
separated by spaces. The command displays values until the end of the
range or until the first 64 words have been displayed, whichever comes
first.
■ Example
>DW O 36
3D5E:0000 6F53 656D 6C20 7465 6574 7372 6120 646E
3D5E:0010 6E20 6D75 6562 7372 003A EA10 FC89 EFFF
3D5E:0020 FOOO CAOO 09E4
>
143
pcjs.org
Microsoft CodeView and Utilities
■ Syntax
DD {address \ range}
The Dump Double Words command displays the hexadecimal values of the
double words (four-byte values) starting at address or in the specified
range of addresses.
The command displays one or more lines, depending on the address or
range specified. Each line displays the address of the first double word in
the line, followed by up to four hexadecimal double-word values. The
words of each double word are separated by a colon. The values are
separated by spaces. The command displays values until the end of the
range or until the first 32 double words have been displayed, whichever
comes first.
■ Example
>DD O 36
3D5E:0000 656D:6F53 7465:6C20 7372:6574 646E:6120
3D5E:0010 6D75:6E20 7372:6562 EA10:003A EFFF:FC89
3D5E:0020 CA00:F000 6F73:09E4
>
■ Syntax
DS {address \ range}
The Dump Short Reals command displays the hexadecimal and decimal
values of the short (four-byte) floating-point numbers at address or in the
specified range of addresses.
The command displays one or more lines, depending on the address or
range specified. Each line displays the address of the floating-point number
in the first column. Next, the hexadecimal values of the bytes in the
number are shown, followed by the decimal value of the number. The
hexadecimal values are separated by spaces.
144
pcjs.org
Examining Data and Expressions
{-\digit.digitsEi{-\- \ —} exponent
If the number is negative, it will have a minus sign; positive numbers have
no sign. The first digit of the number is followed by a decimal point. Six
decimal places are shown following the decimal point. The letter E follows
the decimal digits, and marks the start of a three-digit signed exponent.
The command displays at least one value. If a range is specified, all values
in the range are displayed.
■ Example
>DS SPI
5E68:0100 DB OF 49 40 3.141593E+000
>
■ Syntax
DL {address \ range}
The Dump Long Reals command displays the hexadecimal and decimal
values of the long (eight-byte) floating-point numbers at the specified
address or in the specified range of addresses.
The command displays one or more lines, depending on the address or
range specified. Each line displays the address of the floating-point number
in the first column. Next, the hexadecimal values of the bytes in the
number are shown, followed by the decimal value of the number. The
hexadecimal values are separated by spaces.
{—}digit.digitsEi{-\- \ —} exponent
If the number is negative, it will have a minus sign; positive numbers have
no sign. The first digit of the number is followed by a decimal point. Six
decimal places are shown following the decimal point. The letter E follows
the decimal digits, and marks the start of a three-digit signed exponent.
145
pcjs.org
Microsoft CodeView and Utilities
The command displays at least one value. If a range is specified, all values
in the range are displayed.
■ Example
>DL LPI
5 E 6 8 : 0 2 0 0 11 2 D 4 4 5 4 F B 2 1 0 9 4 0 3 . 1 4 1 5 9 3 E + 0 0 0
>
■ Syntax
DT {address \ range}
The Dump 10-Byte Reals command displays the hexadecimal and decimal
values of the 10-byte floating-point numbers at the specified address or in
the specified range of addresses.
The command displays at least one value. If a range is specified, all values
in the range are displayed.
■ Example
>DT TPI
5E68:0300 DE 87 68 21 A2 DA OF C9 00 40 3.141593E+000
>
146
pcjs.org
Examining Data and Expressions
■ Mouse
■ Keyboard
■ Dialog
To compare two blocks of memory, enter a command line with the follow
ing syntax:
C range address
The bytes in the memory locations specified by range are compared with
the corresponding bytes in the memory locations beginning at address. If
one or more pairs of corresponding bytes do not match, each pair of
mismatched bytes is displayed.
■ Examples
147
pcjs.org
Microsoft CodeView and Utilities
The second example compares the 100 bytes starting at the address of
arrl (1), with the 100 bytes starting at address of arr2 (1). The Code
View debugger produces no output in response, so this indicates that the
first 100 bytes of each array are identical. (Using C language, this example
would be entered as C arrl [0] L 100 arr2 [O].)
Note
You can enter the Compare Memory command using any radix you
like; however, any output will still be in hexadecimal format.
The Search Memory command (not to be confused with the Search com
mand discussed in Section 11.6) scans a specified area of memory, looking
for specific byte values. It is primarily of interest to programmers using
assembly mode, and to users who want to test for the presence of specific
values within a range of data.
■ Mouse
■ Keyboard
■ Dialog
To search a block of memory, enter the Search Memory command with the
following syntax:
S range list
The debugger will search the specified range of memory locations for the
byte values specified in the list. If bytes with the specified values are
148
pcjs.org
Examining Data and Expressions
■ Examples
The first example displays the address of each memory location containing
the string error. The command searches the first 1500 bytes at the
address specified by buffer. The string was found at the three addresses
displayed by the CodeView debugger.
>S DS:100 200 OA ;* hexadecimal radix assumed
3CBA:0132
3CBA:01C2
>
The second example displays the address of each memory location that
contains the byte value OA in the range DS:0100 to DS:0200 (hexadec
imal). The value was found at two addresses.
■ Mouse
■ Keyboard
149
pcjs.org
Microsoft CodeView and Utilities
■ Dialog
I port
The byte is read and displayed from the specified port, which can be any
16-bit address.
■ Examples
The preceding example reads input port, number 2F8, and displays the
result, E8. You may enter the port address using any radix you want, but
the result will always be displayed in current radix.
The Port Input command is often used in conjunction with the Port Out
put command, which is described in Section 10.5.
The Register command has two functions. It displays the contents of the
central processing unit (CPU) registers. It can also change the values of
the registers. The display features of the Register command are explained
here. The modification features of the command are explained in Chapter
10, "Modifying Code or Data."
■ Mouse
To display the registers with the mouse, point to View on the menu bar,
press a mouse button and drag the highlight down to the Registers selec
tion, and then release the button. The register window will appear on the
right side of the screen. If the register window is already on the screen, the
same command removes it.
■ Keyboard
150
pcjs.org
Examining Data and Expressions
If the register window is already on the screen, the same command will
remove it.
In sequential mode, the F2 key will display the current status of the regis
ters. (This produces the same effect as entering the Register dialog com
mand with no argument.)
■ Dialog
The current values of all registers and flags are displayed. The instruction
at the address pointed to by the current CS and D? register values is also
shown. (The Register command can also be given with arguments, but
only when used to modify registers, as explained in Chapter 10, "Modify
ing Code or Data.")
If the display mode is source (S+) or mixed (S&) (see Section 9.1, "Set
Mode Command," for more information), the current source line is also
displayed by the Register command. If an operand of the instruction con
tains memory expressions or immediate data, the CodeView debugger will
evaluate operands and show the value to the right of the instruction. This
value is referred to as the "effective address," and is also displayed at the
bottom of the register window. If the CS and D? registers are currently at
a breakpoint location, the register display will indicate the breakpoint
number.
In sequential mode, the Trace (T), Program Step (P), and Go (G) com
mands show registers in the same format as the Register command.
■ Examples
>s&
mixed
>R
AX=0005 BX=299E CX=OOCO DX=0OO0 SP=3800 BP=380E SI=O070 DI=40D1
DS=5067 ES=5067 SS=5067 CS=4684 IP=014F NV UP EI PL NZ NA PO NC
3 5 : VA R I A N = ( N * S U M X S Q - S U M X * * 2 ) / ( N - l )
4684:014F 8B5E06 MOV BX.Word Ptr [BP+06] ;BR1 SS:3814=299E
>
151
pcjs.org
Microsoft CodeView and Utilities
The example above displays all register and flag values, as well as the
instruction at the address pointed to by the CS and B? registers. Because
the mode has been set to mixed (S&), the current source line is also
shown. The example is from a FORTRAN program, but applies equally
well to BASIC and C programs.
>s-
assembly
>R
AX=CO05 BX=299E CX=OOCO DX=OOO0 SP=3800 BP=380E SI=CO70 DI=40D1
DS=5067 ES=5067 SS=5067 CS=4684 IP=014F NV UP EI PL NZ NA PO NC
4684:014F 8B5E06 MOV BX,Word Ptr [BP+06] ;BR1 SS:3814=299E
>
The 8087 command dumps the contents of the 8087 registers. If you do not
have an 8087 or 80287 coprocessor chip on your system, then this com
mand will dump the contents of the pseudoregisters created by the
compiler's emulator routines. This command is useful only if you have an
8087 or 80287 chip installed, or if your executable file includes math rou
tines from a Microsoft 8087-emulator library.
Note
This section does not attempt to explain how the registers of the Intel
8087 and 80287 processors are organized or how they work. In order to
interpret the command output, you must learn about the chip from an
Intel reference manual or other book on the subject. Since the Micro
soft emulator routines mimic the behavior of the 8087 coprocessor,
these references will apply to emulator routines as well as to the chips
themselves.
■ Mouse
152
pcjs.org
Examining Data and Expressions
■ Keyboard
■ Dialog
To display the status of the 8087 or 80287 chip (or floating-point emulator
routines) with a dialog command, enter a command line with the following
syntax:
The current status of the chip is displayed when you enter the command.
In window mode, the output is to the dialog window. If you do not have an
8087 or 80287 chip, and are not linking to an emulator library, then the
debugger will report the error message floating point not loaded.
The following example shows a display for a machine that actually has an
8087 or 80287 chip. The example at the end of the section shows the same
display for a machine using an emulator library instead of an actual math
coprocessor.
■ 8087 Example
>7
cControl 037F (Projective closure, Round nearest, 64-bit precision)
iem=0 pm=l um=l om=l zm=l dm=l im=l
cStatus 6004 cond=10O0 top=4 pe=0 ue=0 oe=0 ze=l de=0 ie=0
Ta g A 1 F F i n s t r u c t i o n = 5 9 3 8 0 o p e r a n d = 5 9 3 6 0 o p c o d e = D 9 E E
Stack Exp Mantissa Va l u e
cST(3) special 7FFF 8C>OOOCKXXXXXXXXX) = + Infinity
cST(2) special 7FFF OIOIOIOIOIOIOIOI = + Not a Number
cST(l) valid 4000 C90FDAA22168C235 = +3.141592265110390E+0OO
cST(O) zero 0000 OOOOOOOOOOOOOOOO = +0.0O0O00OOO0O0OO0E+0O0
>
In the example above, the first line of the dump shows the current closure
method, rounding method, and the precision. The number 037F is the
hexadecimal value in the control register. The rest of the line interprets
the bits of the number. The closure method can be either projective (as in
the example) or affine. The rounding method can be either rounding to the
nearest even number (as in the example), rounding down, rounding up, or
using the chop method of rounding (truncating toward zero). The preci
sion may be 64 bits (as in the example), 53 bits, or 24 bits.
The second line of the display indicates whether each exception mask bit is
set or cleared. The masks are interrupt-enable mask (iem), precision mask
153
pcjs.org
Microsoft CodeView and Utilities
(pm), underflow mask (urn), overflow mask (om), zero-divide mask (zm),
denormalized-operand mask (dm), and invalid-operation mask (im).
The third line of the display shows the hexadecimal value of the status
register (6004 in the example), and then interprets the bits of the register.
The condition code (cond) in the example is the binary number 1000. The
top of the stack (top) is register 4 (shown in decimal). The other bits
shown are precision exception (pe), underflow exception (ue), overflow
exception (oe), zero-divide exception (ze), denormalized-operand excep
tion (de), and invalid-operation exception (ie).
The fourth line of the display first shows the hexadecimal value of the tag
register (A1FF in the example). It then gives the hexadecimal values of the
instruction (59380), the operand (59360), and the operation code, or
opcode, (D9EE).
The fifth line is a heading for the subsequent lines, which contain the con
tents of each 8087 or 80287 stack register. The registers in the example
contain four types of numbers that may be held in these registers. Starting
from the bottom, register 0 contains zero. Register 1 contains a valid real
number. Its exponent (in hexadecimal) is 4000 and its mantissa is
C90FDAA22168C235. The number is shown in scientific notation in the
rightmost column. Register 2 contains a value that cannot be interpreted
as a number, and register 3 contains infinity.
The c that precedes Control, Status, and each of the ST listings indi
cates that an actual math-coprocessor chip is in use. If emulator routines
were in use instead of a chip, then each c prefix would be replaced by e, as
in the next example.
>7
eControl 037F (Projective closure, Round nearest, 64-bit precision)
iem=0 pm=l um=l om=l zm=l dm=l im=l
eStatus 6004 cond=1000 top=4 pe=0 ue=0 oe=0 ze=l de=0 ie=0
Ta g A 1 F F i n s t r u c t i o n = 5 9 3 8 0 o p e r a n d = 5 9 3 6 0 o p c o d e = D 9 E E
Stack Exp Mantissa Va l u e
eST(3) special 7FFF 8000000000000000 = + Infinity
eST(2) special 7FFF 0101010101010101 = + Not a Number
eST(l) valid 4000 C90FDAA22168C235 = +3.141592265110390E+0O0
eST(O) zero 0000 OOOOOOCOOOOOOOOO = +0.0000000000O0000E+000
>
Note the e at the beginning of the first, third, sixth, seventh, eighth, and
ninth lines. Aside from this replacement of the c prefix by e, the emulator
display is the same as the corresponding display for an 8087 chip.
154
pcjs.org
Chapter/ 7
MANAGING BREAKPOINTS
7.1 Breakpoint Set Command 157
7.2 Breakpoint Clear Command 160
7.3 Breakpoint Disable Command 161
7.4 Breakpoint Enable Command 162
7.5 Breakpoint List Command 164
pcjs.org
Managing Breakpoints
Command Action
157
pcjs.org
Microsoft CodeView and Utilities
Mouse
To set a breakpoint with the mouse, point to the source line or instruction
where you want to set the breakpoint, and then click the left button. The
line will be displayed in high-intensity text, and will remain so until you
remove or disable the breakpoint.
■ Keyboard
■ Dialog
158
pcjs.org
Managing Breakpoints
■ Examples
>BP .19 10
>
The example above first sets the mode to assembly, and then creates a
breakpoint at the hexadecimal (offset) address #0A94 in the default (CS)
159
pcjs.org
Microsoft CodeView and Utilities
■ Mouse
To clear a single breakpoint with the mouse, point to the breakpoint line
or instruction you want to clear. Breakpoint lines are shown in high-
intensity text. Press the left mouse button. The line will be shown in nor
mal text to indicate that the breakpoint has been removed.
To remove all breakpoints with the mouse, point to Run on the menu bar,
press a mouse button and drag the highlight down to the Clear Break
points selection, and then release the button.
■ Keyboard
■ Dialog
BC list
BC*
If list is specified, the command removes the breakpoints named in the list.
The list can be any combination of integer values from 0 to 19. You can
160
pcjs.org
Managing Breakpoints
use the Breakpoint List command (BL) if you need to see the numbers for
each existing breakpoint. If an asterisk (*) is given as the argument all
breakpoints are removed.
■ Examples
>BC 0 4 8
>
>BC *
>
Note
All disabled breakpoints are automatically enabled whenever you
restart the program being debugged. The program can be restarted
with the Start or Restart selection from the Run menu, or with the
Restart dialog command (L). See Chapter 5, "Executing Code."
■ Mouse
■ Keyboard
161
pcjs.org
Microsoft CodeView and Utilities
■ Dialog
BD list
BD*
If list is specified, the command disables the breakpoints named in the list.
The list can be any combination of integer values from 0 to 19. Use the
Breakpoint List command (BL) if you need to see the numbers for each
existing breakpoint. If an asterisk (*) is given as the argument, all break
points are disabled.
The window commands for setting and clearing breakpoints can also be
used to enable or clear disabled breakpoints.
■ Examples
>BD 0 4 8
>
>BD *
>
■ Mouse
To enable a disabled breakpoint with the mouse, point to the source line
or instruction of the breakpoint, and then click the left button. The line
162
pcjs.org
Managing Breakpoints
■ Keyboard
■ Dialog
■ Examples
>BE 0 4 8
>
>BE*
>
163
pcjs.org
Microsoft CodeView and Utilities
The Breakpoint List command (BL) lists current information about all
breakpoints.
■ Mouse
■ Keyboard
■ Dialog
The command displays the breakpoint number, the enabled status (e for
"enabled", d for "disabled"), the address, the routine, and the line
number. If the breakpoint does not fall on a line number, an offset is
shown from the nearest previous line number. The pass count and break
commands are shown if they have been set. If no breakpoints are currently
defined, nothing is displayed.
■ Example
>BL
0 e 5 6 C 4 : 0 1 0 5 _ A R C TA N : 1 0
1 d 5 6 C 4 : 0 11 E _ A R C TA N : 1 9 (pass = 10) " T; T "
2 e 56C4:00FD _ARCTAN:9+6
>
164
pcjs.org
Managing Breakpoints
will not be taken until the 10th time it is encountered. The command
string at the end of the line indicates that each time the breakpoint is
taken, the Trace command will automatically be executed twice.
The line number for breakpoint 2 has an offset. The address is six bytes
beyond the address for line 9 in the current source file. Therefore, the
breakpoint was probably set in assembly mode, since it would be difficult
to set a breakpoint anywhere except on a source line in source mode.
165
pcjs.org
Chapter
MANAGING
WATCH STATEMENTS
8.1 Setting Watch-Expression
a n d Wa t c h - M e m o r y S t a t e m e n t s 170
8.2 Setting Watchpoints 174
8.3 Setting Tracepoints 177
8.4 Deleting Watch Statements 181
8.5 Listing Watchpoints and Tracepoints 183
8.6 C Examples 184
8.7 FORTRAN Examples 185
8.8 Pascal Examples 186
8.9 Assembly Examples 187
pcjs.org
Managing Watch Statements
Note
Syntax for each CodeView command is always the same, regardless of
the expression evaluator; however, the method for specifying an
argument may vary with the language. Therefore, each example in this
chapter is repeated with C, FORTRAN, BASIC, and Pascal arguments.
The sample screens throughout the text that present these examples
feature BASIC. At the end of this chapter are C, FORTRAN, and Pas
cal sample screens, each of which incorporates all the previous exam
ples (except for Watch Delete and Watch List).
Command Action
169
pcjs.org
Microsoft CodeView and Utilities
Note
In order to set a watch statement containing a local variable, you must
be in the function where the variable is defined. If the current line is
not in the function, the CodeView debugger displays the message
UNKNOWN SYMBOL. When you exit from a function containing a local
variable referenced in a watch statement, the value of the statement is
displayed as UNKNOWN SYMBOL. When you reenter the function, the
local variable will again have a value. With the C and FORTRAN
expression evaluators, you can avoid this limitation by using the
period operator to specify both the function and the variable. For
example, enter main.x instead of just x.
170
pcjs.org
Managing Watch Statements
Note
If your program directly accesses absolute addresses used by IBM or
IBM-compatible computers, you may sometimes get unexpected results
with the Display Expression and Dump commands. However, the
Watch command will usually show the correct values. This problem
can arise if the CodeView debugger and your program begin to use the
same memory location.
The problem often occurs when a program reads data directly from the
screen buffer of the display adapter. If you have an array called
screen that is initialized to the starting address of the screen buffer,
the command DB screen L 16 will display data from the CodeView
display rather than from the display of the program you are debug
ging. The command WB screen L 16 will display data from the
program's display (provided screen swapping or screen flipping was
specified at start-up). The Watch command behaves differently from
the Dump command because watch-statement values are updated dur
ing program execution, and any values read from the screen buffer will
be taken from the output screen rather than from the debugging
screen.
■ Mouse
You cannot use the mouse version of the command to specify a range of
memory to be watched, as you can with the dialog version.
■ Keyboard
171
pcjs.org
Microsoft CodeView and Utilities
■ Dialog
S p e c i fi e r S i z e
None Default type
B Byte
A ASCII
I Integer (signed decimal word)
U Unsigned (unsigned decimal word)
W Word
D Double word
S Short real
L Long real
T 10-byte real
If no type size is specified, the default type used is the last type used by a
Dump, Enter, Watch Memory, or Tracepoint Memory command. If none of
these commands has been used during the session, the default type is byte.
The data will be displayed in a format similar to that used by the Dump
commands (see Section 6.1, "Display Expression Command," for more
information on format arguments). The range can be any length, but only
one line of data will be displayed in the watch window. If you do not
specify an ending address for the range, the default range is one object.
■ Examples
pcjs.org
Managing Watch Statements
W? n
W? higher * 100
The example above displays the value of the expression higher * 100.
WL chance
File View Search Run Natch Options Language Calls Help I F8=Trace F5=Go
DICE,BAS
0) n : 4
1) higher* 108 : 33,33333333333333
2) chance : 55FFH79A 55 55 55 55 55 55 B5 3F +8,333333333333E-0
5
3 PRINT str2$;higher *
6
3 ID IF
37 i
38 win : sum
35 lose : 1,0 - win
43.
41:
>y? n
>U? higher *
>ULchance
_
>
173
pcjs.org
Microsoft CodeView and Utilities
■ Mouse
■ Keyboard
174
pcjs.org
Managing Watch Statements
■ Dialog
WP? expression{,format}
■ Examples
Note
BASIC and C will each display a numerical result in response to a
Boolean expression (0 being equivalent to false, nonzero to true). How
ever, the corresponding FORTRAN condition will be displayed with
either .TRUE, or .FALSE, in the watch window. Pascal will display
TRUE or FALSE.
175
pcjs.org
Microsoft CodeView and Utilities
PRINT str2S;higher * 10
3b: IF
37: NEXTn
38; wni = sum
39' lose : 1,0 wn
i
40: ENDSUE
41:
42;
Wl?higher
higher >) chance
ch
>UF? n:7 or n=ll
Note
Setting watchpoints significantly slows execution of the program being
debugged. The CodeView debugger checks if the expression is true
each time a source line is executed in source mode, or each time an
instruction is executed in assembly mode. Be careful when setting
watchpoints near large or nested loops. A loop that executes almost
instantly when run from MS-DOS can take many minutes if executed
from within the debugger with several watchpoints set.
Tracepoints do not slow CodeView execution as much as watchpoints,
so you should use tracepoints when possible. For example, although
you can set a watchpoint on a Boolean variable (WP? moving), a
tracepoint on the same variable (TP? moving) has essentially the
same effect and does not slow execution as much.
If you enter a seemingly endless loop, press CONTROL+BREAK or
CONTROL+C to exit. You will soon learn the size of loop you can safely
execute when watchpoints are set.
176
pcjs.org
Managing Watch Statements
Note
The following is relevant only to C programs.
Register variables are not considered lvalues. Therefore, if i is
declared as register int i, the command TP? i is invalid. How
ever, you can still check for changes in the value of i. Use the Examine
Symbols command to learn which register contains the value of i.
177
pcjs.org
Microsoft CodeView and Utilities
>X? i
3A79:0264 int div()
SI int i
>?i
10
>WP? @SI!=10
>
When setting a tracepoint expression, you can specify the format in which
the value will be displayed. Type the expression followed by a comma and
a type specifier. If you do not give a type specifier, the CodeView debugger
displays the value in a default format. See Section 6.1, "Display Expression
Command," for more information about type specifiers and the default
format.
■ Mouse
You cannot specify a range of memory to be watched with the mouse ver
sion of the command, as you can with the dialog version.
■ Keyboard
■ Dialog
178
pcjs.org
Managing Watch Statements
Although no more than one line of data will be displayed in the watch win
dow, the range to be checked for change can be any size up to 128 bytes.
The data will be displayed in the format used by the Dump commands (see
Section 6.1, "Display Expression Command," for more information on for
mat arguments). The valid memory-size specifiers are listed below:
S p e c i fi e r S i z e
None Default type
B Byte
A ASCII
I Integer (signed decimal word)
U Unsigned (unsigned decimal word)
w Word
D Double word
S Short real
L Long real
T 10-byte real
The default type used if no type size is specified is the last type used by a
Dump, Enter, Watch Memory, or Tracepoint Memory command. If none of
these commands has been used during the session, the default type is byte.
179
pcjs.org
Microsoft CodeView and Utilities
■ Examples
TP? sum
TPB n
File View Search Run Natch Options Language Calls Help I F8=Trace F5=Go
I DICE.BAS 1 =
B) sun : B.
1) 55FFH798 04 .
ELSEIF n=7 OR n=ii
sum = sum t polKn
ELSE
chance : roll(n)
uglier = male(n)
strlJjn,
PRINT str2$; higher*
IF
>TF^ su
>TPBn
180
pcjs.org
Managing Watch Statements
Note
Setting tracepoints significantly slows execution of the program being
debugged. The CodeView debugger has to check to see if the expres
sion or memory range has changed each time a source line is executed
in source mode or each time an instruction is executed in assembly
mode. However, tracepoints do not slow execution as much as do
watchpoints.
Be careful when setting tracepoints near large or nested loops. A loop
that executes almost instantly when run from the MS-DOS operating
system can take many minutes if executed from within the debugger
with several tracepoints set. If you enter a seemingly endless loop,
press CONTROL+BREAK or CONTROL+C to exit. Often you can tell how
far you went in the loop by the value of the tracepoint when you
exited.
The Watch Delete command enables you to delete watch statements that
were set previously with the Watch, Watchpoint, or Tracepoint command.
When you delete a watch statement in window mode, the statement disap
pears and the watch window closes around it. For example, if there are
three watch statements in the window and you delete statement 1, the
window is redrawn with one less line. Statement 0 remains unchanged, but
statement 2 becomes statement 1. If there is only one statement, the win
dow disappears.
■ Mouse
To delete a watch statement with the mouse, point to Watch on the menu
bar, press a mouse button and drag the highlight down to the Delete
Watch selection, and then release the button. A dialog box appears, con
taining all the watch statements. Point to the statement you want to
delete and press the ENTER key or a mouse button. The dialog box disap
pears, and the watch window is redrawn without the watch statement.
You can also delete all the statements in the watch window at once, sim
ply by selecting the Delete All selection.
181
pcjs.org
Microsoft CodeView and Utilities
■ Keyboard
You can also delete all the statements in the watch window at once, sim
ply by selecting the Delete All selection. Do this by pressing L (upppercase
or lowercase) after the Watch menu is open.
■ Dialog
Y number
You can delete existing watch statements by specifying the number of the
statement you want to delete with the Delete Watch command. (The Y is
a mnemonic for "yank.")
You can use the asterisk (*) to represent all watch statements.
Examples
>Y 2
>
>Y *
>
The command above deletes all watch statements and closes the watch
window.
182
pcjs.org
Managing Watch Statements
The Watch List command lists all previously set watchpoints and trace-
points with their assigned numbers and their current values.
■ Mouse
■ Keyboard
■ Dialog
The display is the same as the display that appears in the watch window
in window mode.
■ Example
>W
0) code,c : I
1) ( fl o a t ) l e t t e r s / w o r d s , f : 4 . 7 7 7 7 7 8
2) 3F65:0B20 20 20 43 4F 55 4E 54 COUNT
3) lines==ll : 0
>
Note
The command letter for the Watch List command is the same as the
command letter for the memory version of the Watch command when
no memory size is given. The difference between the commands is that
the Watch List command never takes an argument. The Watch com
mand always requires at least one argument.
183
pcjs.org
Microsoft CodeView and Utilities
8.6 C Examples
File (Mew Search Run Match Options Language Calls Help I F3=Trace F5:Go
I dice,C I " =
@) n : 4
1) higher* 103 : 33,33333333333333
2) chance : 5958:115A 55 55 55 55 55 55 B5 3F +3,333333333333E-
3) higher1 > chance ! 1
4) n:=7 !! n::li : 9
5) sum :
6) 595811172 04
: sum t roll(n)
else {
chance = roll(n);
'ligher z make(n)'
print
>U?n
>U? higher * 100
}IJL chance
>UP? higher > chance
W? n==7 !! n==ii
>TP?sum
>TPBn
The first three items in the watch window are simple watch statements.
They display values but never cause execution to break.
The next two items are watchpoints; they cause execution to break when
ever they evaluate to true (nonzero). The fourth item will break execution
whenever higher is greater than chance, and the fifth item will break
execution whenever n is equal to 7 or 11.
The last two items are tracepoints, which cause execution to break when
ever any bytes change within a specified area of memory. The sixth item
breaks execution whenever the value of sum changes; the seventh item
breaks execution whenever there is a change in the first byte at the
address of n.
184
pcjs.org
Managing Watch Statements
File Uiew Search Run Natch Options Language Calls Help | F3=Trace F5=Go
=| dice, for I =
0) n : 4
1) higher* 108 : 33,33333333333333
2) chance : 5B43:0AF8 55 55 55 55 55 55 E5 3F +8,3333333333331-802
3) higher ,gt. chance ! .TRUE,
4) n.eq.7 .or. n.ej.ll : .FALSE.
5) sun I
6) 5B43:BAF4 84
The first three items in the watch window are simple watch statements.
They display values but never cause execution to break.
The next two items are watchpoints; they cause execution to break when
ever they evaluate to true (nonzero). The fourth item will break execution
whenever higher is greater than chance, and the fifth item will break
execution whenever n is equal to 7 or 11.
The last two items are tracepoints, which cause execution to break when
ever any bytes change within a specified area of memory. The sixth item
breaks execution whenever the value of sum changes; the seventh item
breaks execution whenever there is a change in the first byte at the
address of n.
185
pcjs.org
Microsoft CodeView and Utilities
File Uiew Search Run Hatch Options Language Calls Help | F8=Trace F5=Go
0.) n : 4
1) higher * 100 : 33,333333333333
2) chance : 3071:1156 55 55 55 55 55 55 E5 3F +3,333333333333E-902
3) higher > chance : IRUE
4) (n=7) or (n=ll) : FALSE
5) sun ; 8,88888888888800
6) 8071U16E 84 .
30: sum ! = sum + roll(n)
31: else loegin
32:
331
chance
higher !=
i: roll(n);
make(n); 1
Tkijill IC4i|i[llHfcl>liiMMWi"if''TJIt!SiitFitTJ<yiNBi ^H
351 writelnfstrl, ' ', n)i
mi n
>U? higher * 100
>UIL chance
>ijJF? higher ) chance
Wi (n=7) or (n=ll)
>TF^ sum
>TPBn
The first three items in the watch window are simple watch statements.
They display values but never cause execution to break.
The next two items are watchpoints; they cause execution to break when
ever they evaluate to true (nonzero). The fourth item will break execution
whenever higher is greater than chance, and the fifth item will break
execution whenever n is equal to 7 or 11.
The last two items are tracepoints, which cause execution to break when
ever any bytes change within a specified area of memory. The sixth item
breaks execution whenever the value of sum changes; the seventh item
breaks execution whenever there is a change in the first byte at the
address of n.
186
pcjs.org
Managing Watch Statements
■ Examples
>WW sp L 8
>WW bp L 8
>W? wo bp+4,d
>W? by bp-2,d
>TPW arr L 5
>
The first two examples watch a range of memory. The watch command WW
sp L 8 is particularly useful because it will cause the debugger to watch
the stack dynamically; the debugger will continually display the first eight
words on the top of the stack as items are pushed and popped. The expres
sion WW bp L 8 is similar; it causes the debugger to watch the first eight
words in memory pointed to by BP (the framepointer).
The third example, W? wo bp+4, d, is useful if you are using the stack to
pass parameters. In this case, the position on the stack four bytes above
BP holds one of three integer parameters. The WO operator returns the
same value as the assembler expression WORD PTR [bp+4] ; the result is
displayed in decimal.
You must use the expression bp+4 in order to watch this parameter; you
cannot specify a parameter by name. The assembler does not emit sym
bolic information for parameters. The fourth command, W? by bp-2, d,
is similar to the third, but instead of watching a parameter, this command
watches a local variable. The operator BY returns the same value as the
assembler expression BYTE PTR [bp-2].
187
pcjs.org
Microsoft CodeView and Utilities
The five examples above produce the following screen, when entered in a
CodeView debugging session:
File View Search Run Match .Options Language Calls Help I F8=Trace F5=Go
1 tKilnMOII r
AX : 001B
0) sp L 8 : 531C:09A2 0044 09B4 0037 0005 000F 001B 000F 0005
BX : 09A2
1) bp L 8 ; 531C109A4 09B4 0037 0005 000F 001B 000F 0005 001B
2) wo kp+4,d ; 5 CX : 0044
3) ky bp-2,d : 68 DX : S0B0
4) 53IF:N06 81 88 82 88 83 SP : 09A2
BP : 09A4
701 ; First parameter largest j SI : 0098
71! ; DI : 0A8C
72: mov BYTE PTR [kp-21,1 J Load indicator value DS : 531C
73: J of 1 into local v a r i a k l ES : 531C
74: jmp SHORT finished ] and finish up SS : 531C
75: next test: CS : 52D7
76: mov ax,[kp+8] j Load 3rd[warm into ax IP : 005D
78: jle last test ; go to last test nvUP
79: ; J EI NG
NZAC
>UUspL8 PECY
>yy kp l 8
>U? wo kp+4,d ss:
>y? ky kp-2,d
>TPB arr L 5
>.
J
Figure 8.7 Assembly Watch Statements
188
pcjs.org
Chapter< 9
F.XAMINING CODE
9.1 Set Mode Command 191
9.2 Unassemble Command 193
9.3 View Command 195
9.4 Current Location Command 198
9.5 Stack Trace Command 199
pcjs.org
Examining Code
Command Action
The Set Mode command sets the mode in which code is displayed. The two
basic display modes are source mode, in which the program is displayed as
source lines, and assembly mode, in which the program is displayed as
assembly-language instructions. These two modes can be combined in
mixed mode, in which the program is displayed with both source lines and
assembly-language instructions.
In sequential mode, there are three display modes: source, assembly, and
mixed. These modes affect the output of commands that display code
(Register, Trace, Program Step, Go, Execute, and Unassemble).
In window mode, these same display modes are available, but affect what
kind of code appears in the display window.
Source and mixed modes are only available if the executable file contains
symbols in the CodeView format. Programs that do not contain symbolic
information (including all .COM files) are displayed in assembly mode.
■ Mouse
To set the display mode with the mouse, point to View on the menu bar,
press a mouse button and drag the highlight to either the Source selection
for source mode, the Mixed selection for mixed mode, or the Assembly
selection for assembly mode. Then release the button.
191
pcjs.org
Microsoft CodeView and Utilities
■ Keyboard
To change the display mode with a keyboard command, press the F3 key.
This will rotate the mode to the next setting; you may need to press F3
twice to get the desired mode. This command works in either window or
sequential mode. In sequential mode, the word source, mixed, or
assembly is displayed to indicate the new mode.
■ Dialog
To set the display mode from the dialog window, enter a command line
with the following syntax:
si+l-l&l
If the plus sign is specified (S+), source mode is selected, and the word
source is displayed.
If the minus sign is specified (S-), assembly mode is selected, and the word
assembly is displayed. In window mode, the display will include any
assembly options, except the Mxed Source option, previously toggled on
from the Options menu. The Mixed Source option is always turned off by
the S— command.
If the ampersand is specified (S&), mixed mode is selected, and the word
mixed is displayed. In window mode, the display will include any assem
bly options previously toggled on from the Options menu. In addition, the
Mxed Source option will be turned on by the S& command.
■ Examples
>s+
source
>S-
assembly
>S&
mixed
>
192
pcjs.org
Examining Code
The examples above show the source mode being changed to source,
assembly, and mixed. In window mode, the commands change the for
mat of the display window. In sequential mode, the commands change the
output from the commands that display code (Register, Trace, Program
Step, Go, Execute, and Unassemble). See the sections on individual com
mands for examples of how they are affected by the display mode.
Note
Occasionally, code similar to the following will be displayed:
FE30 ??? Byte Ptr [BX + SI]
■ Mouse
The Unassemble command has no direct mouse equivalent, but you can
view unassembled code at any time by changing the mode to assembly or
mixed (see Section 9.1, "Set Mode Command," for more information).
■ Keyboard
The Unassemble command has no direct keyboard equivalent, but you can
view unassembled code at any time by changing the mode to assembly or
mixed (see Section 9.1, "Set Mode Command," for more information).
■ Dialog
The effect of the command varies depending on whether you are in sequen
tial or window mode.
In sequential mode, if you do not specify address or range, the disassem
bled code begins at the current unassemble address and shows the next
eight lines of instructions. The unassemble address is the address of the
instruction after the last instruction displayed by the previous Unassemble
command. If the Unassemble command has not been used during the ses
sion, the unassemble address is the current instruction.
If you specify an address, the disassembly starts at that address and shows
the next eight lines of instructions. If you specify a range, the instructions
within the range will be displayed.
The sequential mode format of the display depends on the current display
mode (see Section 9.1, "Set Mode Command," for more information). If
the mode is source (S+) or mixed (S&), the CodeView debugger displays
source lines mixed with unassembled instructions. One source line is shown
for each corresponding group of assembly-language instructions. If the
display mode is assembly, only assembly-language instructions are shown.
In window mode, the Unassemble command changes the mode of the
display window to assembly. The display format will reflect any options
previously set from the Options menu. There is no output to the dialog
window. If address is given, the instructions in the display window will
begin at the specified address. If range is given, only the starting address
will be used. If no argument is given, the debugger scrolls down and
displays the next screen of assembly-language instructions.
Note
The 80286 protected-mode mnemonics (also available with the 80386)
cannot be displayed with the Unassemble command.
■ Examples
>S£
mixed
>U Oxll
49DO:0011 35068E XOR AX, sqrtjmptab+8cd4 (8E06)
49DO:0014 189A2300 SBB Byte Ptr [BP+SI+0023],BL
49DO:0018 FC CLD
49DO:0019 49 DEC CX
49DO:001A CD351ED418 INT 3 5 ; F S T P D W o r d P t r [ f p i n i t + e e (18D4)]
49DO:001F CD3D INT 3D ;FWAIT
7: A = .0
0
49DO:O021 CD35EE INT 35 ;FLDZ
194
pcjs.org
Examining Code
The sequential mode example above sets the mode to mixed and unassem
bles eight lines of machine code, plus whatever source lines are encoun
tered within those lines. The display would be the same if the mode were
source.
>s-
assembly
>U Oxll
49DO:O011 3 5 0 6 8 E X O R A X s q r t j n p t a b + 8 c d 4 ( 8 E 0 6 )
4900:0014 189A230O SBB Byte Ptr [BP+SI+0023],BL
49DO:0018 FC CLD
49D0:0019 49 DEC CX
4 9 D 0 : 0 0 1 A C D 3 5 1 E D 4 1 8 I N T 3 5 ; F S T P D Wo r d P t r [ f p i n i t + e e ( 1 8 D 4 11
49D0:001F CD3D INT 3D ;FWAIT
4900:0021 CD35EE INT 35 ;FLDZ
>
The sequential mode example above sets the mode to assembly and repeats
the same command.
The View command displays the lines of a text file (usually a source
module or include file). It is most useful in sequential mode, where it is the
only method of examining a sequence of source lines. In window mode, the
View command can be used to page through the source file or to load a
new source file.
■ Mouse
To load a new source file with the button, point to File on the menu bar,
press a mouse button and drag the highlight to the Load selection, then
release the button. A dialog box appears, asking for the name of the file
you wish to load. Type the name of the file, and press the ENTER key or a
mouse button. The new file appears in the display window.
195
pcjs.org
Microsoft CodeView and Utilities
■ Keyboard
To load a new source file with a keyboard command, press ALT+F to open
the File menu, then press L to select Load. A dialog box appears, asking
for the name of the file you wish to load. Type the name of the file, and
press the ENTER key. The new file appears in the display window.
The paging capabilities of the View command have no direct keyboard
equivalent, but you can move about in the source file by first putting the
cursor in the display window with the F6 key, then pressing the PGUP,
PGDN, HOME, END, UP ARROW, and DOWN ARROW keys. See Section 2.1.1.3,
"Controlling Program Execution with Keyboard Commands," for more
information.
■ Dialog
Since addresses for the View command are often specified as a line number
(with an optional source file), a more specific syntax for the command
would be as follows:
V {.{filename:}linenumber}
196
pcjs.org
Examining Code
appear at the top of the source window. If you specify a filename with a
linenumber, the specified file will be loaded.
If you enter the View command with no arguments, the display will scroll
down one line short of a page; that is, the source line that was at the bot
tom of the window will be at the top.
Note
The View command with no argument is similar to pressing the PGDN
key, or clicking right on the down arrow with the mouse. The
difference is that pressing the PGDN key enables you to scroll down one
more line.
■ Examples
Example 2 loads the source file math.c and displays eight source lines
starting at line 30.
All forms of the View command are supported with all languages that
work with the CodeView debugger.
197
pcjs.org
Microsoft CodeView and Utilities
■ Mouse
The Current Location command cannot be executed with the mouse.
■ Keyboard
■ Dialog
To display the current location line using a dialog command, enter a com
mand line with the following syntax (a period only):
In sequential mode, the command displays the current source line. The line
is displayed regardless of whether the current debugging mode is source or
assembly. If the program being debugged has no symbolic information, the
command will be ignored.
In window mode, the command puts the current program location (marked
with reverse video or a contrasting color) in the center of the display win
dow. The display mode (source or assembly) will not be affected. This com
mand is useful if you have scrolled through the source code or assembly-
language instructions so that the current location line is no longer visible.
For example, if you are in window mode and have executed the program
being debugged to somewhere near the start of the program, but you have
scrolled the display to a point near the end, the Current Location com
mand returns the display to the current program location.
■ Example
>.
MINDAT = 1.0E6
The example above illustrates how to display the current source line in
sequential mode. The same command in window mode would not produce
198
pcjs.org
Examining Code
any output, but it could change the text that is shown in the display
window.
The Stack Trace command allows you to display routines that have been
called during program execution (see note below). The first line of the
display shows the name of the current routine. The succeeding lines (if
any) list any other routines that were called to reach the current address.
The dialog version of the Stack Trace command also displays the source
lines where each routine was called.
For each routine, the values of any arguments are shown in parentheses
after the routine name. Values are shown in the current radix (the default
is decimal).
The term "stack trace" is used because, as each routine is called, its
address and arguments are stored on (pushed onto) the program stack.
Therefore, tracing through the stack shows the currently active routines.
With C and FORTRAN programs, the main routine will always be at the
bottom of the stack. With BASIC programs, the main program is not
listed on the stack, because BASIC programs have no standard label (such
as main) corresponding to the first line of a program. Only routines called
by the main program will be displayed. In assembly-language programs,
the bottom routine displayed in the stack trace is astart instead of main.
Note
This discussion uses the term "routines," which is a general term for
functions (C, FORTRAN, Pascal), subroutines (FORTRAN), pro
cedures (Pascal), and subprograms and function procedures
(BASIC)-each of which uses the stack to transfer control to an
independent program unit. In assembly mode, the term "procedure"
may be more accurate. GOSUB and DEF FN routines in BASIC will
not work with the Stack Trace command, since they do not follow the
same convention for setting up the stack.
If you are using the CodeView debugger to debug assembly-language
programs, the Stack Trace command will work only if procedures were
called with the calling convention used by Mcrosoft languages. This
calling convention is explained in the Microsoft Mixed-Language Pro
gramming Guide.
199
pcjs.org
Microsoft CodeView and Utilities
Mouse
To view a stack trace with the mouse, point to Calls on the menu bar and
press a mouse button. The Calls menu will appear, showing the current
routine at the top and other routines below it in the reverse order in which
they were called; for example, the first routine called (which is always
main in a C or FORTRAN program) will be at the bottom. The values of
any routine arguments will be shown in parentheses following the routines.
If you want to view one of the routines that was previously called, select
the routine by dragging down the highlight to the routine you wish to see,
then releasing the mouse button. (You can also select a routine by clicking
a selection, once the menu is open.) The effect of selecting a routine in the
Calls menu is to cause the debugger to display that routine. The cursor
will be on the last statement that was executed in the routine.
■ Keyboard
To view a stack trace with a keyboard command, press ALT+C to open the
Calls menu. The menu will show the current routine at the top, and other
routines below it in the reverse order in which they were called; for exam
ple, the first routine called will be at the bottom. The values of any rou
tine arguments will be shown in parentheses following the routine.
If you want to view one of the routines that was previously called, select
the routine by moving the cursor with the arrow keys and then pressing
ENTER, or by typing the number or letter to the left of the routine. The
effect of selecting a routine in the Calls menu is to cause the debugger to
display that routine. The cursor will be on the last statement that was
executed in the routine.
■ Dialog
The output from the Stack Trace dialog command lists the routines in the
reverse order in which they were called. The arguments to each routine are
shown in parentheses. Finally, the line number from which the routine was
called is shown.
You can enter the line number as an argument to the View or Unassemble
command if you want to view code at the point where the routine was
called.
200
pcjs.org
Examining Code
In window mode, the output from the Stack Trace dialog command
appears in the dialog window.
FORTRAN Example
>K
ANALYZE(67,0), line 94
COUNTWORDS(0,512), line 73
MAIN(2,5098), line 42
In the example above, the first line of output indicates that the current
routine is ANALYZE. Its first argument currently has a decimal value of
67, and its second argument has a value of 0. The current location in this
routine is line 94.
The second line indicates that ANALYZE was called by COUNTWORDS, and
that its arguments have the values 0 and 512. Routine ANALYZE was
called from line 73 of routine COUNTWORDS.
Likewise, COUNTWORDS was called from line 42 of MAIN, and its argu
ments have the values 2 and 5098.
If the radix had been set to 16 or 8 using the Radix (N) command, the
arguments would be shown in that radix. For example, the last line would
be shown as MAIN (2,13ea) in hexadecimal or MAIN (2, 11752) in octal.
■ C Example
>K
analyze(67,0), line 94
countwords(0,512), line 73
main(2,5098)
>
As with the FORTRAN example, the example above shows the routines on
the stack in the reverse order in which they were called. Since analyze is
on the top, it has been called most recently; in other words, it is the
current routine.
Each routine is shown with the arguments it was passed, along with the
last source line that it had been executing. Note that main is shown with
the command line arguments argc (which is equal to 2) and argv (which
is a pointer equal to 5098 decimal). Since the language is C, main will
always be on the bottom of the stack.
201
pcjs.org
Microsoft CodeView and Utilities
■ BASIC Example
>K
ROLL#(19122:6040)
MAKE#(19122:6040)
CALC(19122:5982, 19122:5990)
>
As with the FORTRAN example, the example above shows the routines on
the stack in the reverse order in which they were called. Since R0LL# is on
the top, it has been called most recently; in other words, it is the current
routine.
202
pcjs.org
Chapter
MODIFYING CODE OR DATA
10.1 Assemble Command 205
10.2 Enter Commands 209
10.2.1 Enter Command 212
10.2.2 Enter Bytes Command 212
10.2.3 Enter ASCII Command 213
10.2.4 Enter Integers Command 214
10.2.5 Enter Unsigned Integers Command 214
10.2.6 Enter Words Command 215
1 0 . 2 . 7 E n t e r D o u b l e Wo r d s C o m m a n d 2 1 6
10.2.8 Enter Short Reals Command 217
10.2.9 Enter Long Reals Command 217
10.2.10 Enter 10-Byte Reals Command 218
10.3 Fill Memory Command 219
10.4 Move Memory Command 220
10.5 Port Output Command 221
10.6 Register Command 222
pcjs.org
Modifying Code or Data
Command Action
A s s e m b l e ( A ) M o d i fi e s c o d e
E n t e r ( E ) M o d i fi e s m e m o r y, u s u a l l y d a t a
Register (R) Modifies registers and flags
Fill Memory (F) Fills a block of memory
Move Memory (M) Copies one block of memory to another
Port Output (O) Outputs a byte to a hardware port
These commands change code temporarily. You can use the alterations for
testing in the CodeView debugger, but you cannot save them or per
manently change the program. To make permanent changes, you must
modify the source code and recompile.
Note
The effects of the Assemble command are temporary. Any instructions
that you assemble are lost as soon as you exit the program.
The instructions you assemble are also lost when you restart the pro
gram with the Start or Restart command, because the original code is
reloaded on top of memory you may have altered.
To test the results of an Assemble command, you may need to manipu
late the IP register (and possibly the CS register) to the starting
address of the instructions you have assembled. If you do this, you
must use the Current Line command (.) to reset the debugger's inter
nal variables so that it will trace properly.
205
pcjs.org
Microsoft CodeView and Utilities
■ Mouse
■ Keyboard
■ Dialog
To assemble code using a dialog command, enter a command line with the
following syntax:
The assembly address is normally the current address (the address pointed
to by the CS and IP registers). However, when you use the Assemble com
mand, the assembly address is set to the address immediately following
the last assembled instruction. When you enter any command that exe
cutes code (Trace, Program Step, Go, or Execute), the assembly address is
reset to the current address.
When you type the Assemble command, the assembly address is displayed.
The CodeView debugger then waits for you to enter a new instruction in
the standard 8086-family instruction-mnemonic form. You can enter
instructions in uppercase, lowercase, or both.
To assemble a new instruction, type the desired mnemonic and press the
ENTER key. The CodeView debugger assembles the instruction into
memory and displays the next available address. Continue entering new
instructions until you have assembled all the instructions you want. To
conclude assembly and return to the CodeView prompt, press the ENTER
key only.
If an instruction you enter contains a syntax error, the debugger displays
the message " Syntax error, redisplays the current assembly address,
and waits for you to enter a correct instruction. The caret symbol in the
message will point to the first character the CodeView debugger could not
interpret.
206
pcjs.org
Modifying Code or Data
207
pcjs.org
Microsoft CodeView and Utilities
■ Example
>U #40 L 1
39B0:0040 89C3 MOV BX,AX
>A #40
39B0:0040 MOV CX,AX
39B0:0042
>U #40 L 1
39B0:0040 89C1 MOV CX,AX
You can modify a portion of code for testing, as in the example, but you
cannot save the modified program. You must modify your source code and
recompile.
208
pcjs.org
Modifying Code or Data
■ Mouse
■ Keyboard
■ Dialog
To enter data (or code) to memory with a dialog command, enter a com
mand line with the following syntax:
The type is a one-letter specifier that indicates the type of the data to be
entered. The address indicates where the data will be entered. If no seg
ment is given in the address, the data segment (DS) is assumed.
209
pcjs.org
Microsoft CodeView and Utilities
The list can consist of one or more expressions that evaluate to data of the
size specified by type (the expressions in the list are separated by spaces).
This data will be entered to memory at address. If one of the values in the
list is invalid, an error message will be displayed. The values preceding the
error are entered; values at and following the error are not entered.
The expressions in the list are evaluated in the current radix, regardless of
the size and type of data being entered. For example, if the radix is 10 and
you give the value 10 in a list with the Enter Words command, the decimal
value 10 will be entered even though word values are normally entered in
hexadecimal. This means that the Enter Words, Enter Integers, and Enter
Unsigned Integers commands are identical when used with the list method,
since two-byte data are being entered for each command.
If list is not given, the CodeView debugger will prompt for values to be
entered to memory. Values entered in response to prompts are accepted in
hexadecimal for the Enter Bytes, Enter ASCII, Enter Words, and Enter
Double Words commands. The Enter Integers command accepts signed
decimal integers, while the Enter Unsigned Integers command accepts
unsigned decimal integers. The Enter Short Reals, Enter Long Reals, and
Enter 10-Byte Reals commands accept decimal floating-point values.
■ Examples
>EW PLACE 16 32
The example above shows how to enter two word-sized values at the
address PLACE.
210
pcjs.org
Modifying Code or Data
>EW PLACE
3DA5:OB20 00F3._
>EW PLACE
3DA5:0B20 00F3.10_
You can then skip to the next value by pressing the SPACEBAR. The Code
View debugger responds by displaying the next value, as shown below:
>EW PLACE
>EW PLACE
3DA5:0B20 00F3.10 4F20.3O_
>EW PLACE
Assume you realize that the last value entered, 30, is incorrect. You really
wanted to enter 20. You could return to the previous value by typing a
backslash. The CodeView debugger starts a new line, starting with the
previous value. Note that the backslash is not echoed on the screen:
>EW PLACE
>EW PLACE
211
pcjs.org
Microsoft CodeView and Utilities
If this is the last value you want to enter, press the ENTER key to stop. The
CodeView prompt reappears, as shown below:
>EW PLACE
■ Syntax
E address {list}
The Enter command enters one or more values into memory at the
specified address. The data are entered in the format of the default type,
which is the last type specified with a Dump, Enter, Watch Memory, or
Tracepoint Memory command. If none of these commands has been
entered during the session, the default type is bytes.
Use this command with caution when entering values in the list format;
values will be truncated if you enter a word-sized value when the default
type is actually bytes. If you are not sure of the current default type,
specify the size in the command.
Important
The Execute command and the Enter command have the same com
mand letter (E). The difference is that the Execute command never
takes an argument; the Enter command always requires at least one
argument.
■ Syntax
EB address {list}
The Enter Bytes command enters one or more byte values into memory at
address. The optional list can be entered as a list of expressions separated
212
pcjs.org
Modifying Code or Data
by spaces. The expressions are evaluated and entered in the current radix.
If list is not given, the CodeView debugger prompts for new values, which
must be entered in hexadecimal.
The Enter Bytes command can also be used to enter strings, as described
in Section 10.2.3, "Enter ASCII Command."
■ Examples
>EB 256 10 20 30
>
If the current radix is 10, the above example replaces the three bytes at
DS:256, DS:257, and DS:258 with the decimal values 10, 20, and 30.
(These three bytes correspond to the hexadecimal addresses DS:0100,
DS:0101, and DS:0102.)
>EB 256
3DA5:0100 130F.A
>
■ Syntax
EA address {list}
The Enter ASCII command works in the same way as the Enter Bytes com
mand (EB) described in Section 10.2.2. The list version of this command
can be used to enter a string expression.
■ Example
You can also use the Enter Bytes command to enter a string expression, or
you can enter nonstring values using the Enter ASCII command.
213
pcjs.org
Microsoft CodeView and Utilities
■ Syntax
EI address {list}
The Enter Integers command enters one or more word values into memory
at address using the signed-integers format. With the CodeView debugger,
a signed integer can be any decimal integer between -32,768 and 32,767.
■ Examples
If the current radix is 10, the example above replaces the three integers at
DS:256, DS:258, and DS:260 with the decimal values -10, 10, and -20.
The three addresses correspond to the three hexadecimal addresses
8"SiOlOO, DS:0102, and DS:0104.)
>EI 256
3 D A 5 : 0 1 0 0 1 3 0 F. - 1 0
>
■ Syntax
EU address {list}
The Enter Unsigned Integers command enters one or more word values
into memory at address using the unsigned-integers format. With the
CodeView debugger, an unsigned integer can be any decimal integer
between 0 and 65,535.
214
pcjs.org
Modifying Code or Data
■ Examples
>EU 256 10 20 30
>
If the current radix is 10, the example above replaces the three unsigned
integers at DS:256, DS:258, and DS:260 with the decimal values 10, 20,
and 30. (These addresses correspond to the hexadecimal addresses
DS:0100,
"0, DS:C
DS:0102, and DS:0104.)
>EU 256
3DA5:0100 130F.10
>
■ Syntax
EW address {list}
The Enter Words command enters one or more word values into memory
at address.
The optional list list The expressions are entered and evaluated in the
current radix. If list is not given, the CodeView debugger prompts for new
values, which must be entered in hexadecimal.
■ Examples
>EW 256 10 20 30
>
If the current radix is 10, the example above replaces the three words at
DS:256, DS:258, and DS:260 with the decimal values 10, 20, and 30.
SThese
S:0102,addresses correspond to the hexadecimal addresses DS:0100,
and DS:0104.)
215
pcjs.org
Microsoft CodeView and Utilities
>EW 256
3DA5:0100 130F.A
>
■ Syntax
ED address {list}
The Enter Double Words command enters one or more double-word values
into memory at address. Double words are displayed and entered in the
segmenhoffset address format; that is, two words separated by a colon (:).
If the colon is omitted and only one word entered, only the offset portion
of the address will be changed.
■ Examples
If the current radix is 10, the example above replaces the double words at
DS:256 (DS:0100 hexadecimal) with the decimal address 8700 :12008
(hexadecimal address 21FC:2EE8).
>ED 256
3DA5:0100 21FC:2EE8.2EE9
>
The example above replaces the offset portion of the double word at
DS:256 (DS.OIOO hexadecimal) with 2EE9 hexadecimal. Since the segment
portion of the address is not provided, the existing segment (21FC hexade
cimal) is unchanged.
216
pcjs.org
Modifying Code or Data
■ Syntax
ES address {list}
The Enter Short Reals command enters one or more short-real values into
memory at address.
The optional list can be entered as a list of real numbers separated by
spaces. The numbers must be entered in decimal, regardless of the current
radix. If list is not given, the CodeView debugger prompts for new values,
which must be entered in decimal. Short-real numbers can be entered
either in floating-point format or in scientific-notation format.
■ Examples
The example above replaces the four numbers at DS:256, DS:260, DS:264,
and DS:268 with the real numbers 23.479, 0.25, -1650.0, and 235.0.
SThese
S:0104,addresses
DS:0108,correspond to the hexadecimal addresses DS:0100,
and DS:0112.)
>ES PI
3DA5:0064 42 79 74 65 7.215589E+022 3.141593
>
The example above replaces the number at the symbolic address PI with
3.141593.
■ Syntax
EL address {list}
The Enter Long Reals command enters one or more long-real values into
memory at address.
The optional list can be entered as a list of real numbers separated by
spaces. The numbers must be entered in decimal, regardless of the current
radix. If list is not given, the CodeView debugger prompts for new values,
217
pcjs.org
Microsoft CodeView and Utilities
■ Examples
The example above replaces the four numbers at DS:256, DS:264, DS:272,
and DS:280 with the real numbers 23.479, 0.25, -1650.0, and 235.0
SThese addresses
S:0108, DS:0110,correspond to the hexadecimal addresses DS:0100,
and DS:0118.)
>EL PI
3DA5:0064 42 79 74 65 DC OF 49 40 5.012391E+001 3.141593
>
The example above replaces the number at the symbolic address PI with
3.141593.
■ Syntax
ET address {list}
The Enter 10-Byte Reals command enters one or more 10-byte-real values
into memory at address.
■ Examples
The example above replaces the four numbers at DS:256, DS:266, DS:276,
and DS:286 with the real numbers 23.479, 0.25, -1650.0, and 235.0.
218
pcjs.org
Modifying Code or Data
>ET PI
3DA5:0064 42 79 74 65 DC OF 49 40 7F BD -3.292601E-193 3.141593
>
The example above replaces the number at the symbolic address PI with
3.141593.
■ Mouse
■ Keyboard
■ Dialog
To fill an area of memory with values you specify, enter the Fill Memory
command as follow:
F range list
The Fill Memory command fills the addresses in the specified range with
the byte values specified in list. The values in the list are repeated until
the whole range is filled. (Thus, if you specify only one value, the entire
range is filled with that same value.) If the list has more values than the
number of bytes in the range, then the command ignores any extra values.
219
pcjs.org
Microsoft CodeView and Utilities
■ Examples
The first example fills 255 (100 hexadecimal) bytes of memory starting at
DS:0100 with the value 0. This command might possibly be used to reini
tialize the program's data without having to restart the program.
The second example fills the 100 (64 hexadecimal) bytes starting at table
with the following hexadecimal byte values: 42, 79, 74. These three values
are repeated until all 100 bytes are filled.
The Move Memory command enables you to copy all the values in one
block of memory directly to another block of memory of the same size.
This command is of most interest to assembly programmers, but can be
used by anyone who wants to do large data transfers efficiently. For exam
ple, you can use this command to copy all the values in one array to the
elements of another.
■ Mouse
■ Keyboard
■ Dialog
To copy the values in one block of memory to another, enter the Move
Memory command with the following syntax:
M range address
The values in the block of memory specified by range are copied to a block
of the same size beginning at address. All data in range are guaranteed to
be copied completely over to the destination block, even if the two blocks
220
pcjs.org
Modifying Code or Data
■ Example
In the example above, the block of memory beginning with the first ele
ment of arrl, and arsize bytes long, is copied directly to a block of the
same size beginning at the address of the first element of arr2. In C, this
command would be entered as M arrl [0] L arsize arr2 [0] .
■ Mouse
■ Keyboard
■ Dialog
To output to a hardware port, enter the Port Output command with the
following syntax:
O port byte
The specified byte is sent to the specified port, in which port is a 16-bit
port address.
221
pcjs.org
Microsoft CodeView and Utilities
■ Example
The Port Output command is often used in conjunction with the Port
Input command, which is discussed in Section 6.6.
The Register command has two functions: it displays the contents of the
central processing unit registers, and it can also change the values of those
registers. The modification features of the command are explained in this
section. The display features of the Register command are explained in
Section 6.7.
■ Mouse
The only register that can be changed with the mouse is the flags register.
The register's individual bits (called flags) can be set or cleared. To change
a flag, first make sure the register window is open. The window can be
opened by selecting Registers from the Options menu or by pressing the
F2 key.
The flag values are shown as mnemonics in the bottom of the window.
Point to the flag you want to change and click either button. The
mnemonic word representing the flag value will change. The mnemonics
for each flag are shown in the third and fifth columns of Table 10.1. The
color or highlighting of the flag will also be reversed when you change a
flag. Set flags are shown in red on color monitors and in high-intensity text
on two-color monitors. Cleared flags are shown in light blue on color moni
tors or normal text on two-color monitors.
222
pcjs.org
Modifying Code or Data
■ Keyboard
■ Dialog
R {registername{{-} expression}}
To modify the value in a register, type the command letter R followed by
registername. The CodeView debugger displays the current value of the
register and prompts for a new value. Press the ENTER key if you only
want to examine the value. If you want to change it, type an expression for
the new value and press the ENTER key.
To change a flag value, supply the register name F when you enter the
Register command. The command displays the current value of each flag
as a two-letter name.
At the end of the list of values, the command displays a dash (-). Enter
new values after the dash for the flags you wish to change, then press the
ENTER key. You can enter flag values in any order. Flags for which new
values are not entered remain unchanged. If you do not want to change
any flags, simply press the ENTER key.
If you enter an illegal flag name, an error message will be displayed. The
flags preceding the error are changed; flags at and following the error are
not changed.
The flag values are shown in Table 10.1.
223
pcjs.org
Microsoft CodeView and Utilities
Table 10.1
Flag-Value Mnemonics
Overflow OV NV
Direction DN UP
Interrupt EI DI
Sign NG PL
Zero ZR NZ
Auxiliary icarry AC NA
Parity PE PO
Carry CY NC
■ Examples
>R IP 256
>
The example above changes the IP register to the value 256 (0100 hexade
cimal).
>R AX
AX 0E00
The example above displays the current value of the AX register and
prompts for a new value (the underscore represents the CodeView cursor).
You can now type any 16-bit value after the colon.
>R AX
AX 0E00
:256
>
The example above changes the value of AX to 256 (in the current radix).
>R F UP EI PL
The example above shows the command-line method of changing flag
values.
224
pcjs.org
Modifying Code or Data
>R F
NV(OV) UP(DN) EI(DI) PL (NG) NZ (ZR) AC (NA) PE (PO) NC (CY) -OV DI ZR
With the prompting method of changing flag values (shown above), the
first mnemonic for each flag is the current value, and the second mnemonic
(in parentheses) is the alternate value. You can enter one or more
mnemonics at the dash prompt. In the example, the command is given a
second time to show the results of the first command.
225
pcjs.org
ChapieE<
ITSING riODEVIEW
11
SYSTEM-CONTROL COMMANDS
11 . 1 Help Command 229
11 . 2 Quit Command 230
11 . 3 Radix Command 231
11 . 4 Redraw Command 233
11 . 5 S c r e e n E x c h a n g e C o m m a n d 233
11 . 6 Search Command 234
11 . 7 S h e l l E s c a p e C o m m a n d 237
11 . 8 Ta b Set Command 239
11 . 9 Option Command 240
11 . 1 0 R e d i r e c t i o n C o m m a n d s 242
11 . 1 0 . 1 R e d i r e c t i n g C o d e V i e w I n p u t 2 4 3
11 . 1 0 . 2 R e d i r e c t i n g C o d e V i e w O u t p u t 2 4 4
11.10.3 Redirecting CodeView Input and Output....245
11.10.4 Commands Used with Redirection 245
11 . 1 0 . 4 . 1 C o m m e n t C o m m a n d 2 4 6
11 . 1 0 . 4 . 2 D e l a y C o m m a n d 2 4 7
11 . 1 0 . 4 . 3 P a u s e C o m m a n d . * 2 4 8
pcjs.org
Using CodeView System-Control Commands
This chapter discusses commands that control the operation of the Code
View debugger. The commands in this category are listed below:
Command Action
The CodeView debugger has two help systems: a complete on-line-help sys
tem available only in window mode, and a syntax summary available with
sequential mode.
■ Mouse
To enter the complete on-line-help system with the mouse, point to View
on the menu bar, press a mouse button and drag the highlight down to a
Help selection, and then release the button. The appropriate help screen
will appear.
■ Keyboard
If you are in window mode, press the Fl key to enter the complete on-line-
help system. If you are in sequential mode, a syntax-summary screen
appears when you press Fl.
229
pcjs.org
Microsoft CodeView and Utilities
■ Dialog
If you are in window mode, you can view the complete on-line-help system
with the following command:
The Quit command terminates the CodeView debugger and returns con
trol to DOS.
■ Mouse
To quit the CodeView debugger with the mouse, point to "File" on the
menu, press a mouse button and drag the highlight down to the Exit selec
tion, and then release the button. The CodeView screen will be replaced by
the DOS screen, with the cursor at the DOS prompt.
■ Keyboard
■ Dialog
Q
When the command is entered, the CodeView screen will be replaced by
the DOS screen, with the cursor at the DOS prompt.
230
pcjs.org
Using CodeView System-Control Commands
The Radix command changes the current radix for entering arguments and
displaying the value of expressions. The default radix when you start the
CodeView debugger is 10 (decimal). Radixes 8 (octal) and 16 (hexadecimal)
can also be set. Binary and other radixes are not allowed.
The following seven conditions are exceptions; they are not affected by the
Radix command:
1. The radix for entering a new radix is always decimal.
2. Format specifiers given with the Display Expression command or
any of the Watch Statement commands override the current radix.
3. Addresses output by the Assemble, Dump, Enter, Examine Symbol,
and Unassemble commands are always shown in hexadecimal.
4. In assembly mode, all values are shown in hexadecimal.
5. The display radix for Dump, Watch Memory, and Tracepoint
Memory commands is always hexadecimal if the size is bytes,
words, or double words, and always decimal if the size is integers,
unsigned integers, short reals, long reals, or 10-byte reals.
6. The input radix for the Enter commands with the prompting
method is always hexadecimal if the size is bytes, words, or double
words, and always decimal if the size is integers, unsigned integers,
short reals, long reals, or 10-byte reals. The current radix is used
for all values given as part of a list, except real numbers, which
must be entered in decimal.
7. The register display is always in hexadecimal.
■ Mouse
■ Keyboard
■ Dialog
To change the input radix with a dialog command, enter a command line
with the following syntax:
N{radixnumber}
231
pcjs.org
Microsoft CodeView and Utilities
Examples
>N10
>N
10
>? prime
107
>
>N8 ;* C example
>? prime
0153
>
The example aboves show how 107 decimal, stored in the variable
prime, would be displayed with different radixes. Examples are taken
from different languages; there is no logical connection between the radix
and the language used in each example.
>N8
>? 34. i
28
>N10
>? 28,i
28
>N16
>? 1C,1
28
>
In the example above, the same number is entered in different radixes, but
the i format specifier is used to display the result as a decimal integer in
all three cases. See Chapter 6, "Examining Data and Expressions," for
more information on format specifiers.
232
pcjs.org
Using CodeView System-Control Commands
The Redraw command can be used only in window mode; it redraws the
CodeView screen. This command is seldom necessary, but you might need
it if the output of the program being debugged disturbs the CodeView
display temporarily.
■ Mouse
■ Keyboard
■ Dialog
To redraw the screen with a dialog command, enter a command line with
the following syntax:
The Screen Exchange command allows you to switch temporarily from the
debugging screen to the output screen.
The CodeView debugger will use either screen flipping or screen swapping
to store the output and debugging screens. See Chapter 1, "Getting
Started," for an explanation of flipping and swapping.
■ Mouse
To execute the Screen Exchange command with the mouse, open the View
menu, then select Output. Press any key when you are ready to return to
the debugging screen.
233
pcjs.org
Microsoft CodeView and Utilities
■ Keyboard
■ Dialog
To execute the Screen Exchange command from the dialog window, enter
a command line with the following syntax:
\
The output screen appears. Press any key when you are ready to return to
the debugging screen.
For example, you would use \* to find x*y. The periods in the relational
operators must also be preceded by a backslash.
234
pcjs.org
Using CodeView System-Control Commands
The Case Sense selection from the Options menu has no effect on searches
for regular expressions.
Note
When you search for the next occurrence of a regular expression, the
CodeView debugger searches to the end of the file, and then wraps
around and begins again at the start of the file. This can have unex
pected results if the expression occurs only once. When you give the
command repeatedly, nothing seems to happen. Actually, the debugger
is repeatedly wrapping around and finding the same expression each
time.
■ Mouse
After you have found a regular expression, you can search for the next or
previous occurrence of the expression. Point to "Search" on the menu bar,
press a mouse button and drag the highlight down to the Next or Previous
selection, and then release the button. The cursor will move to the next or
previous match of the expression.
You can also search the executable code for a label (such as a routine
name or an assembly-language label). Point to "Search" on the menu bar,
press a mouse button and drag the highlight down to the Label selection,
and then release the button. A dialog box appears, asking for the label to
be found. Type the label name, and press either the ENTER key or a mouse
button. The cursor will move to the line containing the label. This selec
tion differs from other search selections because it searches executable
code rather than source code. The CodeView debugger will switch to
assembly mode, if necessary, to display a label in a library routine or
assembly-language module.
235
pcjs.org
Microsoft CodeView and Utilities
■ Keyboard
After you have found a regular expression, you can search for the next or
previous occurrence of the expression. Press ALT+S to open the Search
menu and then press N to select Next or P to select Previous. The cursor
will move to the next or previous match of the expression.
You can also search the executable code for a label (such as a routine
name or an assembly-language label). Press ALT+S to open the Search
menu and then press L to select Label. A dialog box appears, asking for the
label to be found. Type the label name and press the ENTER key. The cur
sor will move to the line containing the label. This selection differs from
other search selections because it searches executable code rather than
source code. The CodeView debugger will switch to assembly mode, if
necessary, to display a label in a library routine or assembly-language
module.
■ Dialog
/{regularexpression}
If regular expression is given, the CodeView debugger searches the source
file for the first line containing the expression. If no argument is given, the
debugger searches for the next occurrence of the last regular expression
specified.
In window mode, the CodeView debugger starts searching at the current
cursor position and puts the cursor at the next line containing the regular
expression. In sequential mode, the debugger starts searching at the last
source line displayed. It displays the source line in which the expression is
found. An error message appears if the expression is not found. If you are
in assembly mode, the CodeView debugger automatically switches to
source mode when the expression is found.
236
pcjs.org
Using CodeView System-Control Commands
You cannot search for a label with the dialog version of the Search com
mand, but you can use the View command with the label as an argument
for the same effect.
The Shell Escape command allows you to exit from the CodeView
debugger to a DOS shell. You can execute DOS commands or programs
from within the debugger, or you can exit from the debugger to DOS while
retaining your current debugging context.
The Shell Escape command works by saving the current processes in
memory and then executing a second copy of COMMAND.COM. The
COMSPEC environment variable is used to locate a copy of
COMMAND.COM.
If you change directories while working in the shell, make sure you return
to the original directory before returning to the CodeView debugger. If
you don't, the debugger may not be able to find and load source files when
it needs them.
Note
In order to use the Shell Escape command, the executable file being
debugged must release unneeded memory. Programs created with
Mcrosoft compilers release memory during start-up.
You cannot use the Shell Escape command with assembler programs
unless the program specifically releases memory by using the DOS
function call 4A hexadecimal (Set Block) or is linked with the
/CPARMAXALLOC link option.
237
pcjs.org
Microsoft CodeView and Utilities
■ Mouse
To open a DOS shell with the mouse, point to File on the menu bar, press
a mouse button and drag the highlight down to the DOS Shell selection,
and then release the button. If there is enough memory to open the shell,
the DOS screen will appear. You can execute any DOS command or any
program. When you are ready to return to the debugging session, type the
command exit (in any combination of uppercase and lowercase letters).
The debugging screen will appear with the same status it had when you
left it.
■ Keyboard
To open a DOS shell with a keyboard command, press ALT+F to open the
File menu, and then press D to select DOS Shell. If there is enough memory
to open the shell, the DOS screen will appear. You can execute any DOS
internal command or any program. When you are ready to return to the
debugging session, type the command exit (in any combination of
uppercase and lowercase letters). The debugging screen will appear with
the same status it had when you left it.
■ Dialog
To open a DOS shell using a dialog command, enter a command line with
the following syntax:
\{command\
If you want to exit to DOS and execute several programs or commands,
enter the command with no arguments. The CodeView debugger executes
a new copy of COMMAND.COM, and the DOS screen appears. You can
run programs or DOS internal commands. When you are ready to return
to the debugger, type the command exit (in any combination of upper
case and lowercase letters). The debugging screen will appear with the
same status it had when you left it.
If you want to execute a program or DOS internal command from within
the CodeView debugger, enter the Shell Escape command (!) followed by
the name of the command or program you want to execute. The output
screen appears, and the debugger executes the command or program.
When the output from the command or program is finished, the message
Press any key to continue. . . appears at the bottom of the
screen. Press a key to make the debugging screen reappear with the same
status it had when you left it.
238
pcjs.org
Using CodeView System-Control Commands
Examples
>!
In the above example, the CodeView debugger saves the current debugging
context and executes a copy of COMMAND.COM. The DOS screen
appears, and you can enter any number of commands. To return to the
debugger, enter exit.
>!DIR a:*.for
In the example above, the DOS command DIR is executed with the argu
ment a: * . for. The directory listing will be followed by a prompt telling
you to press any key to return to the CodeView debugging screen.
>!CHKDSK a:
In the example above, the DOS command CHKDSK is executed, and the
status of the disk in Drive A is displayed in the dialog window. The pro
gram name specified could be for any executable file, not just that for a
DOS program.
The Tab Set command sets the width in spaces that the CodeView
debugger fills for each tab character. The default tab is eight spaces. You
might want to set a smaller tab size if your source code has so many levels
of indentation that source lines extend beyond the edge of the screen. This
command has no effect if your source code was written with an editor that
indents with spaces rather than with tab characters.
■ Mouse
■ Keyboard
239
pcjs.org
Microsoft CodeView and Utilities
■ Dialog
To set the tab size with a dialog command, enter a command line with the
following syntax:
^number
The number is the new number of characters for each tab character. In
window mode, the screen will be redrawn with the new tab width when
you enter the command. In sequential mode, any output of source lines
will reflect the new tab size.
■ Example
>.
32: IF (X(I)) .LE. X(J)) GOTO 301
>#4
>.
32: IF (X(I)) .LE. X(J)) GOTO 301
>
In the example above, the Source Line command (.) is used to show the
source line with the default tab width of eight spaces. Next the Tab Set
command is used to set the tab width to four spaces. The Source Line
command then shows the same line.
The Option command allows you to view the state of options in the
Option menu (Flip/Swap, Bytes Coded, Case Sense, and 386), and to turn
any of the these options on or off.
For each different kind of source module that you debug, there is a
different set of default settings. However, the use of the Option command
will override any of these settings.
■ Mouse
To view the state of the options with a mouse, simply point to Options on
the menu bar and click either button. Each option is then displayed.
Those options that are turned on have a double arrow immediately to the
left. Options that are turned off have no double arrow.
240
pcjs.org
Using CodeView System-Control Commands
To change one of the Option settings, drag the highlight down to the
option you wish to change and release the button. This will reverse the
state of the option. (An option that was on will be turned off and vice
versa.)
■ Keyboard
To view the state of the Options menu with a keyboard command, press
ALT+O to open the Options menu. Each option is then displayed. Those
options that are turned on have a double arrow immediately to the left.
Options that are turned off have no double arrow.
To change one of the Option settings, press the letter key corresponding to
the option's mnemonic. This will reverse the state of the option. (An
option that was on will be turned off and vice versa.) You can also reverse
an option by moving the highlight down with the arrow key, and then
pressing ENTER.
■ Dialog
O[option [+ | -1]
In the above display, option is one of the following characters: F, B, C, or
3. If used, there must be no spaces between the character and the O.
These characters correspond to options as shown below:
Command Correspondence
OF Flip/Swap option
OB Bytes-Coded option
OC Case-Sense option
03 386 option
O All options
The O form of the command (all options) takes no arguments. It simply
displays the state of all four options. The other forms of the command
(OF, OB, OC, and 03) can be used either with no arguments (in which
case they simply display the state of the option) or they can take the argu
ment + or -.
241
pcjs.org
Microsoft CodeView and Utilities
The + argument turns the option on. The - argument turns the option off.
■ Examples
>0
F1ip/Swap on
Bytes Coded on
Case Sense off
3 8 6 o ff
>03
3 8 6 o ff
>03+
386 on
>0F
F1ip/Swap on
>0F-
Flip/Swap off
In the example above, the O, 03, and OF commands are used simply to
view the current state of an option. Each of the 03+ and OF- commands
modifies an option and then reports the results of the modification.
This command line could be put into a batch file for convenient execution.
■ Mouse
242
pcjs.org
Using CodeView System-Control Commands
Keyboard
None of the redirection or related commands can be executed with key
board commands.
■ Dialog
■ Syntax
< devicename
The Redirected Input command causes the CodeView debugger to read all
subsequent command input from a device, such as another terminal or a
file. The sample session supplied with most versions of the debugger is an
example of commands being redirected from a file.
■ Examples
><C0M1
xlNFILE.TXT
The example above redirects command input from file INFILE .TXT to
the CodeView debugger. You might use this command to prepare a Code
View session for someone else to run. You create a text file containing a
series of CodeView commands separated by carriage-return-line-feed com
binations or semicolons. When you redirect the file, the debugger will exe
cute the commands to the end of the file. One way to create such a file is
to redirect commands from the CodeView debugger to a file (see Section
11.10.3) and then edit the file to eliminate the output and add comments.
243
pcjs.org
Microsoft CodeView and Utilities
■ Syntax
[T]>|>J devicename
The Redirected Output command causes the CodeView debugger to write
all subsequent command output to a device, such as another terminal, a
printer, or a file. The term "output" includes not only the output from
commands, but the command characters that are echoed as you type
them.
The optional T indicates that the output should be echoed to the Code
View screen. Normally, you will want to use the T if you are redirecting
output to a file, so that you can see what you are typing. However, if you
are redirecting output to another terminal, you may not want to see the
output on the CodeView terminal.
The second greater-than symbol (optional) appends the output to an exist
ing file. If you redirect output to an existing file without this symbol, the
existing file will be replaced.
■ Examples
»C0M1
>T>OUTFILE.TXT
»CON
In the example above, output is redirected to the file OUTFILE .TXT. You
might want to enter this command in order to keep a permanent record of
a CodeView session. Note that the optional T is used so that the session
244
pcjs.org
Using CodeView System-Control Commands
will be echoed to the CodeView screen as well as to the file. After redirect
ing some commands to a file, output is returned to the console (terminal)
with the command >CON.
>T»OUTFILE .TXT
If, later in the session, you want to redirect more commands to the same
file, use the double greater-than symbol, as in the example above, to
append the output to the existing file.
■ Syntax
= devicename
Redirecting input and output works best if you start in sequential mode
(using the /T option). The CodeView debugger's window interface has lit
tle purpose in this situation, since the remote terminal can act only as a
sequential (nonwindow) device.
■ Example
>=C0M1
In the example above, output and input are redirected to the device desig
nated as C0M1. This command would be useful if you wanted to enter
debugging commands and see the debugger output on a remote terminal,
while entering program commands and viewing program output on the ter
minal where the debugger is running.
245
pcjs.org
Microsoft CodeView and Utilities
Command Action
■ Syntax
^comment
The Comment command is an asterisk (*) followed by text. The CodeView
debugger echoes the text of the comment to the screen (or other output
device). This command is useful in combination with the redirection com
mands when saving a commented session, or when writing a commented
session that will be redirected to the debugger.
■ Examples
* D u m p fi r s t 2 0 b y t e s o f s c r e e n b u f f e r
D #B800:0 L 20
< CON
246
pcjs.org
Using CodeView System-Control Commands
The example above illustrates another way to use the Comment command.
You can put comments into a text file of commands that will be executed
automatically when you redirect the file into the CodeView debugger. In
this example, an editing program was used to create the text file called
INPUT.TXT.
XINPUT.TXT
>* Dump first 20 bytes of screen buffer
>D #B800:0 L 20
B800:0O00 54 17 6F 17 20 17 72 17 65 17 74 17 75 17 72 17 T.o. .r.e.t.u r
B800:0010 6E 17 20 17 n. .
X CON
>
When you read the file into the debugger by using the Redirected Input
command, you will see the comment, the command, and then the output
from the command, as in the example above.
■ Syntax
Example
* That was a short delay...
:: ;* That was a longer delay.
In the example above from a text file that might be redirected into the
CodeView debugger, the Delay command is used to slow execution of the
redirected file.
247
pcjs.org
Microsoft CodeView and Utilities
■ Syntax
■ Example
In the example above from a text file that might be redirected into the
CodeView debugger, a Comment command is used to prompt the user to
press a key. The Pause command is then used to halt execution until the
user responds.
The example above shows the output when the text is redirected into the
debugger. The next CodeView prompt will not appear until the user
presses a key.
248
pcjs.org
Part 2
I JTILITIES
pcjs.org
£>/
A®
& ■
£9 o^ &
••&
Hi.
^$>
<? &>
P&
sr&
*
v^ OP & :
*K vS:
\f t
^ to^v<y .*&
>v
0*>
\*>
<o^ 5s
nS5:
Vfc
*&$.
$4-
\5
3
pcjs.org
Part 2 describes the use of each of the DOS pro
gramming utilities (while exit messages and exit
codes for these utilities are presented in the
Appendixes).
Some of the material in this part, most notably
the information on LINK, is presented in par
tial form in the user's guides of Mcrosoft com
pilers. However, you will find here the only com
plete, authoritative reference on utility opera
tion and available options.
Chapters 12-14 document LINK, LIB, and
MAKE—all the functions, command-line
options, and commands (if applicable).
Chapter 15 describes four additional utilities.
251
pcjs.org
pcjs.org
Chapter
T JNKING OBTECT FILES
WITH LINK
12.1 Specifying Files for Linking 255
12.1.1 Specifying File Names 255
12.1.2 Linking with the LINK Command Line 256
12.1.3 Linking with the LINK Prompts 258
12.1.4 Linking with a Response File 260
12.1.5 How LINK Searches
for Libraries 261
12.1.6 LINK Memory Requirements 263
12.2 Specifying Linker Options 264
1 2 . 2 . 1 Vi e w i n g t h e O p t i o n s L i s t ( / H E ) 265
1 2 . 2 . 2 P a u s i n g d u r i n g L i n k i n g ( / PA U ) 266
12.2.3 Displaying Linker Process
Information (/I) 266
12.2.4 Packing Executable Files (/E) 267
12.2.5 Listing Public Symbols (/M) 268
12.2.6 Including Line Numbers
in the Map File (/LI) 269
12.2.7 Preserving Case Sensitivity (/NOI) 269
12.2.8 Ignoring Default Libraries (/NOD) 269
12.2.9 Controlling Stack Size (/ST) 270
12.2.10 Setting the Maximum Allocation
Space (/CP) 270
12.2.11 Setting Maximum Number
of Segments (/SE) 271
12.2.12 Setting the Overlay Interrupt (/O) 272
12.2.13 Ordering Segments (/DO) 272
12.2.14 Controlling Data Loading (/DS) 273
12.2.15 Controlling Executable-File Loading (/HI) ..274
12.2.16 Preserving Compatibility (/NOG) 274
12.2.17 Preparing for Debugging (/CO) 275
pcjs.org
CHAPTER
254
pcjs.org
Linking Object Files with LINK
The Microsoft Overlay Linker (LINK) is used to combine object files into
a single executable file. It can be used with object files compiled or assem
bled for 8086/8088 or 80286 machines. The format of input to the linker is
the Microsoft Relocatable Object-Module Format (OMF), which is based
on the Intel 8086 OMF.
The output file from LINKJthat is, the executable file) is not bound to
specific memory addresses. Thus, the operating system can load and exe
cute this file at any convenient address. LINK can produce executable
files containing up to 1 megabyte of code and data.
The following sections explain how to run the linker and specify options
that control its operation.
Regardless of the way in which LINK was invoked, type CONTROL+C at any
time to terminate LINK operation and exit back to DOS.
abcde.fgh
AbCdE.FgH
ABCDE.fgh
255
pcjs.org
Microsoft CodeView and Utilities
If you specify file names without extensions, LINK uses the following
default file-name extensions:
File Default
Type Extension
Object .OBJ
Executable .EXE
Map .MAP
Library .LIB
You can override the default extension for a particular command-line field
or prompt by specifying a different extension. To enter a file name that
has no extension, type the name followed by a period.
■ Examples
ABC.
ABC
If you use the first file specification, LINK assumes that the file has no
extension. If you use the second file specification, LINK uses the default
extension for that prompt.
LINK|op«Jons]o6yect/j7e8[,[exec«to6/e/«7e][4map/»Vel|4/i6rory/i7efil]]]|;]
The objectfiles field allows you to specify the names of the object files you
are linking. At least one object-file name is required. A space or plus sign
(+) must separate each pair of object-file names. LINK automatically
supplies the .OBJ extension when you give a file name without an exten
sion. If your object file has a different extension, or if it appears in another
directory or on another disk, you must give the full name—including the
extension and path name—for the file to be found. If LINK cannot find a
given object file, and the drive associated with the object file is a remov
able (floppy) drive, then LINK displays a message and waits for you to
change disks.
256
pcjs.org
Linking Object Files with LINK
You may also specify one or more libraries in the objectfiles field To enter
a library in this field, make sure that you include the .LLB extension- oth
erwise LINK wi 1 assume an .OBJ extension. Libraries entered in this
held are called load libraries" as opposed to "regular libraries " LINK
automatically links in every object module in a load library; it does not
search lor unresolved external references first. The effect of entering a load
ibrary is exactly the same as if you had entered all the names of the
library s object modules into the objectfiles field. This feature is useful if
you are developing software using many modules, and wish to avoid hav
ing to retype each module on the LINK command line.
The executablefile field allows you to specify the name of the executable
tie. II the hie name you give does not have an extension, LINK automati
cally adds .EXE as the extension. You can give any file name you like-
however, if you are specifying an extension, you should always use .EXE
Ac^weextension.
•COM S exPects executable files to have either this extension or the '
The mapfile field allows you to specify the name of the map file if you are
creating one. To include public symbols and their addresses in the map
file, specify the /MAP option on the LINK command line. See Section
12.2.5, "Listing Public Symbols." If you specify a map-file name without
an extension, LINK automatically adds an extension of .MAP. LINK
creates the map file in the current working directory unless you specify a
path name for the map file.
The libraryfiles field allows you to specify the name of a library that you
want linked to the object file(s). (When LINK finds the name of a library
in this field, the library is a "regular library," and LINK will link in only
those object modules needed to resolve external references.) Each time you
compile a source file for a high-level language, the compiler places the
name of one or more libraries in the object file that it creates; the linker
automatically searches for a library with this name. Because of this, you
do not need to give library names on the LINK command line unless you
want to add the names of other libraries, search for libraries in different
locations, or override the use of the library named in the object file.
The options field allows you to specify the linker options described in Sec
tions 12.2.1-12.2.23. You do not have to give any options when you run
the linker. If you specify options, you can put them after any field (but
before comma) or at the end of the command line.
If you include a comma (to indicate where a field would be) but do not put
a file name before the comma, then LINK will select the default for that
field. However, if you use a comma to include the mapfile field (but do not
include a name), then LINK will create a map file. This file has the same
base name as the executable file. Use NUL for the map-file name if you do
not want to produce a map file.
257
pcjs.org
Microsoft CodeView and Utilities
You can also select default responses by using a semicolon (;). The semi
colon tells LINK to use the defaults for all remaining fields.
If you do not give all file names on the command line, or if you do not end
the command line with a semicolon, the linker prompts you for the files
you omitted, using the prompts described in Section 12.1.3, Linking with
the LINK Prompts."
If you do not specify a drive or directory for a file, the linker assumes that
the file is on the current drive and directory. If you want the linker to
create files in a location other than the current drive and directory, you
must specify the new drive and directory for each such file on the com
mand line.
■ Examples
LINK FUN,,;
This command line produces a map file named FUN.MAP, since a comma
appears as a placeholder for the mapfile specification on the command line.
LINK FUN,;
LINK FUN;
These command lines do not produce a map file, since commas do not
appear as placeholders for the mapfile specification.
258
pcjs.org
Linking Object Files with LINK
LINK waits for you to respond to each prompt before printing the next
one. Section 12.1.1 gives the rules for specifying file names in response to
these prompts.
The responses you give to the LINK command prompts correspond to the
fields on the LINK command line. (See Section 12.1.2 for a discussion of
the LINK command line.) The following list shows these correspondences:
Command-Line
Prompt Field
Default Responses
To select the default response to the current prompt, type a carriage
return without giving a file name. The next prompt will appear.
Prompt Default
"Run File" The name of the first object file submitted for
the "Object Modules" prompt, with the .EXE
extension replacing the .OBJ extension
"List File" The special file name NUL.MAP, which tells
LINK not to create a map file
"Libraries" The default libraries encoded in the object
module (see Section 12.1.5, "How LINK
Searches for Libraries").
259
pcjs.org
Microsoft CodeView and Utilities
Here responsefile specifies the name or pathname of the response file that
starts the linker. You can also enter the name of a response file after any
LINK command prompt or at any position in the LINK command line.
You can use options and command characters in the response file in the
same way as you would use them in responses you type at the keyboard.
For example, if you type a semicolon on the line of the response file
corresponding to the "Run File" prompt, LINK uses the default responses
for the executable file and for the remaining prompts.
When you enter the LINK command with a response file, each LINK
prompt is displayed on your screen with the corresponding response from
your response file. If the response file does not include a line with a file
name, semicolon, or carriage return for each prompt, LINK displays the
missing prompts and waits for you to enter responses. When you type an
acceptable response, LINK continues the link session.
■ Example
260
pcjs.org
Linking Object Files with LINK
You can type the following command to run LINK and tell it to use the
responses in FUN. LNK:
LINK OFUN.LNK
The response file tells LINK to load the four object modules FUN, TEXT,
TABLE, and CARE. LINK produces an executable file named FUN.EXE '
and a map file named FUNLIST.MAP. The /PAUSE option tells LINK to
pause before it produces the executable file so that you can swap disks, if
necessary. The /MAP option tells LINK to include public symbols and'
addresses in the map file. LINK also links any needed routines from the
library file GRAF . LIB. See the discussions of the /PAUSE and /MAP
options in Sections 12.2.2 and 12.2.5, respectively, for more information
about these options.
If the library name includes a path specification, LINK searches only that
directory for the library. Libraries specified by object modules (that is,
default libraries) will normally not include a path specification.
261
pcjs.org
Microsoft CodeView and Utilities
For example, if you have developed your own customized libraries, you
might want to include one or more of them as additional libraries at link
ing time.
If you specify a new library name on the LINK command line, the linker
searches the new library to resolve external references before it searches
the library specified in the object file.
262
pcjs.org
Linking Object Files with LINK
If you want the linker to ignore the library whose name is included in the
object file, you must use the /NOD option. This option tells LINK to
ignore the default-library information that is encoded in the object files
created by high-level language compilers. Use this option with caution-
see the discussion of the /NOD option in Section 12.2.8 for more informa
tion.
■ Example
LINK
• The linker will use the directory specified by the TMP environ
ment variable, for the purpose of creating a temporary file. For
example, if the TMP variable were set to C:\TEMPDIR, then
LINK would put the temporary file in C:\TEMPDIR.
If there is no TMP environment variable, or if the directory
specified by TMP does not exist, then LINK will put the tem
porary file in the current working directory.
• If the linker is running on DOS Version 3.0 or later, it uses a DOS
system call to create a temporary file with a unique name in the
temporary-file directory.
• If the linker is running on a version of DOS prior to 3.0, it creates a
temporary file named VM.TMP.
263
pcjs.org
Microsoft CodeView and Utilities
When the linker creates a temporary disk file, you will see the message
Note
Do not give any of your own files the name VM.TMP. The linker
displays an error message if it encounters an existing file with this
name.
This section explains how to use linker options to specify and control the
tasks performed by LINK. All options begin with the linker's option char
acter, the forward slash (/).
When you use the LINK command line to invoke LINK, options can
appear at the end of the line or after individual fields on the line. However,
they must precede the comma that separates each field from the next.
If you respond to the individual prompts for the LINK command, you can
specify linker options at the end of any response. When you specify more
than one option, you can either group the options at the end of a single
264
pcjs.org
Linking Object Files with LINK
Abbreviations
Since linker options are named according to their functions, some of these
names are quite long. You can abbreviate the options to save space and
effort. Be sure that your abbreviation is unique so that the linker can
determine which option you want. (The minimum legal abbreviation for
each option is indicated in the syntax description of the option.)
Abbreviations must begin with the first letter of the option and must be
continuous through the last letter typed. No gaps or transpositions are
allowed.
Numerical Arguments
Some linker options take numeric arguments. A numeric argument can be
any of the following:
• A decimal number from 0 to 65,535.
• An octal number from 0 to 177777. A number is interpreted as
octal if it starts with 0. For example, the number 10 is interpreted
as a decimal number, but the number 010 is interpreted as an
octal number, equivalent to 8 in decimal.
• A hexadecimal number from 0 to FFFF. A number is interpreted as
hexadecimal if it starts with OX. For example, 0X10 is a hexade
cimal number, equivalent to 16 in decimal.
■ Option
/HE[LP]
The /HELP option causes LINK to display a list of the available options
on the screen. This gives you a convenient reminder of the available
options. Do not give a file name when using the /HELP option.
265
pcjs.org
Microsoft CodeView and Utilities
■ Option
/PAU[SE]
Unless you instruct it otherwise, LINK performs the linking session from
beginning to end without stopping. The /PAU option tells LINK to
pause in the link session before it writes the executable (.EXE) file to disk.
This option allows you to swap disks before LINK writes the executable
file.
If you specify the /PAU option, LINK displays the following message
before it creates the run file:
Note
Do not remove the disk that will receive the list file or the disk used for
the temporary file.
If a temporary file is created on the disk you plan to swap, you should
press CONTROL+C to terminate the LINK session. Rearrange your files
so that the temporary file and the executable file can be written to the
same disk. Then try linking again.
For more information on how LINK determines where to put the tem
porary file, see Section 12.1.6, "LINK Memory Requirements."
■ Option
/I[NFORMATION]|
The /I option tells the linker to display information about the linking pro
cess, including the phase of linking and the names of the object files being
266
pcjs.org
Linking Object Files with LINK
linked. This option is useful if you want to determine the locations of the
object files being linked and the order in which they are linked.
Output from this option is sent to the standard error output. You can use
the ERROUT utility, described in Section 15.4, to redirect output to any
file or device.
The following is a sample of the linker output when the /I and /MAP
options are specified on the LINK command line:
**** PASS ONE ****
T E S T. O B J ( t e s t . f o r )
**** LIBRARY SEARCH ****
LLIBF0R7.LIB(wr)
LLIBF0R7.LIB(fmtout)
LLIBF0R7.LIB(ldout)
■ Option
/EJXEPACKJ
The /E option directs LINK to remove sequences of repeated bytes (typi
cally null characters) and to optimize the load-time relocation table before
267
pcjs.org
Microsoft CodeView and Utilities
The /E option does not always give a significant saving in disk space and
may sometimes actually increase file size. Programs that have a large
number of load-time relocations (about 500 or more) and long streams of
repeated characters are usually snorter if packed. If you're not sure
whether your program meets these conditions, link it both ways and com
pare the results.
■ Option
/M[APJ {xnumber}
You can list all public (global) symbols defined in the object file(s) by
using the /M option. When you invoke LINK with the /M option, the
mapfile will contain a list of all the symbols sorted by name and a list of
all the symbols sorted by address. If you do not use this option, then
mapfile will contain only a list of segments.
Whe you use this option, the default for mapfile is no longer NUL.
Instead, the default is a name that combines the basename of the execut
able file, with a .MAP extension. It is still possible for you to specify
NUL in the mapfile field (which indicates that no map file is to be gen
erated); if you do, then the /M option will have no further effect.
The optional number field specifies the maximum number of public sym
bols that the linker can sort. By default, this limit is 2048. If the number
of symbols exceeds this limit, then the linker will generate only an
unsorted list. When you specify a value for number, the mapfile will con
tain a list of symbols sorted by address (assuming that number is large
enough); however, it will not contain a list sorted by name.
268
pcjs.org
Linking Object Files with LINK
■ Option
/LI[NENUMBERSJ
You can include the line numbers and associated addresses of your source
program in the map file by using the /LI option. Ordinarily the map file
does not contain line numbers. To produce a map file with line numbers,
you must give LINK an object file (or files) with line-number information.
You can use the /Zd option with any Microsoft compiler to include line
numbers in the object file. If you give LINK an object file without line-
number information, the /LI option has no effect.
The /LI option forces LINK to create a map file, even if you did not
explicitly tell the linker to create a map file. By default, the file is given
the same base name as the executable file, plus the extension .MAP. You
can override the default name by specifying a new map file on the LINK
command line or in response to the "List File" prompt.
■ Option
/NOI[GNORECASE]
By default, LINK treats uppercase letters and lowercase letters as
equivalent. Thus ABC, abc, and Abc are considered the same name. When
you use the /NOI option, the linker distinguishes between uppercase
letters and lowercase letters, and considers ABC, abc, and Abc to be three
separate names. Since names in some high-level languages are not case sen
sitive, this option can have minimal importance. However, in some
languages, such as C, case is significant. If you plan to link your files from
other high-level language with C routines, you may want to use this
option.
■ Option
/NOD [EFAULTLIBRARYSEAItCH]
The /NOD option tells LINK not to search any library specified in the
object file to resolve external references.
269
pcjs.org
Microsoft CodeView and Utilities
■ Option
/ST[ACKj:rawm6er
The /ST option allows you to specify the size of the stack for your pro
gram. The number is any positive value (decimal, octal, or hexadecimal) up
to 65,535 (decimal). It represents the size, in bytes, of the stack.
If you get a stack-overflow message, you may need to increase the size of
the stack. In contrast, if your program uses the stack very little, you may
save some space by decreasing the stack size.
Note
You can also use the EXEMOD utility, described in Section 15.2, to
change the default stack size in executable files by modifying the
executable-file header. The format of the executable-file header is dis
cussed in that section as well as in the Microsoft MS-DOS
Programmer's Reference and in other reference books on DOS.
■ Option
270
pcjs.org
Linking Object Files with LINK
could be available under DOS, the operating system always denies the
request and allocates the largest contiguous block of memory it can find. If
the /CP option is used, the operating system allocates no more space than
the option specified. This means any additional space in memory is free for
other programs.
The number can be any integer value in the range 1 to 65,535. If number is
less than the minimum number of paragraphs needed by the program,
LINK ignores your request and sets the maximum value equal to whatever
the minimum value happens to be. The minimum number of paragraphs
needed by a program is never less than the number of paragraphs of code
and data in the program. To free more memory for programs compiled in
the medium- and large-memory models, link with /CP:1; this leaves no
space for the near heap.
Note
You can change the maximum allocation after linking by using the
EXEMOD utility, which modifies the executable-file header, as
described in Section 15.2. The format of the executable-file header is
also discussed in that section, as well as in the Microsoft MS-DOS
Programmer's Reference and in other reference books on DOS.
■ Option
/SE[GMENTSj:n«m6er
The /SE option controls the number of segments that the linker allows a
program to have. The default is 128, but you can set number to any value
(decimal, octal, or hexadecimal) in the range 1 to 3072 (decimal).
For each segment, the linker must allocate some space to keep track of
segment information. By using a relatively low segment limit as a default
(128), the linker is able to link faster and allocate less storage space.
When you set the segment limit higher than 128, the linker allocates more
space for segment information. This option allows you to raise the seg
ment limit for programs with a large number of segments. For programs
with fewer than 128 segments, you can keep the storage requirements of
the linker at the lowest level possible by setting the segment number to
reflect the actual number of segments in the program.
271
pcjs.org
Microsoft CodeView and Utilities
If the number of segments allocated is too high for the amount of memory
LINK has available to it, you will see the following error message:
■ Option
/O [VERLAYINTERRUPTJ -.number
By default, the interrupt number used for passing control to overlays is 63
(3F hexadecimal). The /O option allows the user to select a different inter
rupt number.
The number can be a decimal number from 0 to 255, an octal number from
octal 0 to octal 0377, or a hexadecimal number from hexadecimal 0 to hex
adecimal FF. Numbers that conflict with DOS interrupts can be used;
however, their use is not advised.
In general, you should not use /O with programs. The exception to this
guideline would be a program that uses overlays and spawns another pro
gram using overlays; in this case, each program should use a separate
overlay-interrupt number, meaning that at least one of the programs
should be compiled with /O.
■ Option
/DO|SSEGj
The /DO option is automatically enabled by a special object module
record in Microsoft language libraries. If you are linking to one of these
libraries, then you do not need to specify this option.
This option is also enabled by assembly modules that use the Mcrosoft
Macro Assembler directive .DOSSEG.
272
pcjs.org
Linking Object Files with LINK
Note
When the /DO option is in effect the linker initializes two special vari
ables as follows:
■ Option
/DSJALLOCATE]
By default, LINK loads all data starting at the low end of the data seg
ment. At run time, the DS (data segment) register is set to the lowest pos
sible address to allow the entire data segment to be used.
Use the /DS option to tell LINK to load all data starting at the high end
of the data segment instead. In this case, the DS register is set at run time
to the lowest data-segment address that contains program data.
273
pcjs.org
Microsoft CodeView and Utilities
The /DS option is typically used with the /HI option, discussed in the
next section, to take advantage of unused memory within the data seg
ment.
Warning
This option should be used only with assembly-language programs.
■ Option
/HIJGH]
The executable file can be placed either as low or as high in memory as
possible. Use of the /HI option causes LINK to place the executable file
as high as possible in memory. Without the /HI option, LINK places the
executable file as low as possible.
Note
This option should be used only with assembly-language programs.
■ Option
/NOG[ROUPASSOCIATIONj
The /NOG option causes the linker to ignore group associations when
assigning addresses to data and code items. It is provided primarily for
compatibility with previous versions of the linker (Versions 2.02 and ear
lier) and early versions of Microsoft language compilers.
Note
This option should be used only with assembly-language programs.
274
pcjs.org
Linking Object Files with LINK
■ Option
/COJDEVIEW]
The /CO option is used to prepare for debugging with the CodeView
window-oriented debugger. This option tells the linker to prepare a spe
cial executable file containing symbolic data and line-number information.
You can run this executable file outside the CodeView debugger; the extra
data in the file will be ignored. However, to keep file size to a minimum,
use the special-format executable file only for debugging; then you can link
a separate version without the /CO option after the program is debugged.
■ Option
/B1ATCHJ
By default, the linker prompts you for a new path name whenever it can
not find a library that it has been directed to use. It also prompts you if it
cannot find an object file, and it expects that file to be on a removable
disk. If the /B option is used, however, the linker will not prompt you for
any libraries or object files that it cannot find. Instead, the linker will gen
erate an error or warning message, if appropriate.
The use of this option can cause unresolved external references. It is
intended primarily for users who use batch or MAKE files for linking
many executable files with a single command, and who wish to prevent
linker operation from halting.
Note
This option does not prevent the linker from prompting for command-
line arguments. You can prevent such prompting only by using a semi
colon on the command line.
275
pcjs.org
Microsoft CodeView and Utilities
■ Option
/F [ARCALLTRANSLATION]
The /F option may result in slightly faster code, and smaller executable
file size. It should be used with the /PAC option, described in Section
12.2.21, in order to achieve significant results. The gain in speed is most
apparent for 286- and 386-based machines. Though some assembly pro
grams should not be linked with this option, it is generally safe for use
with high-level-language programs. This option is off by default; further
more, it can always be turned off with the /NOF option described in the
next section.
The rest of this section describes the low-level details of /F. It is not
necessary that you understand these details in order to use the option.
The /F option directs the linker to optimize far calls to procedures that
lie in the same segment as the caller. For example, a medium or large
model program may have a machine instruction that makes a far call to a
procedure in the same segment. Since the segment address is the same (for
both the instruction and the procedure it calls), only a near call should be
necessary.
A near-call instruction does not require an entry in the relocation table,
whereas a far-call instruction does. Therefore, use of /F (together with
/PAC) often results in smaller executable files, because the relocation
table is smaller. Such files will load faster.
When /F has been specified the linker will optimize code, by removing the
instruction call FAR label, and substituting the following sequence:
push cs
call NEAR label
nop
Upon execution, the called procedure will still return with a far-return
instruction. However, because both the code segment and the near address
are on the stack, the far return will be executed correctly. The nop (no-op)
instruction appears so that exactly five bytes replace the five-byte far-call
instruction; the linker may in some cases place the nop at the beginning of
the sequence.
The /F option has no effect on programs that only make near calls. Of the
high-level Mcrosoft languages, only small- and compact-model C pro
grams use near calls.
276
pcjs.org
Linking Object Files with LINK
Note
There is a small risk involved with the /F option; the linker may mis
takenly translate a byte in a code segment that happens to have the
far-call opcode (9A hexadecimal). If a program linked with /F inexpli
cably fails, then you may want to try linking with this option off. How
ever, object modules produced by Microsoft high-level languages
should be safe from this problem, because relatively little immediate
data is stored in code segments.
In general, assembly-language programs are also relatively safe for use
with the /F option, as long as they do not involve advanced system-
level code, such as might be found in operating systems or interrupt
handlers.
■ Option
/NOF [ARCALLTRANSLATIONJ
This option is normally not necessary, because far-call optimization
(translation) is turned off by default. However, if an environment variable
such as LINK (or CL) turns on far-call translation automatically, you can
use /NOF to turn far-call translation back off again.
■ Option
/PACIKCODE] {-.number}
This option only affects code segments in medium- and large- model pro
grams. It is intended to be used with the /F option, which is described in
Section 12.2.19. It is not necessary to understand the details of the /PAC
option in order to use it. You only need to know that this option, used in
conjunction with /F, produces slightly faster and more compact code. The
/PAC option is off by default, and can always be turned off with the
/NOP option described in the next section.
The /PAC option directs the linker to group together neighboring code
segments. Segments in the same group are assigned the same segment
address; offset addresses are adjusted upward accordingly. In other words,
277
pcjs.org
Microsoft CodeView and Utilities
all items will have the correct physical address whether the /PAC option
is used or not. However, /PAC changes segment and offset addresses so
that all items in a group share the same segment address.
The number field specifies the maximum size of groups formed by /PAC.
The linker will stop adding segments to a group as soon as it cannot add
another segment without exceeding number. At that point, the linker
starts forming a new group. The default for number is 65,530.
CSEG1 ENDS
CSEG2 SEGMENT PARA PUBLIC 'CODE'
ASSUME cs:CSEG2
; Return the length of CSEGl in AX.
codsize PROC NEAR
mov ax,CSEG2 Load para address of CSEGl
sub ax,CSEGl Load para address of CSEG2
mov ex, 4 Load count, and
shl ax,cl convert distance from paragraphs
to bytes
c o d s i z e ENDP
CSEG2 ENDS
■ Option
/NOP|ACKCODE]
This option is normally not necessary because code-segment packing is
turned off by default. However, if an environment variable such as LINK
(or CL) turns on code-segment packing automatically, you can use /NOP
to turn segment packing back off again.
278
pcjs.org
Linking Object Files with LINK
■ Option
/Q|UICKLIB]
The /Q option directs the linker to produce a "Quick library," suitable for
use with Microsoft QuickBASIC or Microsoft QuickC programs, instead of
producing a stand-alone application. (Stand-alone applications are execut
able files that need only the presence of DOS to run. The linker produces
these by default.)
Important
Two special restrictions apply to use of a Quick library:
1. User libraries can only be loaded by programs created with
QuickC or QuickBASIC. These programs have the special code
that properly loads a Quick library at run time.
2. Routines in a Quick library can be called from any module at
run time. However, Quick-library routines cannot themselves
make calls to routines outside the library. In other words,
Quick libraries must be self-contained.
279
pcjs.org
Microsoft CodeView and Utilities
for references to be resolved at run time, after the entire library is loaded
into memory. For further information on the use of these libraries, consult
the User's Guide for QuickBASIC or QuickC.
You can use the LINK environment variable to cause certain options to
be used each time you link. The linker checks the environment variable for
options, if the variable exists.
The linker expects to find options listed in the variable exactly as you
would type them in on the command line. It will not accept other kinds of
arguments; file names in the environment variable will cause the error
message unrecognized option.
Each time you link, you can specify other options in addition to the ones
specified in the LINK environment variable. If you type an option both on
the command line and in the environment variable, the effect will be the
same as if the option were given once.
■ Example
Note
A command-line option will override the effect of any environment-
variable option that it conflicts with. For example, the command-line
option /SE : 256 cancels the effect of the environment-variable option
/SE:512.
The only other way to prevent an option in the environment variable
from being used is to reset the environment variable itself.
280
pcjs.org
Linking Object Files with LINK
LINK performs the following steps to combine object modules and pro
duce an executable file:
281
pcjs.org
Microsoft CodeView and Utilities
The /DOSSEG option may change the way in which segments are
ordered.
282
pcjs.org
Linking Object Files with LINK
If a segment has combine type STACK, then LINK carries out the same
combine operation as for PUBLIC segments. The only exception is that
STACK segments cause LINK to copy an initial stack-pointer value to
the executable file. This stack-pointer value is the offset to the end of the
first stack segment (or combined stack segment) encountered.
12.4.5 Groups
Groups allow segments to be addressed relative to the same frame address.
When LLNK encounters a group, it adjusts all memory references to items
in the group so that they are relative to the same frame address.
Groups do not affect the order in which the segments are loaded. Unless
you use class names and enter object files in the right order, there is no
guarantee that the segments will be contiguous. In fact, LLNK may place
segments that do not belong to the group in the same 64K of memory.
Although LLNK does not explicitly check that all segments in a group fit
within 64K of memory, LLNK is likely to encounter a fix-up-overflow error
if this requirement is not met.
12.4.6 FixUps
Once the starting address of each segment in a program is known and all
segment combinations and groups have been established, LLNK can "fix
up" any unresolved references to labels and variables. To fix up unresolved
references, LLNK computes an appropriate offset and segment address and
replaces the temporary values generated by the assembler with the new
values.
283
pcjs.org
Microsoft CodeView and Utilities
LLNK carries out fix ups for the types of references shown in the following
list:
Ty p e o f R e f e r e n c e D e s c r i p t i o n
284
pcjs.org
Linking Object Files with LINK
64K away It can also occur if all segments in a group do not fit within a
single 64K block of memory.
In this example, the modules (b+c), (e+f), and (i) are overlays. The
remaining modules, and any drawn from the run-time libraries, constitute
the resident part (or root) of your program. Overlays are loaded into the
same region of memory, so only one can be resident at a time. Duplicate
names in different overlays are not supported, so each module can appear
only once in a program.
The linker replaces calls from the root to an overlay, and calls from an
overlay to another overlay with an interrupt (followed by the module
identifier and offset). By default, the interrupt number is 63 (3F hexade
cimal). You can use the /OVERLAYLNTERRUPT option of the LINK
command to change the interrupt number.
The CodeView debugger is now compatible with overlayed modules. In
fact, in the case of large programs, you may need to use overlays to leave
sufficient room for the debugger to operate.
285
pcjs.org
Microsoft CodeView and Utilities
Even with overlays, the linker produces only one .EXE file. This file is
opened again and again as long as the overlay manager needs to extract
new overlay modules.
For example, assume that an executable program called PAYROLL. EXE
uses overlays, and does not exist in either the current directory or the
directories specified by PATH. If the user runs PAYROLL. EXE (by enter
ing a complete path specification), the overlay manager displays the fol
lowing message when it attempts to load overlay files:
Cannot find PAYROLL.EXE
Please enter new program spec:
The user can then enter the drive or directory, or both, where
PAYROLL.EXE is located. For example, if the file is located in directory
\EMPLOYEE\DATA\ on drive B, the user could enter
B: \EMPLOYEE\DATA\ or simply \EMPLOYEE\DATA\ if the current drive
isB.
If the user later removes the disk in drive B and the overlay manager needs
to access the overlay again, it does not find PAYROLL. EXE and displays
the following message:
After the overlay file has been read from the disk, the overlay manager
displays the following message:
Please restore the original diskette.
Strike any key when ready.
286
pcjs.org
MANAGING
Chapter
%
13
LIBRARIES WITH LIB
13.1 Managing Libraries 289
13.1.1 Managing Libraries
with the LIB Command Line 290
13.1.1.1 Specifying the Library File 290
13.1.1.2 Specifying a Page Size 291
13.1.1.3 Giving LIB Commands 291
13.1.1.4 Specifying a
Cross-Reference-Listing File 293
13.1.1.5 Specifying an Output Library 293
13.1.2 Managing Libraries
with the LIB Prompts 295
13.1.2.1 Extending Lines 295
13.1.2.2 Using Default Responses 296
13.1.3 Managing Libraries
with a Response File 296
1 3 . 1 . 4 Te r m i n a t i n g t h e L I B S e s s i o n 2 9 7
13.2 Performing Library
M a n a g e m e n t Ta s k s w i t h L I B 2 9 7
13.2.1 Creating a Library File 298
13.2.2 Changing a Library File 299
13.2.3 Adding Library Modules 299
13.2.4 Deleting Library Modules 300
13.2.5 Replacing Library Modules 300
13.2.6 Copying Library Modules 300
13.2.7 Moving Library Modules (Extracting) 300
13.2.8 Combining Libraries 300
13.2.9 Creating a Cross-Reference-Listing File 301
13.2.10 Performing Consistency Checks 301
1 3 . 2 . 11 S e t t i n g t h e L i b r a r y P a g e S i z e 3 0 2
pcjs.org
Managing Libraries with LIB
Using LIB, you can create a new library file, add object files to an existing
library, delete library modules, replace library modules, and create object
files from library modules. LIB also lets you combine the contents of two
libraries into one library file.
The command syntax is straightforward; you can give LIB all the input it
requires directly from the command line. Once you have learned how LD3
works and what input it needs, you can use one of the two alternative
methods of invoking Lffi, described in Sections 13.1.1 and 13.1.2 (you can
enter input in response to prompts instead of—or in addition to—entering
the input on the LLB command line).
You run LIB by typing the LLB command on the DOS command line. You
can specify the input required for this command in one of three ways:
289
pcjs.org
Microsoft CodeView and Utilities
2. By responding to prompts.
3. By specifying a file containing responses to prompts. (This type of
file is known as a "response file.")
To tell LIB to use the default responses for the remaining fields, use a
semicolon (;) after any field except the oldlibrary field. The semicolon
should be the last character on the command line.
■ Field
oldlibrary^
The oldlibrary field allows you to specify the name of the existing library
to be used. Usually library files are named with the .LD3 extension. You
can omit the .LIB extension when you give the library-file name since LLB
assumes that the file-name extension is .LIB. If your library file does not
have the .LIB extension, be sure to include the extension when you give
the library-file name. Otherwise, LB3 cannot find the file.
Path names are allowed with the library-file name. You can give LIB the
path name of a library file in another directory or on another disk. There
is no default for this field. LIB produces an error message if you do not
give a file name.
If you give the name of a library file that does not exist, LB3 displays the
following prompt:
L i b r a r y fi l e d o e s n o t e x i s t . C r e a t e ?
290
pcjs.org
Managing Libraries with LIB
■ Option
[/PAGESIZE:n«m6erJ
The /PAGESIZE option allows you to specify the library-page size of a
new library or change the library-page size of an existing library. The
page size of a library affects the alignment of modules stored in the
library. Modules in the library are always aligned to start at a position
that is a multiple of the page size (in bytes) from the beginning of the file.
The default page size for a new library is 16 bytes. See Section 13.2.11,
"Setting the Library Page Size," for more information.
■ Field
{commands}
The commands field allows you to specify the command symbols for mani
pulating modules. To use this field, type a command symbol (such as +, -,
—(-, *, or -*), followed immediately by a module name or an object-file
name. You can specify more than one operation in this field, in any order.
LH3 does not make any changes to oldlibrary if you leave the commands
field blank.
Command
Symbol Meaning
291
pcjs.org
Microsoft CodeView and Utilities
292
pcjs.org
Managing Libraries with LIB
■ Field
{listfile}
The listfile field allows you to specify a file name for a cross-reference-
hstmg file. You can specify a full path name for the listing file to cause it
to be created outside your current working directory. You can give the
listing file any name and any extension. LLB does not supply a default
extension if you omit the extension.
A cross-reference-listing file contains the following two lists:
■ Field
{newlibrary}
The newlibrary field allows you to specify the name of the new library file
that will contain the specified changes. This prompt appears only if you
specify changes to the library in the commands field. The default is the
current library-file name.
293
pcjs.org
Microsoft CodeView and Utilities
■ Examples
LIB LANG-+HEAP;
The example above uses the replace command symbol (-+) to instruct
LIB to replace the HEAP module in the library LANG.LIB. LIB deletes
the HEAP module from the library, then appends the object file HEAP . OBJ
as a new module in the library. The semicolon at the end of the command
line tells LIB to use the default responses for the remaining prompts. This
means that no listing file is created and that the changes are written to
the original library file instead of a new library file.
LIB LANG-HEAP+HEAP;
LIB LANG+HEAP-HEAP;
The examples above perform the same function as the first example in this
section, but in two separate operations, using the add (+) and delete (-)
command symbols. The effect is the same for these examples because
delete operations are always carried out before add operations, regardless
of the order of the operations in the command line. This order of execution
prevents confusion when a new version of a module replaces an old version
in the library file.
LIB FOR;
LIB LANG,LCROSS.PUB
This example tells LIB to perform a consistency check of the library file
LANG.LIB and then create a cross-reference-listing file named
LCROSS.PUB.
This last example instructs LD3 to move the module STUFF from the
library FIRST.LIB to an object file called STUFF .OBJ. The module
STUFF is removed from the library in the process. The module MORE is
copied from the library to an object file called MORE . OBJ; the module
remains in the library. The revised library is called SECOND.LIB. It con
tains all the modules in FIRST.LIB except STUFF, which was removed by
using the move command symbol (-*). The original library, FIRST.LIB,
remains unchanged.
294
pcjs.org
Managing Libraries with LIB
Library name:
Operations:
L i s t fi l e :
Output 1ibrary:
LIB waits for you to respond to each prompt, then prints the next
prompt.
The responses you give to the Lffi command prompts correspond to the
fields on the LIB command line. (See Section 13.1.1 for a discussion of the
LIB command line.) The following list shows these correspondences:
If you have many operations to perform during a library session, use the
ampersand command symbol (8c) to extend the operations line. Give the
ampersand symbol after an object-module or object-file name; do not put
the ampersand between an operation's symbol and a name.
The ampersand causes LLB to repeat the "Operations" prompt, allowing
you to type more operations.
295
pcjs.org
Microsoft CodeView and Utilities
After any entry but the first, use a single semicolon (;) followed immedi
ately by a carriage return to select default responses to the remaining
prompts. You can use the semicolon command symbol with the command-
line and response-file methods of invoking LIB, but it is not necessary
since LIB supplies the default responses wherever you omit responses.
Prompt Default
LIB @responsefile
The responsefile is the name of a response file. The response-file name can
be qualified with a drive and directory specification to name a response file
from a directory other than the current working directory.
You can also enter the name of a response file at any position in a com
mand line or after any of the linker prompts. The input from the response
file will be treated exactly as if it had been entered in command lines or
after prompts. A carriage-return-line-feed combination in the response file
is treated the same as pressing the ENTER key in response to a prompt, or
using a comma in a command line.
Before you use this method, you must set up a response file containing
responses to the LIB prompts. This method lets you conduct the library
session without typing responses to prompts at the keyboard.
A response file has one text line for each prompt. Responses must appear
in the same order as the command prompts appear. Use command symbols
in the response file the same way you would use responses typed on the
keyboard. You can type an ampersand at the end of the response to the
"Operations" prompt and continue typing operations on the next line.
296
pcjs.org
Managing Libraries with LIB
When you run LIB with a response file, the prompts are displayed with
the responses from the response file. If the response file does not contain
responses for all the prompts, LIB uses the default responses.
■ Example
LIBFOR
+CURS0R+HEAP-HEAP*FOIBLES
CROSSLST
The contents of the above response file cause Lffi to delete the module
HEAP from the LIBFOR.LIB library file, copy the module FOIBLES and
place it in an object file named FOIBLES .OBJ, and append the object files
CURSOR.OBJ and HEAP.OBJ as the last two modules in the library. Fi
nally, LIB creates a cross-reference-listing file named CROSSLST.
For each library session, LIB reads and interprets the user's commands as
listed below. It determines whether a new library is being created or an
existing library is being examined or modified.
297
pcjs.org
Microsoft CodeView and Utilities
The listing file contains a list of all public symbols in the index and the
names of the modules in which they are defined. LIB produces the listing
file only if you ask for it during the library session.
LIB never makes changes to the original library; it copies the library and
makes changes to the copy. Therefore, when you terminate LIB for any
reason, you do not lose your original file. It also means that when you run
LH3, enough space must be available on your disk for both the original
library file and the copy.
When you change a library file, LIB lets you specify a different name for
the file containing the changes. If you use this option, the modified library
is stored under the name you give, and the original, unmodified version is
preserved under its own name. If you choose not to give a new name, LIB
gives the modified file the original library name, but keeps a backup copy
of the original library file. This copy has the extension .BAK instead of
.LIB.
298
pcjs.org
Managing Libraries with LIB
Type y to create the file, or n to terminate the library session. This mes
sage is suppressed if the nonexistent library name you give is followed
immediately by commands, a comma, or a semicolon.
You can specify a page size for the library when you create it. The default
page size is 16 bytes. See Section 13.2.11, "Setting the Library Page Size,"
for a discussion of this option.
Once you have given the name of the new library file, you can insert object
modules into the library by using the add command symbol (+) in the
commands field of the command line or at the "Operations" prompt. You
can also add the contents of another library, if you wish. See Section
13.2.3, "Adding Library Modules," and Section 13.2.8, "Combining
Libraries," for a discussion of these options.
However, Lffi lets you keep both the unchanged library file and the newly
changed version, if you like. You can do this by giving the name of a new
library file in the newlibrary field of the command line or at the "Output
library" prompt. The changed library file is stored under the new library-
file name, while the original library file remains unchanged.
If you don't give a new file name, the changed version of the library file
replaces the original library file. Even in this case, LIB saves the original,
unchanged library file with the extension .BAK instead of .LLB. Thus, at
the end of the session you have two library files: the changed version with
the .LEB extension and the original, unchanged version with the .BAK
extension.
299
pcjs.org
Microsoft CodeView and Utilities
To replace a module, LIB deletes the given module, then appends the
object file having the same name as the module. The object file is assumed
to have an .OBJ extension and to reside in the current working directory.
name in the commands field. In the commands field of the command line or
at the "Operations" prompt, give the add command symbol (+) followed
by the name of the library whose contents you wish to add to the library
being changed. When you use this option, you must include the .LIB
extension of the library-file name. Otherwise, LIB assumes that the file is
an object file and looks for the file with an .OBJ extension.
LIB adds the modules of the library to the end of the library being
changed. Note that the added library still exists as an independent library.
LIB copies the modules without deleting them.
Once you have added the contents of a library or libraries, you can save
the new, combined library under a new name by giving a new name in the
newlibrary field of the command line or at the "Output library" prompt. If
you omit the "Output library" response, LLB saves the combined library
under the name of the original library being changed. The original library
is saved with the same base name and the extension .BAK.
You can give the listing file any name and any extension. To cause the list
ing file to be created outside your current working directory, you can
specify a full path name, including drive designation. LIB does not supply
a default extension if you omit the extension.
301
pcjs.org
Microsoft CodeView and Utilities
- files for
perform consistency checks, since LIB automatically checks object
consistency before adding them to the library.
To produce a cross-reference-listing file with a consistency check, invoke
LH3, specify the library name followed by a semicolon, and give the name
of the listing file. LIB then performs the consistency check and creates the
cross-reference-listing file.
/PA[GESIZEj:nMm&er
The number specifies the new page size. It must be an integer value
representing a power of 2 between the values 16 and 32,768.
The page size of a library affects the alignment of modules stored in the
library. Modules in the library are always aligned to start at a position
that is a multiple of the page size (in bytes) from the beginning of the file.
The default page size is 16 bytes for a new library or the current page size
for an existing library.
Note
Because of the indexing technique used by LIB, a library with a large
page size can hold more modules than a library with a smaller page
size. However, for each module in the library, an average of pagesize/2
bytes of storage space is wasted. In most cases, a small page size is
advantageous; you should use a small page size unless you need to put
a very large number of modules in a library.
Another consequence of this indexing technique is that the page size
determines the maximum possible size of the .LLB file. Specifically,
this limit is number * 65,536. For example, /P : 16 means that the
.LIJ3 file has to be smaller than 1 megabyte (16 * 65,536 bytes).
302
pcjs.org
Chapter
AUTOMATING PROGRAM
14
DEVELOPMENT WITH MAKE ^
14.1 Using MAKE 305
14.2 Creating a MAKE Description File 306
14.3 Automating Program Development 309
14.4 Running MAKE 3 11
14.5 Specifying MAKE Options 312
14.6 Using Macro Definitions with MAKE 312
14.6.1 Defining and Specifying Macros 313
14.6.2 Using Macros within Macro Definitions 315
14.6.3 Using Special Macros 315
14.7 Denning Inference Rules 316
pcjs.org
Automating Program Development with MAKE
MAKE SAMPLE
305
pcjs.org
Microsoft CodeView and Utilities
b. For each outfile, the infiles that must change to cause MAKE
to update the outfile
c. The commands that you want MAKE to perform when any of
the infiles change
2. Run MAKE. On the DOS command line, you must specify the
name of the MAKE description file you have created. (You can
also specify options that affect the way in which MAKE operates;
see Section 14.5 for a description of these options.)
The following sections explain how to create a MAKE description file and
run MAKE.
Since a MAKE description file is just a text file, you can use any text edi
tor to create one. You will usually want to give the MAKE description file
the same file name as the program it updates (with no extension); however,
you can use any valid file name.
{macro definition}
306
pcjs.org
Automating Program Development with MAKE
Note
In the example above the pairs of infile names are separated by a
comma. Each pair may also be separated by at least one space.
The following list defines how the fields appearing in a description block
are used:
Field Usage
macro definition Defines one or more MAKE macro definitions. See
Section 14.6 for an explanation of how to use
macro definitions in a MAKE description file.
outfile Specifies the name of a file that you want MAKE
to update automatically. A colon must separate
this field from the infile fields.
infile Specifies the names of any files that the outfile
depends on. For example, if the outfile is an exe
cutable file, the infiles might be object files; if the
outfile is an object file, the infiles might be source
files. The line containing the outfile and infile fields
is known as the "dependency line."
command Specifies the name of an executable file (for exam
ple, LINK) or a DOS internal command.
Note
One way to remember the MAKE description-file format is to think of
it in terms of an "if-then" form: if an outfile is out of date with respect
to any infile, or if an outfile does not exist, then do commands.
The following sections define the rules for using outfile and infile names,
commands, comments, and description blocks in a description file.
307
pcjs.org
Microsoft CodeView and Utilities
The outfile and infile fields must contain valid file names. If any file is not
on the same drive and in the same directory as the description file, you
must include a path specification with the file name.
In any description block, you can give any number of infile names, but
only one outfile name. At least one space or a comma must separate each
pair of infile names. If you have more infile names than can fit on one line,
type a backslash (\) at the end of the current line, and then continue typ
ing names on the next line.
Commands
The command field in a description block can contain any valid DOS com
mand line, consisting of the base name of an .EXE, .COM, or .BAT file
or a DOS internal command. You can give any number of commands, but
each must begin on a new line and each must appear immediately after a
tab or after at least one space.
MAKE carries out this command only if one or more of the infiles in the
description block has been changed since the outfile was created or most
recently updated.
Comments
The comment field must contain a number sign (#), which is a comment
character. MAKE ignores all characters that follow the comment charac
ter on the same line.
If a comment appears on the same line as the outfile name, it must appear
after the infile name(s). If a comment appears on a line where a command
is expected (but no command is written), the comment character (#) must
be the first character on the line; no leading spaces are allowed.
Description Blocks
You can give any number of description blocks in a description file. You
must make sure, however, that a blank line appears between the last line
of one description block and the first line of the next.
308
pcjs.org
Automating Program Development with MAKE
The order in which you place the description blocks is important. MAKE
examines each description block in turn and makes its decision to carry
out the command in that block based on the last-modification dates of the
outfile and infiles. If a command in a later description block changes a file
used in an earlier description block, MAKE has no way to return to that
earlier description block to update files that depend on the changed files.
■ Example
MODI.OBJ: MODI.ASM
MASM MODI;
M 0 D 2 . 0 B J : M 0 D 2 . C # C o m m e n t a l l o w e d a f t e r i n fi l e
# C o m m e n t b e f o r e c o m m a n d m u s t s t a r t i n fi r s t c o l u m n
CL /c /AL M0D2.C #Comment allowed here
M0D3.OBJ: M0D3.FOR
FL /c M0D3.F0R
The sample description file tells MAKE how to update or create four
outfiles: MODI. OBJ, M0D2 . OBJ, M0D3 . OBJ, and EXAMPLE.EXE. To
update or create an object file, MAKE invokes the appropriate assembler
or compiler. To update or create EXAMPLE .EXE, MAKE will link the
three object files.
Note that the description blocks appear in the order in which the outfiles
are updated or created. Thus, MAKE updates MODI. OBJ, M0D2 . OBJ,
and M0D3 . OBJ (or creates them, if necessary) before it updates or creates
EXAMPLE .EXE. Thus, after MAKE is run, any changes to the source files
will be reflected in EXAMPLE .EXE.
309
pcjs.org
Microsoft CodeView and Utilities
W0RK1.0BJ: W0RK1.C
CL /c /AL W0RK1.C
W0RK2.OBJ: W0RK2.FOR
FL /c W0RK2.F0R
WORK.EXE: W0RK1.0BJ WORK2.0BJ \LIB\LIBV3.LIB
LINK /CO W0RK1.0BJ+W0RK2.OBJ,WORK,,\LIB\LIBV3.LIB
Each time you finish debugging the program's files, invoke MAKE with
the following command line:
MAKE WORK
MAKE carries out the following three steps (each step corresponds to a
description block):
1. Checks to see if W0RK1. C has been changed since the last time
W0RK1 .OBJ was changed (in other words, you've made a change to
the source file since the last compile). If so, it carries out the given
CL command to recompile W0RK1. C.
2. Checks W0RK2 . FOR in the same way it checked WORKl. C in Step
1. Note that if only one of the files has been changed, then only
that file is recompiled. For example, if you change WORKl. C but
not W0RK2 . FOR, then only WORKl. C is recompiled; but if each
source file has been changed since its last compile, then each is now
recompiled.
3. Checks to see if the object files WORKl. OBJ and WORK2 . OBJ or
the library file LIBV3.LIB has been changed since the last time
the modules were linked. If either of the object files has been
recompiled, or if the library file has been changed, then MAKE
relinks the program.
If you run MAKE with this description file immediately after you create
the source files WORKl. C and W0RK2 . FOR, MAKE carries out Steps 1
and 2 to compile these source files (since in each case the outfile does not
exist), then links them in Step 3.
If you invoke MAKE again without changing any of the infiles, MAKE
does not execute any commands.
310
pcjs.org
Automating Program Development with MAKE
If you change one of the object files WORKl. OBJ or W0RK2 . OBJ, MAKE
relinks that file and then relinks the program in Step 3.
If you change the library file LIBV3 .LIB, but make no other changes,
MAKE skips Steps 1 and 2, but relinks the program in Step 3 (as
specified in the last description block).
Option Meaning
311
pcjs.org
Microsoft CodeView and Utilities
To invoke a MAKE option, type the option on the MAKE command line
in the options field. The following list describes each option available with
MAKE and how the option affects how MAKE operates.
Option Action
Macro definitions let you associate a name with text in a description file,
and then use the name instead of the text wherever the text appears in a
description file. This feature makes it easier to update a description file
when one of the names used in the file changes: when you update a macro
definition, the corresponding text is updated wherever the macro appears
in the definition file. Thus, you can change the text throughout the
description file without having to edit every line that uses the particular
text.
You might want to use macro definitions to perform operations such as the
following:
1. Specifying the base names of source, object, and executable files
under development. If the program name changes, you only need
to change the base name in the macro definition; then the base
name is changed automatically for the source, object, and execut
able files given in the description file.
312
pcjs.org
Automating Program Development with MAKE
name-text
After you define a macro, use the following to include the macro in the
description file:
%(name)
Wherever the pattern %(name) appears in the description file, that pattern
is replaced by text. The name is converted to uppercase; for example, the
names flags and FLAGS are equivalent. If you define a macro name but
leave text blank, text will be a null string.
For name, you can also use any environment variable that is defined in the
current environment in a macro definition. For example, if the environ
ment variable PATH is defined in the current environment, the value of
PATH will replace any occurrences of $(PATH) in the description file.
You can give macro definitions in either of the following two places:
If the same name is defined in more than one place, the following order of
precedence applies:
1. Command-line definition
2. Description-file task definition
3. Environment definition
313
pcjs.org
Microsoft CodeView and Utilities
■ Example
base=ABC
debug="/CO"
$ (base).OBJ: $ (base).OBJ
LINK $(base).OBJ
In this description file, macro definitions are given for the names base and
debug.
The base macro defines the base name of the object and executable files
being maintained. MAKE replaces each occurrence of $(base) with the
text ABC. If the program name changes, you would only have to replace
ABC in the macro definition with the new program name to change the
base name of the two files.
The debug macro tells the linker to prepare a special executable file con
taining symbolic data and line-number information.
If you want to override one of the macro values in this description file, you
can give a new macro definition on the MAKE command line, as shown in
the following example:
If you do not want the special executable file created during linking, you
could run MAKE with the following command line:
Since you give a blank value for debug (note the white space between the
equal sign and the MAKE description-file name), it will be treated as a
null string. Because definition on the command line has higher precedence
than the definition in the description file, the $(debug) macro becomes a
null string. Thus, the linker does not prepare the special executable file for
debugging.
314
pcjs.org
Automating Program Development with MAKE
LIBS=$(DLIB)\LIBV3.LIB $ (DLIB)\GRAPHICS.LIB
You could then run MAKE and specify the definition for the macro
named $ (DLIB) on the command line, as shown in the following example:
In this case, every occurrence of the macro $(DLIB) in the description file
would be expanded to C:\LIB, so the definition of the LIBS macro in the
description file would be expanded to the following:
LIBS=C:\LIB\LIBV3.LIB C:\LIB\GRAPHICS.LIB
Be careful to avoid infinitely recursive macros such as the following:
A = $ (B)
B = $ (C)
C = $ (A)
In the example above, if the macro $(B) is undefined, all of these macros
will be undefined, as well.
N a m e Va l u e S u b s t i t u t e d
■ Example
315
pcjs.org
Microsoft CodeView and Utilities
Often, you use MAKE to perform updates on one type of file when a file
of another type is changed. For example, you often use MAKE to update
object files when source files change or to update executable files when
object files change.
MAKE allows you to define rules, known as "inference rules," that allow
you to give a single command to convert all files with a given extension to
files with a different extension. For example, you can use inference rules to
specify a single LINK command that changes any object file (which has an
extension of .OBJ) to an executable file (which has an extension of
.EXE). You would not have to include the LINK command in each block
in which you link a object file.
.inextension.outextension:
command
{command}
In this format, command specifies one of the commands that you must use
to convert files with extension inextension to files with extension outexten-
sion. Using the earlier example of converting source files to object files,
inextension would be .OBJ, outextension would be .EXE, and command
would be the LINK command with any appropriate command-line
options.
If MAKE finds a description block without an explicit command, it looks
for an inference rule that matches both the outfile extension and the infile
extension. If it finds such a rule, MAKE carries out any commands given
in the rule.
316
pcjs.org
Automating Program Development with MAKE
■ Example
.OBJ.EXE:
LINK $*.OBJ;
EXAMPLE1.EXE: EXAMPLE1.0BJ
EXAMPLE2.EXE: EXAMPLE2.OBJ
LINK /CO EXAMPLE2,,,LIBV3.LIB
In the sample description file above, line 1 defines an inference rule that
executes the LINK command on line 2 to create an object file whenever a
change is made in the corresponding object file. The file name in the infer
ence rule is specified with the special macro name $* so that the rule
applies to any base name with the . OBJ extension.
When MAKE encounters a line containing an outfile and one or more
infiles, it first looks for commands on the next line. When it does not find
any commands, MAKE checks for a rule that may apply and finds the
rule defined in lines 1 and 2 of the description file. MAKE applies the
rule, replacing the $* macro with EXAMPLE1 when it executes the com
mand, so that the LINK command becomes
LINK EXAMPLEl.OBJ;
When MAKE reaches the line containing the EXAMPLE2 .EXE outfile it
does not search for a dependency rule, since a command is explicitly given
for this outfile/infile relationship.
317
pcjs.org
Chapter
USING EXEPACK, EXEMOD,
15
SETENV, AND ERROUT
15.1 Compressing Executable
F i l e s w i t h t h e E X E PA C K U t i l i t y 3 2 1
15.2 Modifying Program
Headers with the EXEMOD Utility 322
15.3 Enlarging the DOS
Environment with the SETENV Utility 326
15.4 Redirecting Error Output
with the EBROUT Utility 328
pcjs.org
Using EXEPACK, EXEMOD, SETENV, and ERROUT
The following utilities allow you to modify files and change the operating
environment:
Utility Function
Microsoft EXE File Compresses executable files by remov-
^?iHP^sslon Utility ing sequences of repeated characters
( . k X b PA C K ) f r o m t h e fi l e a n d b y o p t i m i z i n g t h e r e l o
cation table.
Microsoft EXE File Header Modifies header information in execut-
U t i h t y ( E X E M O D ) a b l e fi l e s .
Microsoft Environment Enlarges the DOS environment table in
S$SE££« tlhty IBM PC-D°S Versions 2.0, 2.1, 3.0, and
(SETENV) 3.1. SETENV allows you to use more
and/or larger environment variables.
Microsoft STDERR Redirects standard error output from
( E R R O U T ) a n y c o m m a n d t o a g i v e n fi l e o r d e v i c e -
EXEPACK does not always give a significant saving in disk space, and
may sometimes actually increase file size because of an enhanced .EXE
loader However programs that have approximately 500 or more entries in
the relocation table and long streams of repeated characters will usually
be shorter and take less time to load if packed.
pcjs.org
321
Microsoft CodeView and Utilities Guide
The executablefile is the file to be packed and packedfile is the name for the
packed file. The packedfile should have a different name or be on a difler-
ent drive or directory. EXEPACK will not pack a file onto itself.
Note
Using EXEPACK removes all symbolic debug information from exe
cutable files.
■ Example
The EXEMOD utility allows you to modify fields in the header of an exe
cutable file. Some of the options available with EXEMOD are the same
as LINK options, except that they work on files that have already been
linked. Unlike the LINK options, the EXEMOD options require that
values be specified as hexadecimal numbers.
To display the current status of the header fields, type the following:
EXEMOD executablefile
pcjs.org
322
Using EXEPACK, EXEMOD, SETENV, and ERROUT
To modify one or more of the fields in the file header, type the following:
The EXEMOD options are shown with the forward slash (/) designator,
but a dash (-) may also be used. Options can be given in either uppercase
or lowercase, but they cannot be abbreviated. The EXEMOD options and
their effects are described in the following list:
Option Effect
323
pcjs.org
Microsoft CodeView and Utilities Guide
Note
Use of the /STACK option on programs developed with other than
Mcrosoft compilers or assemblers may cause the programs to fail, or
EXEMOD may return an error message.
p a c k e d fi l e
■ Example
M i c r o s o f t ( R ) E X E F i l e H e a d e r U t i l i t y Ve r s i o n 4 . 0 2
Copyright (C) Microsoft Corp 1985. All rights reserved.
TEST.EXE (hex) (dec)
The display above shows how EXEMOD would display the current file
header for file TEST.EXE. Note that (para) refers to paragraphs, which
are units of 16 bytes. To translate paragraphs to bytes, multiply by 16.
The meaning of each field is given below.
324
pcjs.org
Using EXEPACK, EXEMOD, SETENV, and ERROUT
.EXE size is the size of the file as stored on disk. Minimum load
size is the total amount of memory that DOS must provide in order for
the program to execute.
■ Examples
>EXEMOD TEST.EXE
The command in this example will show the display in the previous exam
ple, for the file TEXT.EXE.
325
pcjs.org
Microsoft CodeView and Utilities Guide
The example above uses the EXEMOD command line to modify the
header fields in TEST.EXE.
>EXEMOD TEST.EXE
M i c r o s o f t ( R ) E X E F i l e H e a d e r U t i l i t y Ve r s i o n 4 . 0 2
Copyright (C) Microsoft Corp 1985. All rights reserved.
T E S T. E X E (hex) (dec)
.EXE size (bytes) 439D 17309
Minimum load size (bytes) 528D 20877
Overlay number 0 0
Initial CS:IP 0403 :0000
Initial SS:SP 0000 :00FF 256
Minimum allocation (para) FF 256
Maximum allocation (para) FFF 4095
Header size (para) 20 32
Relocation table offset IE 30
Relocation entries 1 1
The last example shows the current status of the header for TEST.EXE
after being altered by the previous example.
326
pcjs.org
Using EXEPACK, EXEMOD, SETENV, and ERROUT
Note
SETENV will work with most MS-DOS and PC-DOS operating sys
tems, Versions 2.0 through 3.1. If SETENV does not work with your
version of COMMAND.COM, please contact Mcrosoft Technical
Support.
If you use DOS 3.2 or later, you can set the environment space with
the DOS SHELL command. For example, the following command will
set the environment size at 3000 bytes when placed in CONFIG.SYS:
■ Examples
>SETENV C0MMAND.COM
M i c r o s o f t ( R ) E n v i r o n m e n t E x p a n s i o n U t i l i t y Ve r s i o n 2 0 1
Copyright (C) Microsoft Corp 1985,1986. All rights reserved.
command.com: Environment allocation = 160
pcjs.org
327
Microsoft CodeView and Utilities Guide
By default, standard output and standard error output from a DOS pro
gram are directed to the terminal. The ERROUT utility allows you to
execute any legal DOS command-line (including an executable or batch
file, as well as arguments) and redirect standard error output to a specified
file or device.
The ERROUT command-line format is as follows:
Note
With ERROUT, you may use the DOS redirection operators > and
>> just as you normally would. However, their effects change some
what; only standard output is redirected to the file indicated by > or
>>. Standard error is redirected to standarderrorfile.
pcjs.org
328
Using EXEPACK, EXEMOD, SETENV, and ERROUT
■ Examples
In the example above, the entire command line beginning with CL is exe
cuted. All of the command-line arguments /AL, /Zi, /CO, and demo.c
modify the CL command as they normally would. Error output if any is
sent to C_ERRORS. DOC.
In the example above, the DOS command line MASM /ZI TEST, , ; is
executed, and standard error output is sent to the printer (which is the
device indicated by PRN).
329
pcjs.org
Appendixes
A Regular Expressions 333
B Using Exit Codes 341
C Error Messages 347
331
pcjs.org
Appendix A
Regular Expressions
333
pcjs.org
Regular Expressions
A.1 Introduction
Regular expressions are used to specify text patterns in searches for vari
able text strings. Special characters can be used within regular expressions
to specify groups of characters to be searched for.
This appendix explains all of the special characters you can use to form
regular expressions, but you do not need to learn them all to use the Code
View Search commands. The simplest form of regular expression is simply
a text string. For example, if you want to search for all instances of the
symbol COUNT, you can specify COUNT as the string to be found.
If you only want to search for simple strings, you do not need to read this
entire appendix, but you should know how to search for strings containing
the special characters used in regular expressions. See Section A.3 for more
information.
Character Purpose
335
pcjs.org
Microsoft CodeView and Utilities
P e r i o d ( . ) M a t c h e s a n y c h a r a c t e r.
If you need to match one of the special characters used in regular expres
sions, you must precede it with a backslash when you specify a search
string. The special characters are the asterisk (*). backslash (\), left
bracket ([), caret (*), dollar sign ($), and period (.).
Note that when you use the period as a wild card, you will find the strings
you are looking for, but you may also find other strings that you aren't
interested in. You can use brackets to be more exact about the strings you
want to find.
pcjs.org
338
Regular Expressions
match. This method is more exact than using a period to match any char
acter.
For example, the regular expression x [-+/*]y matches x+y, x-y, x/y,
or x*y, but not x=y or xzy. The regular expression COUNT [12] matches
C0UNT1 and C0UNT2, but not C0UNT3.
You can combine ASCII ranges of characters with other listed characters.
For example, [A-Za-z ] matches any uppercase or lowercase letter or a
space.
The dash has this special meaning only if you use it to separate two ASCII
characters. It has no special meaning if used directly after the starting
bracket or directly before the ending bracket. This means that you must
be careful where you place the dash (minus sign) within brackets.
For example, you might use the regular expression [ + -/*] to match the
characters +, -, /, and *. However, this does not give the intended result.
Instead it matches the characters between + and / and also the character
*. To specify the intended characters, put the dash first or last in the list:
[-+/*] or [+/*-].
If the caret is not in the first position within the brackets, it is treated as
an ordinary character. For example, the expression [0-9"] matches any
digit or a caret.
337
pcjs.org
Microsoft CodeView and Utilities
For example, the regular expression IF * TEST will match any number of
repetitions of the space character that follow the word "if."
IF TEST
IF TEST
IF TEST
IFTEST
Notice that the last example contains zero repetitions of the space
character.
The asterisk is convenient if the text you are searching for might contain
some spaces, but you don't know the exact number. (Be careful in this
situation: you can't be sure if the text contains a series of spaces or a tab.)
You might also use the asterisk to search for a symbol when you aren't
sure of the spelling. For example, you could use first* ime if you aren't
sure if the identifier you are searching for is spelled firsttime or firs-
time.
338
pcjs.org
Regular Expressions
You can use brackets with the asterisk to search for a sequence of repeated
characters of a given type. For example, \ [ [0-9] *] matches number
strings within brackets ([1353] or [3] ), but does not match character
strings within brackets ([count]). Empty brackets ([ ]) are also
matched, since the characters in the brackets are repeated zero times.
You can combine both symbols to search for entire lines. For example,
"{$ matches any line consisting of only a left curly brace in the left mar
gin, and ~$ matches blank lines.
339
pcjs.org
Appendix R
Using rxtt (Hopes
341
pcjs.org
Using Exit Codes
Most of the utilities return some exit code (sometimes called an "error-
level" code) that can be used by DOS batch files or other programs such as
MAKE. If the program finishes without errors, it returns an exit code 0.
The code returned varies if the program encounters an error. This appen
dix discusses several uses for exit codes and lists the exit codes that can be
returned by each utility.
For example, assume the MAKE description file TEST contains the fol
lowing lines:
TEST.OBJ : TEST.FOR
FL /c TEST.FOR
If you prefer to use DOS batch files instead of MAKE description files,
you can test the code returned with the IF command. The following sam
ple batch file, called COMPILE . BAT, illustrates how to do this:
CL /c %1
IF NOT ERRORLEVEL 1 LINK %1;
IF NOT ERRORLEVEL 1 %1
You can execute this sample batch file with the following command:
COMPILE TEST.C
343
pcjs.org
Microsoft CodeView and Utilities
DOS then executes the first line of the batch file, substituting TEST. C for
the parameter %1, as in the following command line:
CL /c TEST.C
LINK TEST;
LINK also returns a code, which will be tested by the third line.
0 No error
1 Any LINK fatal error
344
pcjs.org
Using Exit Codes
0 No error
1 Any LIB fatal error
0 No error
2 Program error
4 System error—out of memory
If a program called by a command in the MAKE description file produces
an error, the exit code will be displayed in the MAKE error message.
0 No error
1 A n y E X E PA C K f a t a l e r r o r
0 No error
1 Any EXEMOD fatal error
0 No error
1 Any SETENV fatal error
345
pcjs.org
Microsoft CodeView and Utilities
0 No error
1 Any ERROUT fatal error
346
pcjs.org
Appenpix r
EEBQR Messages
347
pcjs.org
pcjs.org
Error Messages
B a d fl a g
You specified an invalid flag mnemonic with the Register dialog; com
mand (R). b
Use one of the mnemonics displayed when you enter the command RF.
349
pcjs.org
Microsoft CodeView and Utilities
Bad register
You typed the Register command (R) with an invalid register name.
Use AX, BX, CX, DX, SP, BP, SI, DI, DS, ES, SS, CS, B?, or F.
Bad subscript
You entered an illegal subscript expression for an array, such as
I ARRAY (3.3) or I ARRAY ((3,3)). The correct expression for this
example (in BASIC or FORTRAN) would be IARRAY (3,3).
Bad type cast
The types of the operands in an expression are incompatible.
Divide by zero
An expression in an argument of a dialog command attempts to divide
by zero.
EMM error
The debugger is failing to use EMM correctly. Please contact Mcrosoft
Corporation using the Mcrosoft Product Assistance Request form at
the back of one of your manuals.
351
pcjs.org
Microsoft CodeView and Utilities
Illegal instruction
This message usually indicates that a divide-by-zero machine instruc
tion was attempted.
352
pcjs.org
Error Messages
I n v a l i d e x e c u t a b l e fi l e f o r m a t - p l e a s e r e l i n k
The executable file was not linked with the version of the linker
released with this version of the CodeView debugger Relink with the
more current version of the linker.
Invalid option
The option specified cannot be used with the CodeView Option
command.
Missing '"'
You specified a string as an argument to a dialog command, but you
did not supply a closing double quotation mark.
Missing '('
An argument to a dialog command was specified as an expression con
taining a right parenthesis, but no left parenthesis.
Missing ')'
An argument to a dialog command was specified as an expression con
taining a left parenthesis, but no right parenthesis.
Missing ']'
An argument to a dialog command was specified as an expression con
taining a left bracket, but no right bracket.
This error message can also occur if a regular expression is specified
with a right bracket but no left bracket.
pcjs.org
353
Microsoft CodeView and Utilities
354
pcjs.org
Error Messages
N o s u c h fi l e / d i r e c t o r y
A file you specified in a command argument or in response to a prompt
does not exist.
For instance, the message appears when you select Load from the File
menu and then enter the name of a nonexistent file.
No symbolic information
The program file you specified is not in the CodeView format.
You cannot debug in source mode unless you recreate the file in the
CodeView format. However, you can debug in assembly mode.
N o t a t e x t fi l e
You attempted to load a file by using the Load selection from the File
menu or using the View command, but the file is not a text file.
The CodeView debugger determines if a file is a text file by checking
the first 128 bytes for characters that are not in the ASCII ranges 9 to
13 and 20 to 126.
N o t a n e x e c u t a b l e fi l e
The file you specified to be debugged when you started the CodeView
debugger is not an executable file having the extension .EXE or
.COM.
Not enough space
You typed the Shell Escape command (!) or selected Shell from the File
menu, but there is not enough free memory to execute
COMMAND.COM.
Since memory is released by code in the FORTRAN start-up routines,
this error always occurs if you try to use the Shell Escape command
before you have executed any code. Use any of the code-execution com
mands (Trace, Program Step, or Go) to execute the FORTRAN start
up code, then try the Shell Escape command again. The message also
occurs with assembly-language programs that do not specifically
release memory.
355
pcjs.org
Microsoft CodeView and Utilities
356
pcjs.org
Error Messages
Syntax error
You specified an invalid command line for a dialog command.
Check for an invalid command letter. This message also appears if you
enter an invalid assembly-language instruction using the Assemble
command. The error will be preceded by a caret that points to the first
character the CodeView debugger could not interpret.
Too few array bounds given
The bounds you specified in an array subscript do not match the array
declaration.
For example, given the array declaration INTEGER IARRAY (3,4),
the expression IARRAY (I) would produce this error message.
Too many array bounds given
The bounds you specified in an array subscript do not match the array
declaration.
For example, given the array declaration INTEGER IARRAY (3 4)
the expression IARRAY (1, 3, J) would produce this error message.'
Too many breakpoints
You tried to specify a 21st breakpoint; the CodeView debugger only
permits 20.
Too many open files
You do not have enough file handles for the CodeView debugger to
operate correctly.
You must specify more files in your CONFIG.SYS file. See the DOS
pcjs.org
357
Microsoft CodeView and Utilities
You must specify more files in your CONFIG.SYS file. See the DOS
user's guide for information on using the CONFIG.SYS file.
Unknown symbol
You specified an identifier not in the CodeView debugger's symbol
table.
Check for a misspelling. This message may also occur if you try to use
a local variable in an argument when you are not in the routine where
the variable is defined. The message also occurs when a subroutine
that uses alternate returns is called and the values of the return labels
in the actual parameter list are not 0.
358
pcjs.org
Error Messages
This section lists and describes error messages generated by the Mcrosoft
Overlay Linker, LINK.
Fatal errors cause the linker to stop execution. Fatal error messages have
the following format:
pcjs.org
359
Microsoft CodeView and Utilities
file and has a module name, the module name is enclosed in parentheses,
as shown in the following examples:
S L I B C . L I B ( _ fi l e )
MAIN.OBJ(main.c)
TEXT.OBJ
The following error messages may appear when you link object files with
the Microsoft Overlay Linker, LINK.
pcjs.org
360
Error Messages
361
pcjs.org
Microsoft CodeView and Utilities
362
pcjs.org
Error Messages
L 1 0 5 3 s y m b o l t a b l e o v e r fl o w
The program had more than 256K of symbolic information
(such as public, external, segment, group, class, and file
names).
Combine modules or segments and re-create the object files.
Eliminate as many public symbols as possible.
363
pcjs.org
Microsoft CodeView and Utilities
L 1 0 8 0 c a n n o t o p e n l i s t fi l e
The disk or the root directory was full.
Delete or move files to make space.
L 1 0 8 1 o u t o f s p a c e f o r r u n fi l e
The disk was full on which the .EXE file was being written.
Free more space on the disk and restart the linker.
L 1 0 8 3 c a n n o t o p e n r u n fi l e
The disk or the root directory was full.
Delete or move files to make space.
L 1 0 8 4 c a n n o t c r e a t e t e m p o r a r y fi l e
The disk or root directory was full.
Free more space in the directory and restart the linker.
L 1 0 8 5 c a n n o t o p e n t e m p o r a r y fi l e
The disk or the root directory was full.
Delete or move files to make space.
L 1 0 8 6 s c r a t c h fi l e m i s s i n g
An internal error has occurred.
Note the circumstances of the problem and contact Mcro
soft Corporation using the Mcrosoft Product Assistance
Request form at the back of one of your manuals.
L 1 0 8 7 u n e x p e c t e d e n d - o f - fi l e o n s c r a t c h fi l e
The disk with the temporary linker-output file was
removed.
384
pcjs.org
Error Messages
L1088 o u t o f s p a c e f o r l i s t fi l e
The disk (where the listing file was being written) is full.
Free more space on the disk and restart the linker.
365
pcjs.org
Microsoft CodeView and Utilities
L I 1 0 4 fi l e n a m e : n o t v a l i d l i b r a r y
The specified file was not a valid library file. This error
causes LINK to abort.
L 111 3 u n r e s o l v e d C O M D E F ; i n t e r n a l e r r o r
Note the circumstances of the failure and contact Mcrosoft
Corporation using the Mcrosoft Product Assistance
Request form at the back of one of your manuals.
L 1 1 1 4 fi l e n o t s u i t a b l e f o r / E X E P A C K ; r e l i n k
without
For the linked program, the size of the packed load image
plus packing overhead was larger than that of the
unpacked load image.
Relink without the /EXEPACK option.
L 11 2 6 s t a r t i n g a d d r e s s _ _ a u l s t a r t n o t f o u n d
You tried to create a Quick library without linking with the
required LD3 library.
L 2 0 0 1 fi x u p ( s ) w i t h o u t d a t a
A FIXUPP record occurred without a data record immedi
ately preceding it. This is probably a compiler error. (See
the Microsoft MS-DOS Programmer's Reference for more
information on FLXUPP.)
L 2 0 0 2 fi x u p o v e r fl o w n e a r n u m b e r i n f r a m e s e g
segname target seg segname target of fset. number
The following conditions can cause this error:
• A group is larger than 64K.
• The program contains an intersegment short jump
or intersegment short call.
• The name of a data item in the program conflicts
with that of a library subroutine included in the
link.
366
pcjs.org
Error Messages
367
pcjs.org
Microsoft CodeView and Utilities
EXIT in file(s):
MAIN.OBJ (main.for)
OPEN in file(s):
MAIN.OBJ (main.for)
368
pcjs.org
Error Messages
369
pcjs.org
Microsoft CodeView and Utilities
L 4 0 5 3 V M . T M P : i l l e g a l fi l e n a m e ; i g n o r e d
VM.TMP appeared as an object-file name.
Rename the file and rerun the linker.
L 4 0 5 4 fi l e n a m e : c a n n o t fi n d fi l e
The linker could not find the specified file.
Enter a new file name, a new path specification, or both.
U 11 5 0 p a g e s i z e t o o s m a l l
The page size of an input library was too small, which indi
cates an invalid input .LD3 file.
U 1 1 5 1 s y n t a x e r r o r : i l l e g a l fi l e s p e c i fi c a t i o n
A command operator such as a minus sign (-) was given
without a following module name.
U 11 5 2 s y n t a x e r r o r : o p t i o n n a m e m i s s i n g
A forward slash (/) was given without an option after it.
370
pcjs.org
Error Messages
371
pcjs.org
Microsoft CodeView and Utilities
U1181 w r i t e t o l i b r a r y fi l e f a i l e d
The disk or root directory was full.
Delete or move files to make space.
372
pcjs.org
Error Messages
U 1 1 8 2 fi l e n a m e : c a n n o t c r e a t e e x t r a c t fi l e
The disk or root directory was full, or the specified extract
file already existed with read-only protection.
Make space on the disk or change the protection of the
extract file.
U 1 1 8 3 c a n n o t o p e n r e s p o n s e fi l e
The response file was not found.
U 11 8 4 u n e x p e c t e d e n d - o f - fi l e o n c o m m a n d i n p u t
An end-of-file character was received prematurely in
response to a prompt.
U 11 8 5 c a n n o t c r e a t e n e w l i b r a r y
The disk or root directory was full, or the library file
already existed with read-only protection.
Make space on the disk or change the protection of the
library file.
U 11 8 6 e r r o r w r i t i n g t o n e w l i b r a r y
The disk or root directory was full.
Delete or move files to make space.
U 11 8 7 c a n n o t o p e n V M . T M P
The disk or root directory was full.
Delete or move files to make space.
U 11 8 8 c a n n o t w r i t e t o V M
Note the circumstances of the failure and notify Mcrosoft
Corporation by using the Mcrosoft Product Assistance
Request form at the back of one of your manuals.
U 11 8 9 c a n n o t r e a d f r o m V M
Note the circumstances of the failure and notify Microsoft
Corporation by using the Mcrosoft Product Assistance
Request form at the back of one of your manuals.
373
pcjs.org
Microsoft CodeView and Utilities
U2152 fi l e n a m e : c a n n o t c r e a t e l i s t i n g
The directory or disk was full, or the cross-reference-listing
file already existed with read-only protection.
Make space on the disk or change the protection of the
cross-reference-listing file.
U2155 modulename : module not in library; ignored
The specified module was not found in the input library.
374
pcjs.org
Error Messages
U 4 1 5 6 l i b r a r y n a m e : o u t p u t - l i b r a r y s p e c i fi c a t i o n
ignored
An output library was specified in addition to a new library
name. For example, specifying
L I B n e w. l i b + o n e . o b j , n e w. 1 s t , n e w. l i b
where new. lib does not already exist, causes this error.
U 1 0 0 1 m a c r o d e fi n i t i o n l a r g e r t h a n n u m b e r
A single macro was defined to have a value string longer
than the number stated, which is the maximum.
Try rewriting the MAKE description file to split the macro
into two or more smaller ones.
U 1 0 0 2 i n fi n i t e l y r e c u r s i v e m a c r o
A circular chain of macros was defined, as in the following
example:
375
pcjs.org
Microsoft CodeView and Utilities
A=$(B)
B=$(C)
C=$(A)
376
pcjs.org
Error Messages
U 1 0 11 fi l e n a m e : n o t e n o u g h m e m o r y
Not enough memory was available for MAKE to execute a
program.
U 1 0 1 2 fi l e n a m e : u n k n o w n e r r o r
Note the circumstances of the failure and notify Mcrosoft
Corporation by using the Mcrosoft Product Assistance
Request form at the back of one of your manuals.
U1013 command : error encode
One of the programs or commands called in the MAKE
description file returned with a nonzero error code.
U 4 0 0 0 fi l e n a m e : t a r g e t d o e s n o t e x i s t
This usually does not indicate an error. It warns the user
that the target file does not exist. In many cases the outfile
will be created by a later command in the MAKE descrip
tion file.
U 4 0 0 1 d e p e n d e n t fi l e n a m e d o e s n o t e x i s t ; t a r g e t
filename not built
MAKE could not continue because a required infile did not
exist.
Make sure that all named files are present and spelled
correctly in the MAKE description file.
U4013 command : error encode (ignored)
One of the programs or commands called in the MAKE
description file returned with a nonzero error code, and
MAKE was run with the /I option. MAKE ignores the
error and continues.
U4014 usage : make [/n] [/d] [/i] [/s]
[ n a m e = v a l u e . . . ] fi l e
MAKE has not been invoked correctly.
Try entering the command line again with the syntax
shown in the message.
377
pcjs.org
Microsoft CodeView and Utilities
N u m b e r E X E PA C K E r r o r M e s s a g e
U 1 1 0 0 o u t o f s p a c e o n o u t p u t fi l e
The disk or root directory is full.
Delete or move files to make space.
U 1 1 0 1 fi l e n a m e : fi l e n o t f o u n d
The file specified by filename could not be found.
U 11 0 2 fi l e n a m e : p e r m i s s i o n d e n i e d
The file specified by filename was a read-only file.
U 1 1 0 3 c a n n o t p a c k fi l e o n t o i t s e l f
It is illegal to specify the same file for both input and out
put. Change one of the file names.
U 1 1 0 4 u s a g e : e x e p a c k < i n fi l e > < o u t fi l e >
The EXEPACK command line was not specified properly.
Try again using the syntax shown.
U 1 1 0 5 i n v a l i d . E X E fi l e ; b a d h e a d e r
The given file was not an executable file or it had an invalid
file header.
378
pcjs.org
Error Messages
N u m b e r E X E PA C K E r r o r M e s s a g e
U 11 0 6 c a n n o t c h a n g e l o a d - h i g h p r o g r a m
When the minimum allocation value and the maximum
allocation value are both 0, the file cannot be compressed.
U 1 1 0 7 c a n n o t p a c k a l r e a d y - p a c k e d fi l e
The file specified for EXEPACK had already been packed
using EXEPACK.
U 1 1 0 8 i n v a l i d . E X E fi l e ; a c t u a l l e n g t h l e s s t h a n
reported
The second and third fields in the file header indicated a file
size greater than the actual size.
U 11 0 9 o u t o f m e m o r y
The EXEPACK utility did not have enough memory to
operate.
U 111 0 e r r o r r e a d i n g r e l o c a t i o n t a b l e
The file could not be compressed because the relocation
table could not be found or was invalid.
U l l l l fi l e n o t s u i t a b l e f o r p a c k i n g
The packed load image of the specified file was larger than
the unpacked load image, so the file could not be packed.
U 111 2 fi l e n a m e : u n k n o w n e r r o r
An unknown system error occurred while the specified file
was being read or written.
Try running EXEPACK again.
U 4 1 0 0 o m i t t i n g d e b u g d a t a f r o m o u t p u t fi l e
EXEPACK strips symbolic debug information from the
input file before packing.
You may also encounter DOS error messages if the EXEPACK program
cannot read from, write to, or create a file.
379
pcjs.org
Microsoft CodeView and Utilities
Error messages from the Mcrosoft EXE File Header Utility, EXEMOD,
have one of the following formats:
U 1 0 5 1 i n v a l i d . E X E fi l e : b a d h e a d e r
The specified input file is not an executable file or it has an
invalid file header.
U 1 0 5 2 i n v a l i d . E X E fi l e : a c t u a l l e n g t h l e s s t h a n
reported
The second and third fields in the input-file header indicate
a file size greater than the actual size.
U 1 0 5 4 fi l e n o t . E X E
EXEMOD automatically appends the .EXE extension to
any file name without an extension; in this case, no file with
the given name and an .EXE extension could be found.
U 1 0 5 5 fi l e n a m e : c a n n o t fi n d fi l e
The file specified by filename could not be found.
380
pcjs.org
Error Messages
U 1 0 5 6 fi l e n a m e : p e r m i s s i o n d e n i e d
The file specified by filename was a read-only file.
U4050 p a c k e d fi l e
The given file was a packed file. This is a warning only.
381
pcjs.org
Microsoft CodeView and Utilities
U1085 fi l e n a m e : c a n n o t fi n d fi l e
The specified file was not found, perhaps because it was a
directory or some other special file.
U1086 filename : permission denied
The specified file was a read-only file.
Messages that indicate errors on the command line used to invoke the
compiler have one of the following formats:
command line error Ulza;x: messagetext
execution error U2axi:: messagetext
382
pcjs.org
Error Messages
U1251 no arguments
No arguments were specified to ERROUT.
383
pcjs.org
pcjs.org
CodeView and T Ttilities Tndex
& (ampersand), LIB command symbol, < (less-than sign), Redirected Input
295 command,
* (asterisk) - (minus sign) 243
Comment command, 246 FORTRAN, 82
FORTRAN multiplication operator, LIB command symbol, 292, 297, 300
82 -* (minus sign-asterisk), LIB command
LIB command symbol, 292, 297, 300 symbol, 292, 300
regular expressions, used in, 338 -+ (minus sign-plus sign), LIB
** (asterisks), exponentiation operator, command symbol, 292, 294, 300
FORTRAN, 82 # (number sign)
@ (at sign) NAN (not a number), 139
Redraw command, 233 Tab Set command, 240
register prefix, 98 ( ) (parentheses), FORTRAN operator,
\ (backslash), Screen Exchange 82
command, 234 . (period)
! ] (brackets) Current Location command, 198
notational conventions, xxi operator
regular expressions, used in, 336
* (caret) C, 79
error messages, 356
exponentiation operator, BASIC, 86 FORTRAN, 82
regular expressions, used in, 337, 339 Pascal, 91
: (colon) regular expressions, used in, 336
Delay command, 247 + (plus sign)
LINK command, 257 LIB command symbol
operator, 82, 87, 99 Intel, XENIX files, used with, 289
, (comma) libraries, combining, 292, 300
LIB command symbol, 290 library, specifying, 294
LINK command symbol, 257 object files, appending, 297, 299
- (dash)
using, 291
option designator, 9, 23 LINK: command symbol, 257, 260
regular expressions, used in, 337 n operator, FORTRAN, 82
$ (dollar sign), regular expressions, (quotation marks)
used in, 339 notational conventions, xxii
= (equal sign) Pause command, 248
assignment operator, FORTRAN, 82 ; (semicolon)
Redirected Input and Output LIB command symbol, 290, 296, 301
command, 245 LINK command symbol, 258, 259,
! (exclamation point), Shell Escape 260
command, 238, 355 _ (underscore), symbol names, used in,
/ (forward slash) 79, 83, 92
division operator, FORTRAN, 82 | (vertical bar), notational convention,
option character, LINK, 264
option designator
CodeView, 23
compilers, 9 /2 option, CodeView, 25
Search command, 236, 354 /43 option, CodeView, 26
> (greater-than sign) 7 (8087 command), 153
CodeView prompt, 39, 41, 71 10-byte reals, dumping, 146
Redirected Output command, 244 386 option, 62
8087
385
pcjs.org
Index
388
pcjs.org
Inde
387
pcjs.org
Index
388
pcjs.org
Index
389
pcjs.org
Index
390
pcjs.org
Index
391
pcjs.org
Index
392
pcjs.org
Index
393
pcjs.org
Index
394
pcjs.org
Inde
395
pcjs.org
Index
398
pcjs.org
Index
397
pcjs.org
Index
398
pcjs.org
Index
399
pcjs.org
Index
400
pcjs.org
Index
pcjs.org
401
Microsoft Corporation
16011 NE 36th Way
Box 97017
Redmond, WA 98073-9717
Microsoft
pcjs.org