Turbo Assembler Version 1.0 Reference Guide 1988
Turbo Assembler Version 1.0 Reference Guide 1988
Turbo Assemble~
Reference Guide
Version 1.0
Copyright!!:> 1988
All rights reserved
Borland International
1800 Green Hills Road
P.O. Box 660001
Scotts Valley, CA 95066-0001
This manual was produced with
Sprint® The Professional Word Processor
109876543
R3
Table of Contents
Introduction 1
Hard ware and Software Requirements .............................. 1
What's in This Manual. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1
Notational Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 2
How to Contact Borland .......................................... 3
Chapter 1 Predefined Symbols 5
@code .......................................................... 6
®CodeSize ...................................................... 6
®Cpu ........................................................... 7
@curseg ......................................................... 8
@data ........................................................... 8
@DataSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 9
??date .......................................................... 9
@fardata ........................................................ 9
@fardata? ...................................................... 10
@FileN"ame ............................... ~ ..................... 10
??filename ...................................................... 10
??time ......................................................... 10
??version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 11
@WordSize ..................................................... 11
Chapter 2 Operators 13
Arithmetic Precision ............................................. 13
Operator Precedence ........................................... 14
() .............................................................. 15
It • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 16
+ (Binary) ...................................................... 16
+ (Unary) ...................................................... 16
- (Binary) ...................................................... 17
- (Unary) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 18
............................................................... 18
/ .............................................................. 19
............................................................... 19
? .............................................................. 20
[ ] operator ..................................................... 21
AND .......................................................... 21
ByTE .......................................................... 22
DATAPTR ...................................................... 22
DUP ........................................................... 23
DWORD ....................................................... 23
EQ ............................................................ 24
FAR ........................................................... 24
FWORD ....................................................... 25
GE ............................................................ 25
GT ............................................................ 26
HIGH ......................................................... 26
LARGE ........................................................ 27
LE ............................................................. 28
LENGTH ...................................................... 28
LOW .......................................................... 29
LT ............................................................. 30
MASK ......................................................... 30
MOD .......................................................... 31
NE ............................................................ 31
NEAR ......................................................... 32
NOT ........................................................... 32
OFFSET ........................................................ 33
OR ............................................................ 33
PROC ......................................................... 34
PTR ........................................................... 34
PWORD ....................................................... 36
QWORD ....................................................... 36
SEG ........................................................... 36
SHL ........................................................... 37
SHORT ........................................................ 37
SHR ........................................................... 38
SIZE ........................................................... 38
SMALL ........................................................ 39
SYMTYPE ...................................................... 40
TBYTE ......................................................... 40
THIS .......................................................... 41
.TYPE ......................................................... 41
TYPE .......................................................... 42
UNKNOWN ................................................... 43
WIDTH ........................................................ 44
WORD ......................................................... 45
XOR ........................................................... 45
The Special Macro Operators ..................................... 46
& ............................................................. 46
<> ............................................................. 47
! ........................................... ~ .................. 48
% ............................................................. 48
ii
;; .............................................................. 49
Chapter 3 Directives 51
Sample Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 52
.186 ............................................................ 53
.286 ........................................................... 53
.286C .......................................................... 53
.286P .......................................................... 54
.287 ........................................................... 54
.386 ........................................................... 54
.386C .......................................................... 55
.386P .......................................................... 55
.387 ........................................................... 55
.8086 .......................................................... 56
.8087 .......................................................... 56
: .............................................................. 57
= .............................................................. 58
ALIGN ........................................................ 58
.ALPHA ....................................................... 59
ARG ........................................................... 60
ASSUME ....................................................... 62
%BIN .......................................................... 63
CA1'STR ....................................................... 64
.CODE ......................................................... 64
CODESEG ..................................................... 65
COMM ........................................................ 65
COMMENT .................................................... 66
%CONDS ...................................................... 67
.CONST ........................................................ 67
CONST ........................................................ 68
.CREF ......................................................... 68
%CREF ........................................................ 68
%CREFALL .................................................... 69
%CREFREF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 69
%CREFUREF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 70
%CTLS ........................................................ 70
.DATA ......................................................... 71
.DATA? ........................................................ 71
DATASEG ...................................................... 72
DB ............................................................ 72
DD ............................................................ 73
%DEPTH ...................................................... 74
DF ............................................................ 75
DISPLAy ....................................................... 76
DOSSEG ....................................................... 76
iii
DP ............................................................ 77
DQ ............................................................ 77
DT ............................................................ 78
DW ........................................................... 79
ELSE .......................................................... 80
ELSEIF ........................................................ 80
EMUL ......................................................... 81
END ........................................................... 82
ENDIF ......................................................... 82
ENDM ......................................................... 83
ENDP ......................................................... 83
ENDS ......................................................... 84
EQU ........................................................... 84
.ERR ........................................................... 85
ERR ........................................................... 86
.ERR1 .......................................................... 86
.ERR2 .......................................................... 86
.ERRB ......................................................... 87
.ERRDEF ....................................................... 87
.ERRDIF ....................................................... 88
.ERRDIFI ....................................................... 88
.ERRE ......................................................... 89
.ERRIDN ....................................................... 89
.ERRIDNI ...................................................... 90
ERRIF ......................................................... 91
ERRIF1 ........................................................ 91
ERRIF2 ........................................................ 91
ERRIFB ........................................................ 91
ERRIFDEF ..................................................... 91
ERRIFDIF ..... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 92
ERRIFDIFI ..................................................... 92
ERRIFE ........................................................ 92
ERRIFIDN ..................................................... 92
ERRIFIDNI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 92
ERRIFNB ...................................................... 93
ERRIFNDEF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 93
.ERRNB ........................................................ 93
.ERRNDEF .................................. . . . . . . . . . . . . . . . . . .. 94
.ERRNZ ........................................................ 94
EVEN ......................................................... 94
EVENDATA .................................................... 95
EXITM ......................................................... 96
EXTRN ........................................................ 96
.FARDATA ..................................................... 98
Iv
.FARDATA? .................................................... 98
FARDATA ..................................................... 99
GLOBAL ...................................................... 100
GROUP ....................................................... 101
IDEAL ........................................................ 102
IF ............................................................ 103
IFl ........................................................... 103
IF2 ........................................................... 104
IFB ........................................................... 105
IFDEF ........................................................ 105
IFDIF, IFDIFI .................................................. 106
IFE ........................................................... 106
IFIDN, IFIDNI ................................................. 107
IFNB ......................................................... 108
IFNDEF ....................................................... 108
%INCL ....................................................... 109
INCLUDE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 109
INCLUDE LIB .................................................. 110
INS1R ........................................................ 110
IRP ........................................................... 111
IRPC ......................................................... 111
JUMPS ........................................................ 112
LABEL ........................................................ 113
.LALL ........................................................ 114
.LFCOND ..................................................... 114
%LINUM ..................................................... 114
%LIST ........................................................ 115
.LIST ......................................................... 115
LOCAL ....................................................... 115
LOCALS ...................................................... 117
MACRO ...................................................... 119
%MACS ...................................................... 119
MASM ........................................................ 120
MASM51 ...................................................... 120
.MODEL ...................................................... 121
MODEL ....................................................... 124
MULTERRS ................................................... 124
NAME ........................................................ 125
%NEWPAGE .................................................. 125
%NOCONDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 125
%NOCREF .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 126
%NOCTLS .................................................... 126
NOEMUL ..................................................... 127
%NOINCL .................................................... 127
v
NOJUMPS .................................................... 128
%NOLIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 128
NOLOCALS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 128
%NOMACS ................................................... 129
NOMASM51 .................................................. 129
NOMULTERRS ................................................ 130
%N()5YMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 131
%NOTRUNC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 131
NOWARN .................................................... 132
ORC .......................................................... 132
%OUT ........................................................ 133
P186 .......................................................... 133
P286 .......................................................... 133
P286N ........................................................ 134
P286P ......................................................... 134
P287 .......................................................... 134
P386 .......................................................... 134
P386N ........................................................ 134
P386P ......................................................... 135
P387 .......................................................... 135
P8086 .......................................................... 135
P8087 ......................................................... 135
PAGE ........................................................ 135
%PAGESIZE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 136
%PCNT ....................................................... 137
PN087 ........................................................ 137
%POPLCTL ................................................... 138
PROC ........................................................ 138
PUBLIC ....................................................... 141
PURGE ....................................................... 141
%PUSHLCTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 142
QUIRKS ...................................•.................. 142
.RADIX ....................................................... 143
RADIX ........................................................ 143
RECORD ...................................................... 143
REPT ......................................................... 144
.SALL ........................................................ 145
SEGMENT .................................................... 145
.SEQ .......................................................... 148
.SFCOND ..................................................... 148
SIZESTR ...................................................... 148
.STACK ....................................................... 149
STACK ....................................................... 149
STRUC ....................................................... 149
vi
SUBSlR ....................................................... 151
SUBTIL ...................................................... 152
%SUBTIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 152
%SYMS ....................................................... 153
%TABSIZE .................................................... 153
%TEXT ....................................................... 154
.TFCOND ......... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 154
TITLE ........................................................ 154
%TITLE ....................................................... 155
%TRUNC ..................................................... 155
UDATASEG ................................................... 156
UFARDATA ................................................... 156
UNION ....................................................... 156
USES ......................................................... 158
WARN ........................................................ 159
.XALL ........................................................ 160
.XCREF ....................................................... 160
.XLIST ........................................................ 160
Appendix A Turbo Assembler Syntax Summary 161
Lexical Grammar ............................................. 161
valid_line ............................................... 161
white_space ............................................. 161
space_char .............................................. 162
id_string ................................................ 162
id_strng2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 162
id_char ................................................. 162
id_chr2 ................................................. 162
number_string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 162
num_string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 162
digits ................................................... 162
digit .................................................... 162
alphanums .............................................. 163
alpha ................................................... 163
exp ..................................................... 163
str_string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 163
punctuation ............................................. 163
MASM Mode Expression Grammar. . . . . . . . . . . . . . . . . . . . . . . . . .. 164
mexprl ................................................. 164
mexpr2 ................................................. 164
mexpr3 ................................................. 164
mexpr4 ................................................. 164
mexpr5 ................................................. 164
mexpr6 ................................................. 165
mexpr7 ................................................. 165
vii
mexpr8 ................................................. 165
mexpr9 ................................................. 165
mexpr10 ................................................ 165
mexpr11 ................................................ 166
mexpr12 ................................................ 166
mexpr13 ................................................ 166
Ideal Mode Expression Grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 166
pointer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 166
type .................................................... 166
pointer2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 167
pointer3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 167
expr .................................................... 167
expr2 ................................................... 167
expr3 ................................................... 167
expr4 ................................................... 168
expr5 ................................................... 168
expr6 ................................................... 168
expr7 ................................................... 168
expr8 ................................................... 168
expr9 ................................................... 168
exprl0 .................................................. 169
Appendix B Compatibility Issues 171
Environment Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 172
Microsoft Binary Floating-Point Format ......................... 172
Turbo Assembler Quirks Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 172
Byte Move to / from Segment Register ...................... . . . .. 173
Erroneous Near Jump to Far Label or Procedure .................. 173
Loss of Type Information with = and EQU Directive .............. 173
Segment-Alignment Checking ................................. 174
Signed Immediate Arithmetic and Logical Instructions ............ 174
Masm 5.1 Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 174
Masm 5ol/Quirks Mode Features ............................... 175
Appendix C Turbo Assembler Highlights 177
Extended Command-Line Syntax ............................. 177
GLOBAL Directive ......................................... 177
Local Symbols ............................................. 178
Conditional Jump Extension ................................. 178
Ideal Mode ........................................... . . . .. 178
UNION Directive/STRUC Nesting ........................... 178
EMUL and NOEMUL Directives ............................. 179
Explicit Segment Overrides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 179
Constant Segments ......................................... 179
Extended LOOP Instruction in 386 Mode ...................... 179
viii
Extended Listing Controls ................................... 180
Alternate Directives ........................................ 180
Predefined Variables ........................................ 180
Masm 5.0 and 5.1 Enhancements ............................. 180
Improved SHL and SHR Handling ........................... 181
Appendix D Turbo Assembler Utilities 183
The Stand-Alone MAKE Utility .................................. 183
A Quick Example ............................................ 184
Creating a Makefile ......................................... 185
U sing a Makefile ........................................... 186
Stepping Through ........ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 187
Creating Makefiles ........................................... 188
Componen ts of a Makefile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 188
Comments .............................................. 189
Explicit Ru1es ........... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 189
Special Considera tions .................................. 190
Implicit Ru1es ............................................ 191
Special Considera tions ........................... . . . . . .. 193
Examples ............................................. 194
Command Lists .......................................... 194
Prefix ................................................. 194
Command Body. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 195
Examples ............................................. 195
Macros ................................................ ".. 196
Defining Macros ....................................... 197
Using Macros .......................................... 197
Special Considera tions ........................... . . . . . .. 198
Predefined Macros ..................................... 198
Directives ............................................... 200
File-Inclusion Directive ................................. 201
Conditional Directives .................................. 201
Error Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 204
Undef Directive ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 204
Using MAKE ................................................ 204
Command-Line Syntax ...................................... 204
A Note About Stopping MAKE .............................. 205
The BUlLTINS.MAK File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 205
How MAKE Searches for Makefiles . . . . . . . . . . . . . . . . . . . . . . . . . .. 206
The TOUCH Utility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 206
MAKE Command-Line Options .............................. 206
MAKE Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 207
Fatals ..................................................... 207
Errors .................................................... 208
Turbo Link .................................................... 210
ix
Invoking TLINK ............................................. 210
Using Response Files ....................................... 211
TLINK Options .............................................. 213
The lx, 1m, Is Options ..................................... 213
The 11 Option .............................................. 214
The Ii Option .............................................. 214
The In Option ............................................. 214
The I c Option ............................................. 214
The I d Option ............................................. 215
The Ie Option ............................................. 215
The It Option .............................................. 216
The Iv Option ............................................. 216
The 13 Option ............................................. 216
Restrictions ................................................ 216
Error Messages .............................................. 217
Fatal Errors ................................................ 217
Nonfatal Errors ............................................ 219
Warnings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 220
TLIB: The Turbo Librarian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 220
The Advantages of Using Object Module Libraries ................ 221
The Components of a TLIB Command Line .... . . . . . . . . . . . . . . . . .. 221
The Operation List ......................................... 222
File and Module Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 223
TLIB Operations ......................................... 223
Creating a Library .......................................... 224
Using Response Files ......................................... 224
Advanced Operation: The IC Option ........................... 225
Examples ................................................... 226
Creating an Extended Dictionary: The IE Option ................. 226
GREP: A File-Search Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 227
The GREP Options ........................................... 227
Order of Precedence ...................................... .. 229
The Search String ............................................ 229
Operators in Regular Expressions ............................ 229
The File Specification ......................................... 230
Examples with Notes ......................................... 231
OBJXREF: The Object Module Cross-Reference Utility . . . . . . . . . . . . . .. 234
The OBJXREF Command Line ................................. 234
Command-Line Options .................................... 235
Control Options .......................................... 235
Report Options .......................................... 235
Response Files ............................................... 236
Freeform Response Files .................................... 236
Linker Response Files ....................................... 237
x
The ID ComlI1and . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 237
The 10 Command ......................................... 237
The IN Command ......................................... 238
Sample OBJXREF Reports ..................................... 238
Report by Public Names (lRP) ............................... 239
Report by Module (/RM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 240
Report by Reference (/RR) (Default) .......................... 240
Report by External References (/RX) .......................... 240
Report of Module Sizes (IRS) ................................ 241
Report by Class Type (/RC) ................................. 241
Report of Unreferenced Symbol Names (/RU) ................. 242
Verbose Reporting (/RV) .................................... 242
Examples Using OBJXREF .................................... , 243
OBJXREF Error Messages and Warnings . . . . . . . . . . . . . . . . . . . . . . . .. 243
Error Messages ............................................ 243
Warnings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 244
TCREF: The Source Module Cross-Reference Utility ................. 244
Response Files ............................................... 245
Compa tibility with TLINK .................................... 245
Switches .................................................. 245
Output ..................................................... 246
The Global (or Linker-Scope) Report ............................ 246
The Local (or Module-Scope) Report .. . . . . . . . . . . . . . . . . . . . . . . . . .. 246
Appendix E Error Messages 249
Information Messages .......................................... 249
Warning and Error Messages .................................... 250
Fatal Error Messages ............................................ 272
Index 275
xl
List of Tables
xii
N T R o D u c T o N
This book is the second of the two books accompanying the Turbo
Assembler package. Now that you've probably thoroughly perused the first
manual (User's Guide) in this set, you'll want to look at this one for all the
nitty-gritty in fo rma tion.
The Reference Guide is just that-a straight and to-the-point reference about
Turbo Assembler. If you find you still need to know more about the basics
of assembly language, go back to the User's Guide for some in-depth
discussions.
Introduction
Appendix B: Compatibility Issues covers the differences between MASM
and Turbo Assembler MASM mode.
Appendix C: Turbo Assembler Highlights details Turbo Assembler's
enhancements that add to those of MASM.
Appendix D: Turbo Assembler Utilities describes six utilities that come
with this package: MAKE, TLINK, TLIB, GREP, OBJXREF, and TCREF.
Appendix E: Turbo Assembler Error Messages describes all the error
messages that can be generated when using Turbo Assembler: information
messages, fatal error messages, warning messages, and error messages.
Notational Conventions
When we talk about IBM PCs or compatibles, we're referring to any
computer that uses the 8088, 8086, 80186, 80286, and 80386 chips (all of
these chips are commonly referred to as 80x86). When discussing PC-DOS,
DOS, or MS-DOS, we're referring to version 2.0 or greater of the operating
system.
All typefaces were produced by Borland's Sprint: The Professional Word
Processor, output on a PostScript printer. The different typefaces displayed
are used for the following purposes:
Italics In text, italics represent labels, placeholders, variables, and
arrays. In syntax expressions, placeholders are set in italics
to indicate that they are user-defined.
Boldface Boldface is used in text for directives, instructions, symbols,
and operators, as well as for command-line options.
CAPITALS In text, capital letters are used to represent instructions,
directives, registers, and operators.
Monospace Monospace type is used to display any sample code, text or
code that appears on your screen, and any text that you
must actually type to assemble, link, and run a program.
Keycaps In text, keycaps are used to indicate a key on your keyboard.
It is often used when describing a key you must press to
perform a particular function; for example, "Press Enter after
typing your program name at the prompt."
Introduction 3
4 Turbo Assembler Reference Guide
c H A p T E R
Predefined Symbols
Turbo Assembler provides a number of predefined symbols that you can
use in your programs. These symbols can have different values at different
places in your source file. They are similar to equated symbols that you
define using the EQU directive. When Turbo Assembler encounters one of
these symbols in your source file, it replaces it with the current value of that
predefined symbol.
Some of these symbols are text (string) equates, some are numeric equates,
and others are aliases. The string values can be used anywhere that you
would use a character string, for example to initialize a series of data bytes
using the DB directive:
NOW DB ??time
Numeric predefined values can be used anywhere that you would use a
number:
IF ??version GT lOOh
Alias values make the predefined symbol into a synonym for the value it
represents, allowing you to use the predefined symbol name anywhere you
would use an ordinary symbol name:
ASSUME cs:@code
All the predefined symbols can be used in both MASM and Ideal mode.
If you use the Iml command-line option when assembling, you must use
the predefined symbol names exactly as they are described on the following
pages.
@code
Function Alias equate for .CODE segment name
Remarks When you use the simplified segmentation directives
(.MODEL, and so on), this equate lets you use the name
of the code segment in expressions, such as ASSUMEs
and segment overrides.
Example •CODE
mov ax,@code
mov dx,ax
ASSUME ds:@code
@CodeSize
Function Numeric equate that indicates code memory model
Remarks @CodeSize is set to 0 for the small and compact memory
models that use near code pointers, and is set to 1 for all
other models that use far code pointers.
You can use this symbol to control how pointers to
functions are assembled, based on the memory model.
@Cpu
Function Numeric equate that returns information about current
processor
Remarks The value returned by @Cpu encodes the processor type
in a number of single-bit fields:
Bit Description
The bits not defined here are reserved for future use.
Mask them off when using @Cpu so that your programs
will remain compatible with future versions of Turbo
Assembler.
Since the 8086 processor family is upward compatible,
when you enable a processor type with a directive like
.286, the lower processor types (8086, 80186) are auto-
matically enabled as well.
Note: This equate only provides information about the
processor you've selected at assembly-time via the .286
and related directives. The processor type your program
is executing on at run time is not indicated.
@curseg
Function Alias equate for current segment
Remarks @curseg changes throughout assembly to reflect the
current segment name. You usually use this after you
have used the simplified segmentation directives
(.MODEL, and so on).
Use @curseg to generate ASSUME statements, segment
overrides, or any other statement that needs to use the
current segment name.
Example •CODE
ASSUME cs:@curseg
@data
Function Alias equate for near data group name
Remarks When you use the simplified segmentation directives
(.MODEL, and so on), this equate lets you use the group
name shared by all the near data segments (.DATA,
.CONST, .STACK) in expressions such as ASSUMEs
and segment overrides.
Example •CODE
mov ax,@data
mov ds,ax
ASSUME ds: @data
??date
Function String equate for today's date
Remarks ??date defines a text equate that represents today's date.
The exact format of the date string is determined by the
DOS country code.
See Also ??time
Example asmdate DB ??date i8-byte string
@fardata
Function Alias equate for initialized far data segment name
Remarks When you use the simplified segmentation directives
(.MODEL, and so on), this equate lets you use the name
of the initialized far data segment (.FARDATA) in
expressions such as ASSUMEs and segment overrides.
Example mov ax,@fardata
mov ds,ax
ASSUME ds:@fardata
@FileName
Function Alias equate for current assembly file
See Also ??filename
??filename
Function String equate for current assembly file
Remarks ??filename defines an eight-character string that repre-
sents ,the file name being assembled. If the file name is
less than eight characters, it is padded with spaces.
Example SrcName DB ??filename ;8-bytes always
??time
Function String equate for the current time
Remarks ??time defines a text equate that represents the current
time. The exact format of the time string is determined
by the DOS country code.
See Also ??date
Example asmtime DB ??time ;8-byte string
@WordSize
Function Numeric equate that indicates 16- or 32-bit segments
Remarks @WordSize returns 2 if the current segment is a 16-bit
segment, or 4 if the segment is a 32-bit segment.
Example IF @WordSize EQ 4
mov esp,OlOOh
ELSE
mov sp,OlOOh
ENDIF
Operators
Operators let you fonn complex expressions that can be used as an operand
to an instruction or a directive. Operators act upon operands, such as
program symbol names and constant values. Turbo Assembler evaluates
expressions when it assembles your source file and uses the calculated
result in place of the expression. One way you can use expressions is to
calculate a value that depends on other values that may change as you
modify your source file.
This chapter details the operators Turbo Assembler provides.
Arithmetic Precision
Turbo Assembler uses 16- or 32-bit arithmetic, depending on whether you
have enabled the 80386 processor with the .386 or .386P directive. When
you are assembling code for the 80386 processor or in Ideal mode, some
expressions will yield different results than when they are eva luted in 16-
bit mode; for example,
DW (lOOOh * lOOOh) / lOOOh
generates a word of 1000h in 32-bit mode and a word of 0 in 16-bit mode. In
16-bit mode, multiplication results in an overflow condition, saving only
the bottom 16 bits of the result.
Chapter 2, Operators 13
Operator Precedence
Turbo Assembler evaluates expressions using the following rules:
• Operators with higher precedence are performed before ones with lower
precedence.
• Operators with the same precedence are performed starting with the
leftmost one in the expression.
• If an expression contains a subexpression within parentheses, that
subexpression is evaluated first because expressions within parentheses
ha ve the highest priority.
Ideal mode and MASM mode have a different precedence for some
operators. The following two tables show the precedence of the operators
in both modes. The first line in each table shows the operators with the
highest priority, and the last line those operators with the lowest priority.
Within a line, all the operators have the same priority.
()
Function Marks an expression for early evaluation
Mode MASM, Ideal
Syntax (expression)
Chapter 2, Operators 15
*
Function Multiplies two integer expressions
Mode MASM,Ideal
Syntax expressionl * expression2
Remarks expressionl and expression2 must both evaluate to integer
constants. The '" operator can also be used between a
register and a constant to support 386 addressing
modes.
See also +, -, /, MOD, SHL, SHR
Example SCREENSIZE = 25 * 80 i' chars onscreen
The '" operator can also be used between a register and a
constant to support 386 addressing modes.
+ (Binary)
Function Adds two expressions
Mode MASM,Ideal
Syntax expressionl + expression2
Remarks At least one of expressionl or expression2 must evaluate to
a constant. One expression can evaluate to an address.
See also -, "', /, MOD, SHL, SHR
Example x ow 4 OUP (?)
XPTR ow x + 4 ithird word in buffer
+ (Unary)
Function Indicates a positive number
Mode MASM,Ideal
Syntax + expression
Remarks This operator has no effect. It is available merely to
make explicit positive constants.
- (Binary)
Function Subtracts two expressions
Mode MASM,Ideal
Syntax expressionl - expression2
Remarks There are three combinations of operands you can use
with subtraction:
• expression 1 and expression2 can both evaluate to
integer constants.
f:I expressionl and expression2 can both be addresses as
long as both addresses are within the same segment.
When you subtract two addresses, the result is a con-
stant. Ideal mode checks expressionl and expression2
for consistency much more stringently than MASM
mode. In particular, Ideal mode correctly handles
subtracting a segment from a far pointer, leaving just
an offset fixup in cases where this is a valid operation .
• expressionl can be an address and expression2 can be a
constant, but not vice versa. The result is another
address.
See also +, *, /, MOD, SHL, SHR
Example DATA SEGMENT
DW ?
XYZ EQU 10
VALl DW XYZ - 1 ;constant 9
VAL2 DW ?
V1SIZE DW VAL2 - VALl ;constant 2
V1BEFORE DW VALl - 2 ;points to DW before VALlE
DATA ENDS
Chapter 2, Operators 17
- (Unary)
Function Changes the sign of an expression
Mode MASM,Ideal
Syntax - expression
/
Function Divides two integer expressions
Mode MASM,Ideal
Syntax expressionl / expression2
Chapter 2, Operators 19
• as a group name defined with the GROUP directive
• as an expression starting with the SEG operator
expression can be a constant- or a memory-referencing
expression.
Example mov cl,es: [si+4]
VarPtr DD DGROUP:MEMVAR
?
Function Initializes with indeterminate data
Mode MASM,Ideal
Syntax Dx ?
Remarks Dx refers to one of the data allocation directives (DB,
DD, and so on). Use? when you want to allocate data
but don't want to explicitly assign a value to it.
You should use? when the data area is initialized by
your program before being used. Using? rather than 0
makes the initialization method explicit and visible in
your source code.
When you use ? as the only value in or outside a DUP
expression, no object code is generated. If you use?
inside a DUP expression that also contains initialized
values, it will be treated as a o.
Using? outside of a DUP causes the program counter to
be advanced but no data to be emitted. You can also use
? for the same purpose in, for example, a structure:
x struc ideclare structure
a db 1
x ends
xinst ? iundefined structure instance
AND
Function Bitwise logical AND
Mode MASM,Ideal
Syntax expressionl AND expression2
Remarks Performs a bit-by-bit logical AND of each bit in
expressionl and expression2. The result has a 1 in any bit
position tha t had a 1 in both expressions and a 0 in all
other bit positions.
Chapter 2, Operators 21
See also NOT,OR,XOR
Example mov al,11110000b AND 10100000B ;loads 10100000B
BYTE
Function Forces expression to be byte size
Mode Ideal
Syntax BYTE expression
Remarks expression must be an address. The result is an expres-
sion that points to the same memory address but always
has BYTE size, regardless of the original size of
expression.
You usually use this opera tor to define the size of a
forward-referenced expression, or to explicitly state the
size of a register indirect expression from which the size
cannot be determined.
In MASM mode, you must use the PTR directive
preceded with the BYTE type to perform this function.
See also PTR
Example mov [BYTE bx],l ;byte immediate move
mov [BYTE X],l ;forward reference
X DB 0
DATAPTR
Function Forces expression to model-dependent size
Mode Ideal
Syntax DATAPTR expression
Remarks Declares expression to be a near or far pointer,
depending on selected memory model.
See also PTR, UNKNOWN
Example mov [DATAPTR bx],l
Remarks count defines the number of times that the data defined
by the expression(s) will be repeated. The DUP operator
appears after one of the data allocation directives (DB,
DW, and so on).
Each expression is an initializing value that is valid for
the particular data allocation type that DUP follows.
You can use the DUP operator again within an expres-
sion, nested up to 17 levels.
You must always surround the expression values with
parentheses, O.
Example WRDBUF DW 40 DUP (1) ;40 words initialized to 1
SQUARE DB 4 DUP (4 DUP (0)) ;4x4 array of 0
DWORD
Function Forces expression to be doubleword size
Mode Ideal
Syntax DWORD expression
Remarks expression must be an address. The result is an expres-
sion that points to the same memory address but always
has DWORD size, regardless of the original expression
size.
You usually use this operator to define the size of a
forward-referenced expression.
To perform this function in MASM mode, you must use
the PTR directive preceded by the DWORD type.
See also PTR
Example call DWORD FPTR
Chapter 2, Operators 23
EQ
Function Returns true if expressions are equal
Mode MASM,Ideal
Syntax expressionl EQ expression2
Remarks expressionl and expression2 must both evaluate to con-
stants. EQ returns true (-1) if both expressions are equal
and returns false (0) if they have different values.
EQ considers expressionl and expression2 to be signed
32-bit numbers, with the top bit being the sign bit. This
means that -1 EQ OFFFFFFFFh evaluates to true.
See also NE, LT, LE, GT, GE
Example ALIE 4 EQ 3 ;= 0 (false)
ATRUTH = 6 EQ 6 ;= 1 (true)
FAR
Function Forces an expression to be a far code pointer
Mode Ideal
Syntax FAR expression
Remarks expression must be an address. The result is an expres-
sion that points to the same memory address but is a far
pointer with both a segment and an offset, regardless of
the original expression type.
You usually use this opera tor to call or jump to a
forward-referenced label that is declared as FAR later in
the source file.
To perform this function in MASM mode, you must use
the PTR directive preceded by the FAR type.
See also NEAR
Example call FAR ABC ;forward reference
ABC PROC FAR
GE
Function Returns true if one expression is greater than another
Mode MASM,Ideal
Syntax expressionl GE expression2
Chapter 2, Operators 25
GT
Function Returns true if one expression is greater than another
Mode MASM, Ideal
Syntax expressionl GT expression2
Remarks expressionl and expression2 must both evaluate to con-
stants. GT returns true (-1) if expression1 is greater than
expression2, and returns false (O) if it is less than or equal.
GT considers expressionl and expression2 to be signed
33-bit numbers, with the top bit being the sign bit. This
means that 1 GT -1 evaluates to true, but 1 GT
OFFFFFFFFh evaluates to false.
See also EQ, GE, LE, LT, NE
Example AFACT = 10 GT 9
NOTSO = 10 GT 11
HIGH
Function Returns the high part of an expression
Mode MASM, Ideal
Syntax HIGH expression
Ideal mode only:
type HIGH expression
Remarks HIGH returns the top 8 bits of expression, which must
evaluate to a constant.
In Ideal mode, HIGH in conjunction with LOW becomes
a powerful mechanism for extracting arbitrary fields
from data items. type specifies the size of the field to
extract from expression and can be any of the usual size
specifiers (BYTE, WORD, DWORD, and so on). You can
apply more than one HIGH or LOW operator to an
expression; for example, the following is a byte address
pointing to the third byte of the doubleword DBLVAL:
BYTE LOW WORD HIGH DBLVAL
See also LOW
LARGE
Function Sets an expression's offset size to 32 bits
Mode MASM, Ideal (386 modes only)
Syntax LARGE expression
Remarks expression is any expression or operand, which LARGE
converts into a 32-bit offset. You usually use this to
remove ambiguity about the size of an operation. For
example, if you have enabled the 80386 processor with
the P386 directive, this code can be interpreted as either
a far call with a segment and 16-bit offset or a near call
using a 32-bit offset:
jmp [DWORD PTR ABC]
You can remove the ambiguity by using the LARGE
directive:
jmp LARGE [nWORD PTR ABC] ;32-bit offset near call
In this example, LARGE appears outside the brackets,
thereby affecting the interpretation of the DWORD read
from memory. If LARGE appears inside the brackets, it
determines the size of the address from which to read
the operand, not the size of the operand once it is read
from memory. For example, this code means XYZ is a
4-byte pointer:
jmp LARGE [LARGE nWORD PTR XYZ]
Treat it as a 32-bit offset, and ]MP indirect through that
address, reading a ]MP target address that is also a
32-bit offset.
By combining the LARGE and SMALL operators, both
inside and outside brackets, you can effect any combi-
nation of an indirect ]MP or CALL from a 16- or 32-bit
segment to a 16- or 32-bit segment.
Chapter 2, Operators 27
You can alsq use LARGE to a void erroneous assump-
tions when accessing forward-referenced variables:
mov ax, [LARGE FOOBAR] ;FOOBAR is in a USE32 segment
LARGE and SMALL can be used with other ambiguous
instructions, such as LIDT and LGDT.
See also SMALL
Example ;MASM and Ideal modes
magic EQU 1234h
mov bl, HIGH magic
Ideal
iIdeal mode only
big DD 12345678h
mov ax, [word HIGH big] ;leads 1234h into AX
LE
Function Returns true if one expression is less than or equal to
another
Mode MASM,Ideal
Syntax expressionl LE expression2
Remarks expressionl and expression2 must both evaluate to con-
stants. LE returns true (-1) if expressionl is less than or
equal to expression2 and returns false (0) if it is greater.
LE considers expressionl and expression2 to be signed 33-
bit numbers, with the top bit being the sign bit. This
means that 1 LE -1 evaluates to false, but 1 LE
OFFFFFFFFh evaluates to true.
See also EQ, GE, GT, LT, NE
Example YUP = 5 LT 6 ;true = -1
LENGTH
Function Returns number of allocated data elements
Mode MASM,Ideal
Syntax LENGTH name
LOW
Function Returns the low part of an expression
Mode MASM,Ideal
Syntax LOW expression
Ideal mode only:
type LOW expression
Remarks LOW returns the bottom 8 bits of expression, which
must evaluate to a constant.
In Ideal mode, LOW in conjunction with HIGH becomes
a powerful mechanism for extracting arbitrary fields
from data items. type specifies the size of the field to
extract from expression and can be any of the usual size
specifiers (BYTE, WORD, DWORD, and so on). You can
apply more than one LOW or HIGH operator to an
expression; for example,
BYTE LOW WORD HIGH DBLVAL
is a byte address pointing to the third byte of the
doubleword DBLVAL.
See also HIGH
Chapter 2, Operators 29
Example iMASM and Ideal modes
magic EQU 1234h
mov bl,LOW magic
ideal
iIdeal mode only
big DD 12345678h
mov ax, [WORD LOW big] iloads 5678h into AX
LT
Function Returns true if one expression is less than another
Mode MASM,Ideal
Syntax expression1 LT expression2
Remarks expressionl and expression2 must both evaluate to con-
stants. LT returns true (-1) if expressionl is less than
expression2 and returns false (0) if it is greater than or
equal.
LT considers expressionl and expression2 to be signed 33-
bit numbers, with the top bit being the sign bit. This
means that 1 L T -1 evaluates to false, but 1 L T
OFFFFFFFFH evaluates to true.
See also EQ, GE, GT, LE, NE
Example JA = 3 LT 4 ;true = -1
MASK
Function Returns a bit mask for a record field
Mode MASM, Ideal
Syntax MASK recordfieldname
MASK record
Remarks recordfieldname is the name of any field name in a pre-
viously defined record. MASK returns a value with bits
turned on to correspond to the position in the record
that recordfieldname occupies.
record is the name of a previously defined record. MASK
returns a value with bits turned on for all the fields in
the record.
MOD
Function Returns remainder (modulus) from dividing two ex-
pressions
Mode MASM, Ideal
Syntax expressionsl MOD expression2
Remarks expressionl and expression2 must both evaluate to integer
constants. The result is the remainder of expressionl
divided by expression2.
See also +,-, *,1, SHL, SHR
Example REMAINS = 17 / 5 ;= 2
NE
Function Returns true if expressions are not equal
Mode MASM,Ideal
Syntax expressionl NE expression2
Remarks expressionl and expression2 must both evaluate to con-
stants. NE returns true (-1) if both expressions are not
equal and returns false (0) if they are equal.
NE considers expressionl and expression2 to be signed
32-bit numbers, with the top bit being the sign bit. This
means that -1 NE OFFFFFFFFh evaluates to true.
See also EQ, GE, GT, LE, LT
Example aint = 10 NE 10 ;false = 0
Chapter 2, Operators 31
NEAR
Function Forces an expression to be a near code pointer
Mode Ideal
Syntax NEAR expression
Remarks expression must be an address. The result is an expres-
sion that points to the same memory address but is a
NEAR pointer with only an offset and no segment,
regardless of the original expression type.
You usually use this operator to call or jump to a far
label or procedure with a near jump or call instruction.
See the example section for a typical scenario.
To perform this function in MASM mode, you must use
the PTR directive preceded with the NEAR type.
See also FAR
Example Ideal
PROC farp FAR
ibody of procedure
ENDP farp
istill in same segment
push cs
call NEAR PTR farp ifasterlsmaller than far call
NOT
Function Bitwise complement
Mode MASM,Ideal
Syntax NOT expression
Remarks NOT inverts all the bits in expression, turning 0 bits into
1 and 1 bits into O.
See also AND,OR,XOR
Example mov aI, NOT 11110011b iloads 0000l100b
OR
Function Bitwise logical OR
Mode MASM, Ideal
Syntax expressionl OR expression2
Chapter 2, Operators 33
position that had a 1 in either or both expressions, and a
oin all other bit positions.
See also AND,NOT,XOR
Example mov al,11110000b OR 10101010b iloads 11111010b
PROC
Function Forces an expression to be a near or far code pointer
Mode Ideal
Syntax PRoe expression
Remarks expression must be an address. The result is an expres-
sion that points to the same memory address but is a
near or far pointer, regardless of the original expression
type. If you specified the TINY, SMALL, or COMPACT
memory model with the .MODEL directive, the pointer
will be near. Otherwise, it will be a far pointer.
You usually use PROC to call or jump to a forward-
referenced function when you are using the simplified
segmentation directives. The example section shows a
typical scenario.
To perform this function in MASM mode, you must use
the PTR directive preceded with the PROC type.
See also NEAR, FAR
Example .MODEL large
. CODE
Ideal
call PROC Testl
PROC Testl iactually far due to large model
PTR
Function Forces expression to have a particular size
Mode MASM,Ideal
Syntax type PTR expression
Remarks expression must be an address. The result of this
operation is a reference to the same address, but with a
different size, as determined by type.
Chapter 2, Operators 35
PWORD
Function Forces expression to be 32-bit, far pointer size
Mode MASM,Ideal
See also FWORD
QWORD
Function Forces expression to be quadword size
Mode Ideal
Syntax QWORD expression
Remarks expression must be an address. The result is an expres-
sion that points to the same memory address but always
has QWORD size, regardless of the original size of
expression.
You usually use QWORD to define the size of a
forward-referenced expression, or to explicitly state the
size of a register indirect expression from which the size
cannot be determined.
To perform this function in MASM mode, you must use
the PTR directive preceded by the QWORD type.
See also PTR
Example fadd [QWORD BXl ;sizeless indirect
fsubp [QWORD Xl ;forward reference
•DATA
X DQ 1.234
SEG
Function Returns the segment address of an expression
Mode MASM,Ideal
Syntax SEG expression
Remarks expression can be any expression or operand that
references a memory location. SEG returns a constant
SHL
Function Shifts the value of an expression to the left
Mode MASM,Ideal
Syntax expression SHL count
Remarks expression and count must evaluate to constants. SHL
performs a logical shift to the left of the bits in expression.
Bits shifted in from the right contain 0, and the bits
shifted off the left are lost.
A negative count causes the data to be shifted the
opposite way.
See also SHR
Example mov al,00000011b SHL 3 iloads 00011000B
SHORT
Function Forces an expression to be a short code pointer.
Mode MASM, Ideal
Syntax SHORT expression
Remarks expression references a location in your current code
segment. SHORT informs the assembler that expression
is within -128 to +127 bytes from the current code
location, which lets the assembler generate a shorter
IMP instruction.
You only need to use SHORT on forward-referenced
IMP instructions, since Turbo Assembler automatically
Chapter 2, Operators 37
generates the short jumps if it already knows how far
away expression is.
See also NEAR,FAR
Example jmp SHORT done igenerate small jump instruction
iless than 12B bytes of code here
Done:
SHR
Function Shifts the value of an expression to the right
Mode MASM,Ideal
Syntax expression SHR count
Remarks expression and count must evaluate to constants. SHR
performs a logical shift to the right of the bits in
expression. Bits shifted in from the left contain 0, and the
bits shifted off the right are lost.
A negative count causes the data to be shifted the
opposite way.
See also SHL
Example mov al,BOh SHR 2 iloads 20h
SIZE
Function Returns size of allocated data item
Mode MASM, Ideal
Syntax SIZE name
Remarks name is a symbol that refers to a data item allocated with
one of the data allocation directives (DB, DD, and so
on). In MASM mode, SIZE returns the value of
LENGTH name multiplied by TYPE name. Therefore, it
does not take into account multiple data items, nor does
it account for nested DUP operators.
In Ideal mode, SIZE returns the byte count within a
DUP. To get the byte count ofDUP, use LENGTH.
See also LENGTH, TYPE
SMALL
Function Sets an expression's offset size to 16 bits
Mode MASM, Ideal (386 code generation only)
Syntax small expression
Remarks expression is any expression or operand. SMALL
converts it into a 16-bit offset. You usually use this to
remove ambiguity about the size of an operation. For
example, if you have enabled the 80386 processor with
the P386 directive,
jmp [DWORD PTR ABC]
can be interpreted as either a far call with a segment and
16-bit offset or a near call using a 32-bit offset. You can
remove the ambiguity by using the SMALL directive:
jmp small [DWORD PTR ABC] il6-bit offset far call
In this example, SMALL appears outside the brackets,
thereby affecting the interpretation of the DWORD read
from memory. If SMALL appears inside the brackets, it
determines the size of the address from which to read
the operand, not the size of the operand once it is read
from memory. For example,
CODE SEGMENT USE32
jmp small [small DWORD PTR XYZ]
Chapter 2, Operators 39
address, reading a near JMP target address that is also a
16-bit offset.
By combining the LARGE and SMALL operators, both
inside and outside brackets, you can effect any combi-
nation of an indirect JMP or CALL from a 16- or 32-bit
segment to a 16- or 32-bit segment. LARGE and SMALL
can also be used with other ambiguous instructions,
such as LIDT and LGDT.
See also LARGE
SYMTYPE
Function Returns a byte describing a symbol
Mode Ideal
Syntax SYMTYPE <expression>
Remarks SYMTYPE functions very similarly to .TYPE, with one
minor difference: If expression contains an undefined
symbol, SYMTYPE returns an error, unlike .TYPE.
See also .TYPE
TBYTE
Function Forces expression to be 10-byte size
Mode Ideal
Syntax TBYTE expression
Remarks expression must be an address. The result is an expres-
sion that points to the same memory address but always
has TBYTE size, regardless of the original size of
expression.
You usually use TBYTE to define the size of a forward-
referenced expression, or to explicitly state the size of a
register indirect expression from which the size cannot
be determined.
To perform this function in MASM mode, you must use
the PTR directive preceded by the TBYTE type.
See also PTR
THIS
Function Creates an operand whose address is the current seg-
ment and location counter
Mode MASM,Ideal
Syntax THIS type
Remarks type describes the size of the operand and whether it
refers to code or data. It can be one of the following:
• NEAR, FAR, or PROC (PROC is the same as either
NEAR or FAR, depending on the memory set using
the MODEL directive)
.BYTE, WORD, DATAPTR, DWORD, FWORD,
PWORD, QWORD, TBYTE, ora structure name
You usually use this operator to build EQU and =
statements.
Example ptrl EQU THIS WORD ;same as following statement
ptr2 LABEL WORD
.TYPE
Function Returns a byte describing a symbol
Mode MASM
Syntax .TYPE name
Remarks name is a symbol that mayor may not be defined in the
source file ..TYPE returns a byte that describes the sym-
bol with the following fields:
Chapter 2, Operators 41
Bit Description
TYPE
Function Returns a number indicating the size or type of symbol
Mode MASM,Ideal
Syntax TYPE expression
Remarks TYPE returns one of the following values, based on the
type of expression:
UNKNOWN
Function Removes type infonnation from an expression
Mode Ideal
Syntax UNKNOWN expression
Remarks expression is an address. The result is the same expres-
sion, but with its type (BYTE, WORD, and so on)
removed.
Use UNKNOWN to force yourself to explicitly mention
a size whenever you want to reference a location. This is
useful if you want to treat the location as a type of
union, allowing the storage of many different data
types. Incorrectly then, if you define another name
without an explicit size to reference the location, the
assembler can't use the original data allocation size.
You can also use an address with UNKNOWN size
much like you would use register indirect memory-
referencing for one operand, and pin down the size of
Chapter 2, Operators 43
the operation by using a register for the other operand.
By defining a name as UNKNOWN, you can use it
exactly as you would an anonymous register expression
such as [BX].
To perform this function in MASM mode, you must use
the PTR directive preceded by the BYTE type.
See also PTR
Example •DATA
workbuf DT 0 ;can hold up to a DT
workptr EQU UNKNOWN WORKBUF ;anonymous pointer
.CODE
;EXAMPLE 1
mov [BYTE PTR WORKPTR],l ;store a byte
fstp [QWORD PTR WORKPTR] ;store a qword
mov [WORKPTR],l ;error--no type
;EXAMPLE 2
mov aI, [WORKPTR] ;no complaint
mov ax, [WORKPTR] ;no complaint either!
WIDTH
Function Returns the wid th in bits of a field in a record
Mode MASM, Ideal
Syntax WIDTH recordfieldname
WIDTH record
Remarks recordfieldname is the name of any field name in a
previously defined record. WIDTH returns a value of
the number of bits in the record that recordfieldname
occupies.
record is the name of a previously defined record.
WIDTH returns a value of the total number of bits for
all the fields in the record.
See also MASK
Example ;Macro determines maximum value for a field
maxval MACRO FIELDNAME
value=2
REPT WIDTH FIELDNAME - 1
value = value * 2;
ENDM
WORD
Function Forces expression to be word size
Mode Ideal
Syntax WORD expression
Remarks expression must be an address. The result is an expres-
sion that points to the same memory address but always
has WORD size, regardless of the original size of
expression.
You usually use WORD to define the size of a forward-
referenced expression, or to explicitly state the size of a
register indirect expression from which the size cannot
be determined.
To perform this function in MASM mode, you must use
the PTR directive preceded with the WORD type.
See also PTR
Example mov [WORD bxl,1 iword immediate move
mov [WORD Xl,1 iforward reference
X DW 0
XOR
Function Bitwise logical exclusive OR
Mode MASM, Ideal
Syntax expressionl XOR expression2
Remarks XOR performs a bit-by-bit logical exclusive OR of each
bit in expressionl and expression2. The result has a 1 in
any bit position that had a 1 in one expression but not in
the other, and a 0 in all other bit positions.
See also AND, NOT, OR
Example mov al,11110000b XOR 11000011b ;AL = 00110011b
Chapter 2, Operators 45
The Special Macro Operators
You use the special macro operators when calling macros and within macro
and repeat-block definitions. You can also use them with the arguments to
conditional assembly directives.
Here's a brief summary of the special macro operators:
& Substitute operator
<> Literal text string operator
! Quoted character operator
% Expression evaluate operator
Suppressed comment
"
The operators let you modify symbol names and individual characters so
that you can either remove special meaning from a character or determine
when an argument gets evaluated.
&
Function Substitute operator
Mode MASM,Ideal
Syntax &name
Remarks name is the value of the actual parameter in the macro
invocation or repeat block. In many situations, param-
eter substitution is automatic, and you don't have to use
this operator. You must use this operator when you wish
substitution to take place inside a quoted character
string, or when you want to "paste" together a symbol
from one or more parameters and some fixed characters.
In this case, the & prevents the characters from being
interpreted as a single name.
Example MAKEMSG MACRO StrDef,NUM
MSG & NUM DB '&StrDef'
ENDM
If you call this macro with
MAKEMSG 9,<Enter a value: >
it will expand to
MSG9 DB 'Enter a value: '
Chapter 2, Operators 47
,.
Function Quoted character opera tor
Mode MASM, Ideal
Syntax ! character
Remarks The! operator lets you call macros with arguments that
contain special macro operator characters. This is some-
what equivalent to enclosing the character in angle
brackets. For example,!& is the same as <&>.
Example MAKEMSG MACRO StrDef,NUM
MSG & NUM DB '&StrDef'
ENDM
MAKEMSG <Can't enter !> 99>
In this example, the argument would have been pre-
maturely terminatedif the! operator had not been used.
%
Function Expression evaluate operator
Mode MASM,Ideal
Syntax %expressi on
Remarks expression can be either a numeric expression using any
of the operands and operators described in this chapter
or it can be a text equate. If it is a numeric expression,
the string that is passed as a parameter to the macro
invocation is the result of evaluating the expression. If
expression is a text equate, the string passed is the text of
the text equate. The evalua ted expression will be
represented as a numerical string in the current RADIX.
Use this operator when you want to pass the string
representing a calculated result, rather than the expres-
sion itself, to a macro. Also, a text macro name can be
specified after the %, causing a full substitution of the
text macro body for the macro argument.
11
Chapter 2, Operators 49
50 Turbo Assembler Reference Guide
c H A p T E R
Directives
A source statement can either be an instruction or a directive. An instruction
source line generates object code for the processor operation specified by the
instruction mnemonic and its operands. A directive source line tells the
assembler to do something unrelated to instruction generation, including
defining and allocating data and data structures, defining macros, speci-
fying the fonnat of the listing file, controlling conditional assembly, and
selecting the processor type and instruction set.
Some directives define a symbol whose name you supply as part of the
source line. These include, for example, SEGMENT, LABEL, and GROUP.
Others change the behavior of the assembler but do not result in a symbol
being defined, for example, ORG, IF, %LIST.
The directives presented here appear in alphabetical order (excluding
punctuation); for example, .CODE appears just before CODESEG.
The reserved keywords %TOC and %NOTOC do not perform any
operation in the current version of Turbo Assembler. Future versions will
use these keywords, so you should avoid using them as symbols in your
programs.
The directives fall into three categories:
Chapter 3, Directives 51
3. Turbo Assembler directives that are synonyms for existing MASM
directives: These synonyms provide a more organized alternative to
some existing MASM directives. For example, rather than .LIST and
.XLIST, you use %LIST and %NOLIST. As a rule, all paired directives
that enable and disable an option have the form xxxx and NOxxxx. The
synonyms also avoid using a period (.}as the first character of the
directive name. The MASM directives that start with a period are not
available in Turbo Assembler's Ideal mode, so you must use the new
synonyms instead.
All Turbo Assembler directives that control the listing file start with the
percent (%) character.
In the syntax section of each entry, the following typographical conventions
are used:
• Brackets ([]) indicate optional arguments (you do not need to type in the
brackets) .
.. Ellipses (... ) indicate that the previous item may be repeated as many
times as desired .
• Items in italics are placeholders that you replace with actual symbols and
expressions in your program.
Sample Directive
Function Brief description of what the directive does.
Mode What mode(s} the directive operates in.
Syntax How the directive is used; italicized items are user-
defined
Remarks General information about the directive.
See also Other related directives.
Example Sample code using the directive.
.286
Function Enables assembly of non-privileged 80286 instructions
Mode MASM
Syntax .286
Remarks .286 enables assembly of the additional instructions
supported by the 80286 processor in non-privileged
mode. It also enables the 80287 numeric processor
instructions exactly as if the .287 or P287 directive had
been issued. (Same as P286N and .286C.)
See also .8086, .186, .286C, .286P, .386, .386C, .386P, P8086, P286,
P286N, P286P, P386, P386N, P386P
Example .286
fstsw ax ionly allowed with 80287
.286C
Function Enables assembly of non-privileged 80286 instructions
See also .8086, .186, .286, .286P, .386, .386C, .386P, P8086, P286,
P286N, P286P, P386, P386N, P386P
Chapter 3, Directives 53
.286P
Function Enables assembly of all 80286 instructions
Mode MASM
Syntax .286P
Remarks .286P enables assembly of all the additional instructions
supported by the 80286 processor, including the
privileged mode instructions. It also enables the 80287
numeric processor instructions exactly as if the .287 or
P287 directive had been issued. (Same as P286P.)
See also .8086, .186, .286, .286C, .386, .386C, .386P, P8086, P286,
P286~,P286P,P386,P386~,P386P
.287
Function Enables assembly of 80287 coprocessor instructions
Mode MASM
Syntax .287
Remarks .287 enables assembly of all the 80287 numeric coproces-
sor instructions. Use this directive if you know you'll
never run programs using an 8087 coprocessor. This
directive causes floating-point instructions to be
optimized in a manner incompatible with the 8087, so
don't use it if you want your programs to run using an
8087. (Same as P287.)
See also .8087, .387, P8087, P~087, P287, P387
Example .287
fsetprn ;only on 287
.386
Function Enables assembly of non-privileged 80386 instructions
Mode MASM
Syntax .386
.386C
Function Enables assembly of 80386 instructions
See also .8086, .186, .286C, .286, .286P, .386, .386P, P8086, P286,
P286N, P286P, P386,P386N, P386P
.386P
Function Enables assembly of all 80386 instructions
Mode MASM
Syntax .386P
.387
Function Enables assembly of 80387 coprocessor instructions
Mode MASM
Syntax .387
Chapter 3, Directives 55
never run programs using an 8087 coprocessor. This
directive causes floating-point instructions to be
optimized in a manner incompatible with the 8087, so
don't use it if you want your programs to run using an
8087. (Same as P387.)
See also .8087, .287, 8087, PN087, P287, P387
Example .387
fsin iSIN() only available on 387
.8086
Function Enables assembly of 8086 instructions only
Mode MASM
Syntax .8086
Remarks .8086 enables assembly of the 8086 instructions and dis-
ables all instructions available only on the 80186, 80286,
and 80386 processors. It also enables the 8087 copro-
cessor instructions exactly as if the .8087 or 8087 had
been issued.
This is the default instruction set mode used by Turbo
Assembler when it starts assembling a source file.
Programs assembled using this mode will run on all
members of the 80x86 processor family. If you know that
your program will only be run on one of the more
advanced processors, you can take advantage of the
more sophisticated instructions of that processor by
using the directive that enables that processor's
instructions. (Same as P8086.)
See also J.86, .286C, .286, .286P, .386C, .386, .386P, P8086, P286,
P286N,P286P,P386,P386N,P386P
.8087
Function Enables assembly of 8087 coprocessor instructions
Mode MASM
Syntax .8087
..
Function Defines a near code label
Mode MASM, Ideal
Syntax name:
Remarks name is a symbol that you have not previously defined
in the source file. You can place a near code label on a
line by itself or at the start of a line before an instruction.
You usually use a near code label as the destination of a
]MP or CALL instruction from within the same
segment.
The code label will only be accessible from within the
current source file unless you use the PUBLIC directive
to make it accessible from other source files.
This directive is the same as using the LABEL directive
to define a NEAR label; for example A: is the same as A
LABEL NEAR.
See also LABEL
Example
Chapter 3, Directives 57
Function Defines a numeric equate
Mode MASM,Ideal
Syntax name = expression
Remarks name is assigned the result of evaluating expression,
which must evaluate to either a constant or an address
within a segment. name can either be a new symbol
name, or a symbol that was previously defined using the
=directive.
You can redefine a symbol that was defined using the =
directive, allowing you to use the symbols as counters.
(See the example that follows.)
You can't use = to assign strings or to redefine keywords
or instruction mnemonics; you must use EQU to do
these things.
The = directive has far more predictable behavior than
the EQU directive in MASM mode, so you should use =
instead of EQU wherever you can.
See also EQU
Example BitMask = 1 ;initialize bit mask
BittBl LABEL BYTE
REPT 8
DB BitMask
BitMask = BitMask * 2 ;shift the bit to left
ENDM
ALIGN
Function Rounds up the location counter to a power-of-two
address
Mode MASM,Ideal
Syntax ALIGN boundary
Remarks boundary must be a power of 2 (for example, 2, 4, 8, and
so on).
If the location counter is not already at an offset that is a
multiple of boundary, single byte NOP instructions are
.ALPHA
Function Sets alphanumeric segment-ordering
Mode MASM
Syntax •ALPHA
Remarks You usually use .ALPHA to ensure compatibility with
very old versions of MASM and the IBM assembler. The
default behavior of these old assemblers is to emit seg-
ments in alphabetical order, unlike the newer versions.
Use this option when you assemble source files written
for old assembler versions.
If you don't use this directive, the segments are ordered
in the same order that they were encountered in the
source file. The DOSSEG directive can also affect the
ordering of segments .
.ALPHA does the same thing as the IA command-line
option. If you used the IS command-line option to force
sequential segment-ordering, .ALPHA will override it.
Chapter 3, Directives 59
See also DOSSEG, .SEQ,
Example .ALPHA
XYZ SEGMENT
XYZ ENDS
ABC SEGMENT ;this segment will be first
ABC ENDS
ARC
Function Sets up arguments on the stack for procedures
Mode MASM,Ideal
Syntax arg argument [,argument] ... [=symbol] [RETURNS
argument [,argument]]
Remarks ARG usually appears within a PROC/ENDP pair,
allowing you to access arguments pushed on the stack
by the caller of the procedure. Each argument is assigned
a positive offset from the BP register, presuming that
both the return address of the function call and the
caller's BP have been pushed onto the stack already.
argument describes an argument the procedure is called
with. The language specified with the .MODEL directive
determines whether the arguments .are in reverse order
on the stack. You must always list the arguments in the
same order they appear in the high-level language
function that calls the procedure. Turbo Assembler
reads them in reverse order if necessary. Each argument
has the following syntax:
argname[ [col,lntl] ] [: [distance] PTR] type] [:count2]
Chapter 3. Directives 61
ARG REALBYTE:BYTE:l
If you don't supply a count for BYTE arguments, a
count of 2 is presumed.
The optional RETURNS keyword introduces one or
more arguments that won't be popped from the stack
when the procedure returns to its caller. Normally, if
you specify the language as PASCAL or TP ASCAL
when using the .MODEL directive, all arguments are
popped when the procedure returns. If you place
arguments after the RETURNS keyword, they will be
left on the stack for the caller to make use of, and then
pop. In particular, you must define a Pascal string return
value by placing it after the RETURNS keyword.
See also LOCAL, PROC, USES
Example A sample Pascal procedure:
fp PROC FAR
ARG SRC:WORD,DEST:WORD = ARGLEN
push bp
mov bp,sp
mov di,DEST
mov si,SRC
;<Procedure body>
pop bp
ret ARGLEN
fp ENDP
ASSUME
Function Associates segment register with segment or group
name
Mode MASM, Ideal
Syntax ASSUME segmentreg:name {,segmentreg:namej .•.
ASSUME segmentreg:NOTHING
ASSUME NOTHING
Remarks segmentreg is one of CS, DS, ES, or SS registers and, if
you have enabled the 80386 processor with the P386 or
P386N directives, the FS and GS registers.
name can be one of the following:
%BIN
Function Sets the width of the object code field in the listing file
Mode MASM, Ideal
Syntax %BIN size
Remarks size is a constant. If you don't use this directive, the
instruction opcode field takes up 20 columns in the
listing file.
Example %BIN 12 ;set listing width to 12 columns
Chapter 3, Difecffves 63
CATSTR
Function Concatenates several strings to form a single string
Mode MASM51, Ideal
Syntax name CATSTR string[,string] •••
Remarks name is given a value consisting of all the characters
from each string combined into a single string.
Each string may be one of the following:
• a string argument enclosed in angle brackets,like
<abc>
• a previously defined text macro
• a numeric string substitution starting with percent (%)
See also SUBSTR, INSTR, SIZESTR
Example LETTERS CATSTR <abc>,<def> iLETTERS = lIabcdefli
.CODE
Function Defines the start of a code segment
Mode MASM
Syntax .CODE [name]
Remarks The .CODE directive indicates the start of the executable
code in your module. You must first have used the
.MODEL directive to specify a memory model. If you
specify the medium or large memory model, you can
follow the .CODE directive with an optional name that
indicates the name of the segment. This way you can put
multiple code segments in one file by giving them each a
different name.
You can place as many .CODE directives as you want in
a source file. All the different pieces with the same name
will be combined to produce one code segment exactly
as if you had entered all the code at once after a single
.CODE directive.
Using the .CODE directive allows the CS register to
access the current code segment. This behavior is exactly
CODESEG
Function Defines the start of the code segment
Mode MASM, Ideal
Remarks CODESEG is the same as .CODE.
See also CODE, .DATA, .FARDATA, .FARDATA?, .MODEL,
.STACK
COMM
Function Defines a communal variable
Mode MASM,Ideal
Syntax COMM definition [,definition] •..
Remarks Each definition describes a symbol and has the following
format:
[distance] name:type [:count]
Chapter 3, Directives 65
name is the symbol that is to be communal and have
storage allocated at link time. type can be one of the
following: BYTE, WORD, DATAPTR, DWORD,
FWORD, PWORD, QWORD, TBYTE, or a structure
name.
The optional count specifies how many items this
communal symbol defines. If you do not specify a count,
one is assumed. The total space allocated for the com-
munal variable is the count times the length specified by
the type field.
You can define more than one communal symbol by
separating each definition with a comma (,).
Communal variables are allocated by the linker.
In MASM mode, communal symbols declared outside of
any segment are presumed to be reachable via the DS
register, which may not always be a valid assumption.
Make sure that you either place the correct segment
value in DS or use an explicit segment override when
referring to these variables. In Ideal mode, Turbo
Assembler correctly checks for whether the communal
variable is addressable, using any of the current segment
registers as described with the ASSUME directive.
Communal variables can't be initialized. Use the
GLOBAL directive if you wish to initialize data items
that are to be shared between modules. The linker also
doesn't guarantee the allocation of communal variables
in any particular order, so you can't make assumptions
about data items allocated by COMM directives on
sequential source lines.
See also EXTRN, GLOBAL, PUBLIC
Example COMM buffer:BYTE:512 ;allocated at link time
COMMENT
Function Starts a comment block
Mode MASM
Syntax COMMENT delimiter [text]
[ text]
delimiter
%CONDS
Function Shows all statements in conditional blocks in the listing
Mode MASM,Ideal
Syntax %CONDS
Remarks %CONDS is the default conditional listing mode if you
don't use any listing control directives. (Same as
.LFCOND.)
When %CONDS is in effect, the listing will show all
statements within conditional blocks, even those blocks
that evaluate as false and don't result in the evaluation
of enclosed statements.
See also %NOCONDS, .LFCOND, .SFCOND, .TFCOND
Example %CONDS
IF 0
mov ax,l iin listing, despite "IF 0" above
ENDIF
.CONST
Function Defines constant data segment
Mode MASM
Syntax .CONST
Remarks The .CONST directive indicates the start of the segment
in your program containing constant data. This is data
your program requires, but it will not be changed when
the program executes. You can put things such as
prompt and message strings in this segment.
Chapter 3, Directives 67
You don't have to use this directive when writing an
assembler-only program. It exists so that you can write
routines that interface to high-level languages and then
use this for initializing constant data .
See also .CODE, .DATA, .DATA?, .FARDATA, .FARDATA?,
.MODEL
Example .CONST
MSG DB "Execution terminated"
CONST
Function Defines constant data segment
Mode MASM, Ideal
See also .CODE, .CONST, .DATA, DATA?, .FARDATA,
.FARDATA?
.CREF
Function Enables cross-reference listing (CREF)
Mode MASM
Syntax .CREF
Remarks .CREF allows cross-reference information to be accumu-
lated for all symbols encountered from this point
forward in the source file. This directive reverses the
effect of any %XCREF or .XCREF directives that
inhibited the collection of cross-reference information.
Turbo Assembler includes cross-reference information
in the listing file, as well as in a separate.XRF file.
See also %CREF
%CREF
Function Enables cross-reference listing (CREF)
Mode MASM,Ideal
Syntax %CREF
%CREFALL
Function Lists all symbols in cross-reference
Mode MASM,Ideal
Syntax %CREFALL
Remarks %CREFALL reverses the effect of any previous
%CREFREF or %CREFUREF directives that disabled
the listing of unreferenced or referenced symbols. After
issuing %CREFALL, all subsequent symbols in the
source file will appear in the cross-reference listing.
By default, Turbo Assembler uses this mode when
assembling your source file.
See also %CREFREF, %CREFUREF
Example %CREFREF
ARGI EQU [bp+4] inot referenced, won't be in listing
%CREFALL
ARG2 EQU [bp+6] inot referenced, appears anyway
ARG3 EQU [bp+8] ireferenced, appears in listing
mov ax,ARG3
END
%CREFREF
Function Disables listing of unreferenced symbols in cross-
reference
Mode MASM,Ideal
Syntax %CREFREF
Remarks %CREFREF causes symbols that are defined but never
referenced to be omitted from the cross-reference listing.
Normally when you request a cross-reference, these
symbols appear in the symbol table.
See also %CREF, %CREFUREF, %CREFALL
Chapter 3, Directives 69
Example %CREF
abc EQU 4 iwill not appear in CREF listing
xyz EQU 1 iwill appear in listing
mov ax,xyz imakes XYZ appear in listing
END
%CREFUREF
Function Lists only the unreferenced symbols in cross-reference
Mode MASM, Ideal
Syntax %CREFUREF
Remarks %CREFUREF enables the listing of un referenced sym-
bols in the symbol table cross-reference. When you use
this directive, only unreferenced symbols appear in the
symbol table. To see both referenced and unreferenced
symbols, use the %CREFALL directive.
See also %CREFALL, %CREFREF
Example %CREF
abc EQU 2 idoesn't appear in listing
%CREFUREF
def EQU 1 iappears in listing
END
%CTLS
Function Prints listing controls
Mode MASM,Ideal
Syntax %CTLS
Remarks %CTLS causes listing control directives (such as % LIST,
% INCL, and so on) to be placed in the listing file;
normally, they are not listed. It takes effect on all
subsequent lines, so the %CTLS directive itself will not
appear in the listing file.
See also %NOCTLS
Example %CTLS
%NOLIST ithis will be in listing file
.DATA?
Function Defines the start of an uninitialized data segment
Mode MASM
Syntax •DATA?
Remarks The .DATA? directive indicates the start of the unini-
tialized data in your module. You must first have used
the .MODEL directive to specify a memory model.
You create uninitialized data using the DUP operator
with the? symbol. For example,
DB 6 DUP (?)
Chapter 3, Directives 71
You do not have to use this directive when writing an
assembler-only program. It exists so that you can write
routines that interface to high-level languages and then
use this directive for uninitialized data.
You can place as many .DATA? directives as you want
in a source file. All the pieces will be combined to pro-
duce one data segment, exactly as if you had entered all
the data at once after a single .DATA? directive.
The uninitialized data segment is put in a group called
DGROUP, which also contains the segments defined
with the .STACK, .CONST, and .DATA directives.
See .MODEL for complete information on the segment
attributes for the uninitialized data segment.
See also .CODE, .CONST, .DATA, .FARDATA, .FARDATA?,
.MODEL, .STACK
Example . DATA?
TEMP DD 4 DUP (?) ;uninitialized data
DATASEG
Function Defines the start of a data segment
Mode MASM, Ideal
Syntax DATASEG
Remarks DAT ASEG is the same as .DAT A. It must be used in
Ideal mode only.
See also .CODE, .CONST, .DATA, .DATA?, .FARDATA,
.FARDATA?, .MODEL, .STACK
DB
Function Allocates byte-size storage
Mode MASM, Ideal
Syntax [name] DB expression [,expression] .••
Remarks name is the symbol you'll subsequently use to refer to
the data. If you don't supply a name, the data will be
DD
Function Allocates doubleword-sized storage
Mode MASM, Ideal
Syntax [name] DD [type PTR] expression [,expression] ...
Remarks name is the symbol you'll subsequently use to refer to
the data. If you don't supply a name, the data will be
allocated, but you won't be able to refer to it using a
symbolic name.
type followed by PTR is optional. It adds debug
information to the symbol being defined, so that Turbo
Debugger can display its contents properly. It has no
effect on the data generated by Turbo Assembler. type
can be one of the following: BYTE, WORD, DATAPTR,
DWORD, FWORD, PWORD, QWORD, TBYTE,
SHORT, NEAR, FAR or a structure name. For example,
person STRUC
name DB 32 DUP(?)
age DW ?
person ENDS
PPTR DD person PTR 0 iPPTR is a far pointer
i to the structure
Chapter 3, Directives 73
Each expression allocates one or more doublewords
(4 bytes) and may be one of the following:
• A constant expression that has a value between
-2,147,483,648 and 4,294,967,295.
• A short (32-bit) floating-point number.
• The question mark (?) indeterminate initialization
symbol; this allocates storage without giving it a
specific value.
• An address expression, specifying a far address in a
16-bit segment (segment:offset) or a near address in a
32-bit segment (32-bit offset only).
• A repeated expression using the DUP operator.
See also DB, DF, DP, DQ, DT, DW
Example Data32 SEGMENT USE32
Xarray DB 0,1,2,3
Data32 ENDS
Data SEGMENT
Consts DD 3.141, 2.718 ;floating-point constants
DblPtr DO Consts ;16-bit far pointer
NrPtr DO Xarray ;32-bit near pointer
Biglnt DO 12345678 ;large integer
Darray DO 4 DUP (1) ;4 integers
%DEPTH
Function Sets size of depth field in listing file
Mode MASM, Ideal
Syntax %DEPTH width
Remarks width specifies how many columns to reserve for the
nesting depth field in the listing file. The depth field
indicates the nesting level for INCLUDE files and macro
expansions. If you specify a width of 0, this field does
not appear in the listing file. Usually, you won't need to
specify a width of more than 2, since that would display
a depth of up to 99 without truncation.
The default width for this field is 1 column.
Example %OEPTH 2 ;show nesting levels> 9
Chapter 3, Directives 75
MSG DB "All done"
FmPtr DF MSG iFAR pointer to MSG
DATA ENDS
DISPLAY
Function Outputs a quoted string to the screen
Mode Ideal,MASM
Syntax DISPLAY "text"
Remarks text is any message you want to display; you must sur-
round it with quotes (""). The message is written to the
standard output device, which is usually the screen. If
you wish, you can use the DOS redirection facility to
send screen output to a file.
Among other things, you can use this directive to inform
yourself of the genera tion of sections of conditional
assembly.
See also %OUT
Example DISPLAY "Assembling EGA interface routines"
DOSSEG
Function .Enables DOS segment-ordering at link time
Mode MASM, Ideal
Syntax DOSSEG
Remarks You usually use DOSSEG in conjunction with the
.MODEL directive, which sets up the simplified seg-
mentation directives. DOSSEG tells the linker to order
the segments in your program the same way high-level
languages order their segments.
You should 'only use this directive when you are writing
stand-alone assembler programs, and then you only
need to use the DOSSEG directive once in the main
module that specifies the starting address of your
program.
Segments appear in the following order in the execut-
able program:
DP
Function Defines a far 48-bit pointer (6 byte) data area
Mode MASM, Ideal
See also DB, DD, DF, DQ, DT, DW
DQ
Function Defines a quadword (8 byte) data area
Mode MASM,Ideal
Syntax [name] DQ expression [,expression] ..•
Chapter 3, Directives 77
• The question mark (?) indeterminate initialization
symbol; this allocates storage without giving it a
specific value.
• A repeated expression using the DUP operator.
See also DB, DD, DF, DP, DT, DW
Example Huglnt DQ 314159265358979323
BigFlt DQ 1.2345678987654321
Qarray DQ 10 DUP (?)
DT
Function Defines a IO-byte data area
Mode MASM,Ideal
Syntax [name] DT expression [,expression] ••.
Remarks name is the symbol you'll subsequently use to refer to
the data. If you don't supply a name, the data will be
allocated, but you won't be able to refer to it using a
symbolic name.
Each expression allocates one or more IO-byte values and
may be one of the following:
• A constant expression that has a value between _2 79
and 280_l.
• A packed decimal constant expression that has a value
between 0 and 99,999,999,999,999,999,999.
• The question mark (?) indeterminate initialization
symbol; this allocates storage without giving it a
specific value.
• A IO-byte temporary real formatted floating-point
number.
• A repeated expression using the DUP operator.
See also DB, DD, DF, DP, DQ, DW
Example PakNum DT 123456 ;beware--packed decimal
TempVal DT 0.0000000001 ;high precision FP
Chapter 3, Directives 79
ELSE
Function Starts alternative conditional assembly block
Mode MASM,Ideal
Syntax IF condi tion
statementsl
[ELSE
statements2]
ENDIF
Remarks The statements introduced by ELSE are assembled if the
condition associated with the IF statement evaluates to
false. This means that either statementsl will be
assembled or statements2 will be assembled, but not
both.
The ELSE directive always pairs with the nearest
preceding IF directive that's not already paired with an
ELSE directive.
See also ENDIF, IF, 1Ft, IF2, IFB, IFDEF, IFDIF, IFDIFI, IFE,
IFIDN, IFIDNI, IFNB, IFNDEF
Example IF LargeModel EQ 1
les di,ADDR
ELSE
lea di,ADDR
ENDIF
ELSEIF
Function Starts nested conditional assembly block if an expression
is True
Mode MASM,Ideal
Syntax ELSEIF expression
Remarks expression must evaluate to a constant and cannot con-
tain any forward -referenced symbol names. If expression
evaluates to a nonzero value, the statements within the
conditional block are assembled, as long as the
conditional directive (IF, and so on) preceding the
ELSEIF evaluated to False.
EMUL
Function Generates emulated coprocessor instructions
Mode MASM,Ideal
Syntax EMUL
Chapter 3, Directives 81
END
Function Marks the end of a source file
Mode MASM,Ideal
Syntax END [startaddress]
Remarks startaddress is an optional symbol or expression that
specifies the address in your program where you want
execution to begin. If your program is linked from
multiple source files, only one file may specify a start-
address. startaddress may be an address within the
module; it can also be an external symbol defined in
another module, declared with the EXTRN directive.
Turbo Assembler ignores any text after the END
directive in the source file.
Example .MODEL small
•CODE
START:
iBody of program goes here
END START iprogram entry point is "START"
THIS LINE IS IGNORED
SO IS THIS ONE
ENDIF
Function Marks the end of a conditional assembly block
Mode MASM, Ideal
Syntax IF condition
statements
ENDIF
Remarks All conditional assembly blocks started with one of the
IFxxxx directives must end with an ENDIF directive.
You can nest IF blocks up to 255 levels deep.
See also ELSE, IF, IF1, IF2, IFB, IFDEF, IFDIF, IFDIFI, IFE,
IFIDN, IFIDNI, IFNB, IFNDEF
Example IF DebugMode iassemble following if debug mode not 0
mov ax/O
call DebugDump
ENDIF
ENDP
Function Indicates the end of a procedure
Mode MASM,Ideal
Syntax MASMmode:
[procname] ENDP
Ideal mode:
ENDP [procname]
Remarks If you supply the optional procname, it must match the
procedure name specified with the PROC directive that
started the procedure definition.
Notice that in Ideal mode, the optional procname comes
after the ENDP.
ENDP does not generate a RET instruction to return to
the procedure's caller; you must explicitly code this.
See also ARG, LOCAL, PROC
Example Loadlt PROC
iBody of procedure
ret
Loadlt ENDP
Chapter 3, Directives 83
ENDS
Function Marks end of current segment structure or union
Mode MASM,Ideal
Syntax MASMmode:
[segmentname] ENDS
[strucname] ENDS
Ideal mode:
ENDS [segmentname]
ENDS [strucname]
Remarks ENDS marks the end of either a segment, structure, or
union. If you supply the optional segmentname, it must
rna tch the segment name specified with the matching
SEGMENT directive. Likewise, the optional strucname
must match the structure name specified with the
matching STRUC or UNION directive.
Notice that in Ideal mode, the optional name comes after
the ENDS.
See also SEGMENT, STRUC, UNION
Example DATA SEGMENT ;start of data segment
Barray DB 10 DUP (0)
DATA ENDS ;end of data segment,
; optional "data" included
STAT STRUC
Mode DW ?
FuncPtr DD?
ENDS ;end of structure definition
EQU
Function Defines a string, alias, or numeric equate
Mode MASM,Ideal
Syntax name EQU expression
Remarks name is assigned the result of evaluating expression. name
must be a new symbol name that has not previously
been defined in a different manner. In MASM mode, you
can only redefine a symbol that was defined using the
EQU directive if it was first defined as a string equate.
.ERR
Function Forces an error message
Mode MASM
Syntax • ERR
Chapter 3, Directives 85
ERR
Function Forces an error message
Mode MASM, Ideal
Syntax ERR
Remarks Same as .ERR.
See also .ERR1, .ERR2, .ERRE, .ERRNZ, .ERRNDEF, .ERRDEF,
.ERRB, .ERRNB, .ERRIDN, .ERRIDNI, .ERRDIF,
.ERRDIFI
.ERR1
Function Forces an error message on pass 1
Mode MASM
Syntax .ERRl
Remarks Since Turbo Assembler is a single-pass assembler, the
fact that .ERRl forces a message on pass 1 means that
the error message is forced on the assembly pass. This
means that the error message will appear on the screen
but will not appear in the listing file, which is generated
during a second pass. (This directive would have a
different meaning with a two-pass assembler.)
Again, since this is a single-pass assembler, this directive
also generates a warning message so that you know it's
pass-dependent and may not work as you expect.
See also .ERR2
Example .ERRl ;this won't appear in listing
.ERR2
Function Forces an error message on pass 2
Mode MASM
Syntax .ERR2
Remarks Since Turbo Assembler is a single-pass assembler, the
fact that this forces a message on pass 2 means that it's
.ERRB
Function Forces an error if argument is blank
Mode MASM
Syntax .ERRB <argument>
Remarks You always use this argument inside a macro. It tests
whether the macro was called with a real argument to
replace the specified dummy argument. If the argument is
blank (empty), an error message occurs on the source
line where the macro was invoked.
You must always surround the argument to be tested
with angle brackets « ».
See also .ERRNB
Example DOUBLE MACRO ARGl
.ERRB <ARG1> ;require an argument
shl ARG1,1 ;double the argument's value
ENDM
.ERRDEF
Function Forces an error if a symbol is defined
Mode MASM
Syntax .ERRDEF symbol
Remarks .ERRDEF causes an error message to be generated at the
current source line number if symbol has already been
defined in your source file.
Chapter 3, Directives 87
See also .ERRNDEF
Example SetMode MACRO ModeVal
.ERRDEF MODE ;error if already defined
_MODE EQU ModeVal
ENDM
.ERRDIF
Function Forces an error if arguments are different
Mode MASM
Syntax .ERRDIF <argumentl>,<argument2>
Remarks You always use .ERRDIF inside a macro. It tests
whether its two arguments are identical character
strings. If the two strings are not identical, an error mes-
sage occurs on the source line where the macro was
invoked. The two strings are compared on a character-
by-character basis; case is significant. If you want case to
be ignored, use the .ERRDIFI directive.
You must always surround each argument in angle
brackets « »; separate arguments with a comma.
See also .ERRIDN, .ERRDIFI, .ERRIDNI
Example SegLoad MACRO reg, val
.ERRDIF <reg>,<es> ;only permit ES register
rnov ax, val
rnov reg,ax
ENDM
.ERRDIFI
Function Forces an error if arguments are different, ignoring case
Mode MASM
Syntax .ERRDIFI <argumentl>,<argument2>
Remarks You always use .ERRDIFI inside a macro. It tests
whether its two arguments are identical character
strings. If the two strings are not identical, an error mes-
sage occurs on the source line where the macro was
invoked. The two strings are compared on a character-
.ERRE
Function Forces an error if expression is false (0)
Mode MASM
Syntax .ERRE expression
Remarks expression must evaluate to a constant and cannot
contain any forward-referenced symbol names. If the
expression evaluates to 0, an error message occurs at the
current source line.
See also .ERRNZ
Example PtrLoad MACRO PTR,val
.ERRE val ;error if attempt 0 load to pointer
mov si,val
ENDM
.ERRIDN
Function Forces an error if arguments are identical
Mode MASM
Syntax .ERRIDN <argumentl>,<argument2>
Remarks You always use .ERRIDN inside a macro. It tests
whether its two arguments are identical character
strings. If the two strings are identical, an error message
occurs on the source line where the macro was invoked.
The two strings are compared on a character-by-
Chapter 3, Directives 89
character basis; case is significant. If you want case to be
ignored, use the .ERRIDNI directive.
You must always surround each argument in angle
brackets « »; separate arguments with a comma .
See also .ERRDIF, .ERRIDNI, .ERRDIFI
Example PushSeg MACRO reg, val
.ERRIDN <reg>,<cs> ;CS load is illegal
push reg
mov reg, val
ENDM
.ERRIDNI
Function Forces an error if arguments are identical, ignoring case
Mode MASM
Syntax .ERRIDNI <argumentl>,<argument2>
Remarks You always use .ERRIDNI inside a macro. It tests
whether its two arguments are identical character
strings. If the two strings are identical, an error message
occurs on the source line where the macro was invoked.
The two strings are compared on a character-by-
character basis; case is insignificant. If you want case to
be significant, use the .ERRIDN directive.
You must always surround each argument in angle
brackets « »; separate arguments with a comma.
See also .ERRDIF, .ERRIDN, .ERRDIFI
Example PushSeg MACRO reg, val
.ERRIDNI <reg>,<cs> ;CS load is illegal
push reg ;takes CS or cs
mov reg, val
ENDM
ERRIFI
Function Forces an error message on pass 2
Mode MASM,Ideal
See also .ERRl
ERRIF2
Function Forces an error message on pass 2
Mode MASM,Ideal
See also .ERR2
ERRIFB
Function Forces an error if argument is blank
Mode MASM, Ideal
See also .ERRB
ERRIFDEF
Function Forces an error if a symbol is defined
Mode MASM, Ideal
See also .ERRDEF
Chapter 3, Directives 91
ERRIFDIF
Function Forces an error if arguments are different
Mode MASM, Ideal
See also .ERRDIF
ERRIFDIFI
Function Forces an error if arguments are different, ignoring case
Mode MASM,Ideal
See also .ERRDIFI
ERRIFE
Function Forces an error if expression is false (0)
Mode MASM,Ideal
See also .ERRE
ERRIFIDN
Function Forces an error if arguments are identical
Mode MASM,Ideal
See also .ERRIDN
ERRIFIDNI
Function Forces an error if arguments are identical, ignoring case
Mode MASM,Ideal
See also .ERRIDNI
ERRIFNDEF
Function Forces an error if symbol is not defined
Mode MASM, Ideal
See also .ERRNDEF
.ERRNB
Function Forces an error if argument is not blank
Mode MASM
Syntax .ERRNB <argument>
Remarks You always use .ERRNB inside a macro. It tests whether
the macro was called with a real argument to replace the
specified dummy argument. If the argument is not blank,
an error message occurs on the source line where the
macro was invoked.
You must always surround the argument to be tested
with angle brackets « ».
See also .ERRB
Example Dolt MACRO a, b
.ERRNB <B> ionly need one argument
ENDM
Chapter 3, Directives 93
·ERRNDEF
Function Forces an error if symbol is not defined
Mode MASM
Syntax . ERRNDEF symbol
Remarks .ERRNDEF causes an error message to be generated at
the current source line number if symbol has not yet been
defined in your source file. The error occurs even if the
symbol is defined later in the file (forward-referenced) .
See also .ERRDEF
Example .ERRNDEF BufSize ino buffer size set
BUF DB BufSize
.ERRNZ
Function Forces an error if expression is true (nonzero)
Mode MASM
Syntax .ERRNZ expression
Remarks expression must evaluate to a constant and may not
contain any forward-referenced symbol names. If the
expression evaluates to a nonzero value, an error mes-
sage occurs at the current source line.
See also .ERRE
Example .ERRNZ $ GT lOOOh isegment too big
EVEN
Function Rounds up the location counter to the next even address
Mode MASM,Ideal
Syntax EVEN
Remarks EVEN allows you to align code for efficient access by
processors that use a 16-bit data bus (8086,80186, 80286).
It does not improve performance for those processors
with an 8-bit data bus (8088, 80188).
EVENDATA
Function Rounds up the location counter to the next even address
in a data segment
Mode Masm, Ideal
Syntax EVENDATA
Remarks EVENDATA allows you to align data for efficient access
by processors that use a 16-bit data bus (8086, 80186,
80286). It does not improve performance for those
processors with an 8-bit data bus (8088, 80188).
EVENDATA even-aligns by advancing the location
counter without emitting data, which is useful for
uninitialized segments. A warning is generated if the
alignment isn't strict enough.
You can't use this directive in a segment that has BYTE-
alignment, as specified in the SEGMENT directive that
opened the segment.
If the location counter is odd when an EVENDATA
directive appears, a single byte of 0 is inserted in the
segment to make the location counter even. If the loca-
tion is already even, this directive has no effect.
See also ALIGN, EVEN
Chapter 3, Directives 95
Example EVENDATA
VARl DW 0 ialign for efficient 8086 access
EXITM
Function Terminates macro- or block-repeat expansion
Mode MASM,Ideal
Syntax EXITM
Remarks EXITM stops any macro expansion or repeat block
expansion that's in progress. All remaining statements
after the EXITM are ignored.
This is convenient for exiting from multiple levels of
conditional assembly.
See also ENDM, IRP, IRPC, REPT, MACRO
Example Shiftn MACRO OP,N
Count = 0
REPT N
shl OP,N
Count = Count + 1
IF Count GE 8 ino more than 8 allowed
EXITM
ENDIF
ENDM
EXTRN
Function Indicates a symbol is defined in another module
Mode MASM,Ideal
Syntax EXTRN definition [,definition] .••
Remarks Each definition describes a symbol and ·has the following
format:
name:type [:count]
name is the symbol that is defined in another module.
type must match the type of the symbol where it's
defined in another module. It can be one of the
following:
Chapter 3, Directives 97
·FARDATA
Function Defines the start of a far data segment
Mode MASM
Syntax •FARDATA [name]
.FARDATA?
Function Defines the start of a far uninitialized data segment
Mode MASM
Syntax .FARDATA? [name]
FARDATA
Function Defines the start of a far data segment
Mode MASM,Ideal
Syntax FARDATA [name]
Remarks Same as .FARDATA.
See also .FARDATA
Chapter 3, Directives 99
GLOBAL
Function Defines a global symbol
Mode MASM,Ideal
Syntax GLOBAL definition [,definition] •••
Remarks GLOBAL acts as a combination of the EXTRN and
PUBLIC directives. Each definition describes a symbol
and has the following format:
name:type [:count]
If name is defined in the current source file, it is made
public exactly as if used in a PUBLIC directive. If name is
not defined in the current source file, it is declared as an
. external symbol of type type, as if the EXTRN directive
had been used.
type must match the type of the symbol in the module
where it is defined. It can be one of the following:
• NEAR, FAR, or PROC
• BYTE, WORD, DATAPTR, DWORD, FWORD,
PWORD, QWORD, TBYTE, or a structure name
.ABS
The optional count specifies how many items this
symbol defines. If the symbol's definition uses the DUP
directive to allocate more than one item, you can place
that value in the count field. This lets the SIZE and
LENGTH operators correctly determine the size of the
external data item. If you do not specify a count, it is
assumed to be one.
The GLOBAL directive lets you have an INCLUDE file
included by all source files; the INCLUDE file contains
all shared data defined as global symbols. When you
reference these data items in each module, the GLOBAL
definition acts as an EXTRN directive, describing how
the data is defined in another module. In the module in
which you ·define the data item, the GLOBAL definition
acts as a PUBLIC directive, making the data available to
the other modules.
You can define more than one public symbol by
separating each definition with a comma (,).
GROUP
Function Defines segments as accessible from a single segment
register
Mode MASM, Ideal
Syntax MASMmode:
name GROUP segmentname [,segmentname] •••
Ideal mode:
GROUP name segmentname [,segmentname] .••
Remarks name defines the name of the group. segmentname can be
either a segment name defined previously with the
SEGMENT directive or an expression starting with
SEG. You can use name in the ASSUME directive and
also as a constant in expressions, where it evaluates to
the starting paragraph address of the group.
All the segments in a group must fit into 64K, even
though they don't have to be contiguous when linked.
In MASM mode, you must use a group override
whenever you access a symbol in a segment that is part
of a group. In Ideal mode, Turbo Assembler auto-
matically generates group overrides for symbols in
segments that belong to a group.
In the example shown here, even though var1 and var2
belong to different segments, they both belong to the
IDEAL
Function Enters Ideal assembly mode
Mode MASM, Ideal
Syntax IDEAL
Remarks IDEAL makes the expression parser only accept the
more rigid, type-checked syntax required by Ideal mode.
See Chapter 12 of the User's Guide for a complete
discussion of the capabilities and advantages of Ideal
mode.
Ideal mode will stay in effect until it is overridden by a
MASM or QUIRKS directive.
See also QUIRKS, MASM
Example IDEAL
mov [BYTE ds:si],l ;Ideal operand syntax
IFl
Function Starts conditional assembly block; enabled on pass 1
Mode MASM, Ideal
Syntax IF!
Remarks Because Turbo Assembler is a single-pass assembler, the
statements within the conditional block are assembled
on the assembly pass, but not during any subsequent
listing pass. (IF1 has a different meaning with a two-
pass assembler.)
When using a forward-referenced operator redefinition,
you can't always tell from the listing file that something
has gone wrong. By the time the listing is generated on
pass 2, the operator has been redefined. This means that
the listing will appear to be correct, but the code would
not have been generated properly to the object file.
Use the END IF directive to terminate the conditional
assembly block.
IF2
Function Starts conditional assembly block; enabled on pass 2
Mode MASM, Ideal
Syntax IF2
Remarks Because Turbo Assembler is a single-pass assembler, the
statements within the conditional block are assembled
on the listing pass, but not during the previous assembly
pass. (IF2 has a different meaning with a two-pass
assembler.)
Because Turbo Assembler is a single-pass assembler, IF2
also generates a warning message to inform you that it is
pass-dependent and may not work as you'd expect.
When using a forward-referenced operator redefinition,
you can't always tell from the listing file that something
has gone wrong. By the time the listing is generated on
pass 2, the operator has been redefined. This means that
the listing will appear to be correct, but the code would
not have been generated properly to the object file.
Use the ENDIF directive to terminate the conditional
assembly block.
See also ELSE, ENDIF, IF, IF1, IFB, IFDEF, IFDIF, IFDIFI, IFE,
IFIDN, IFIDNI, IFNB, IFNDEF
Example IF2
iOnly appears in listing
ENDIF
IFDEF
Function Starts conditional. assembly block; enabled if symbol is
defined
Mode MASM, Ideal
Syntax IFDEF symbol
Remarks If symbol is defined, the statements within the. condi-
tional block are assembled.
Use the ENDIF directive to terminate the conditional
assembly block.
See also ELSE, ENDIF,IF, 1Ft, IF2, IFB, IFDIF, IFDIFI, IFE,
IFIDN, IFIDNI, IFNB, IFNDEF
IFE
Function Starts conditional assembly block; enabled if expression is
false
Mode MASM,Ideal
Syntax IFE expression
IFIDN, IFIDNI
Function Starts conditional assembly block; enabled if arguments
are identical
Mode MASM, Ideal
Syntax IFIDN <argumentl>,<argument2>
Remarks You usually use IFIDN inside a macro. It tests whether
its two arguments are identical character strings. Either
of the arguments can be macro dummy arguments that
will have real arguments to the macro call that was
substituted before performing the comparison. If the
two strings are identical, the statements within the
conditional block are assembled. The two strings are
compared on a character-by-character basis; case is
significant. If you want case to be ignored, use the
IFIDNI directive.
Use the ENDIF directive to terminate the conditional
assembly block.
See also ELSE, ENDIF, IF, IF1, IF2, IFB, IFDEF, IFDIF, IFDIFI,
IFE, IFIDNI, IFNB, IFNDEF
Example RDWR MACRO BUF,RWMODE
mov ax,BUF
IFIDN <RWMODE>,<READ>
call ReadIt
ENDIF
IFIDN <RWMODE>,<WRITE>
call WriteIt
IFNB
Function Starts conditional assembly block, enabled if argument
is nonblank
Mode MASM, Ideal
Syntax IFNB <argument>
Remarks If argument is nonblank, the statements within the condi-
tional block are assembled. Use IFNB to test whether a
macro was called with a real argument to replace the
specified dummy argument.
You must always surround the argument to be tested
with angle brackets « ».
Use the END IF directive to terminate the conditional
assembly block.
See also ELSE, ENDIF, IF, IF1, IF2, IFB, IFDEF, IFDIF, IFDIFI,
IFE, IFIDN, IFIDNI, IFNDEF
Example PopRegs MACRO REG1,REG2
IFNB <REG1>
pop REGl
ENDIF
IFNB <REG2>
pop REG2
ENDIF
ENDM
IFNDEF
Function Starts conditional assembly block; enabled if symbol is
not defined
Mode MASM,Ideal
Syntax IFNDEF symbol
Remarks If symbol has not yet been defined in the source file, the
statements within the conditional block are assembled.
Use the ENDIF directive to terminate the conditional
assembly block.
%INCL
Function Allows listing of include files
Mode MASM,Ideal
Syntax %INCL
Remarks Use %INCL after a %NOINCL directive has turned off
listing of INCLUDE files. This is the default INCLUDE
file listing mode.
See also %NOINCL
Example %INCL
INCLUDE DEFS.INC icontents appear in listing
INCLUDE
Function Includes source code from another file
Mode MASM,Ideal
Syntax MASMmode:
INCLUDE filename
Ideal mode:
INCLUDE "filename"
Remarks filename is a source file containing assembler statements.
Turbo Assembler assembles all statements in the
included file before continuing to assemble the current
file.
filename uses the normal DOS file-naming conventions,
where you can enter an optional drive, optional direc-
tory, file name, and optional extension. If you don't
provide an extension, .ASM is presumed.
If filename does not include a directory or drive name,
Turbo Debugger first searches for the file in any direc-
INCLUDELIB
Function Tells the linker to include a library
Mode MASM, Ideal
Syntax MASMmode:
INCLUDELIB filename
Ideal mode:
INCLUDELIB II fil en ame II
Remarks filename is the name of the library that you want the
linker to include at link time. If you don't supply an
extension with filename, the linker assumes .LIB.
Use INCLUDELIB when you know that the source file
will always need to use routines in the specified library.
That way you don't have to remember to specify the
library name in the linker commands.
Notice that in Ideal mode, you must surround the file-
name with quotes.
Example INCLUDELIB diskio ;includes DISKIO.LIB
INSTR
Function Returns the position of one string inside another string
Mode MASM51, Ideal
Syntax name INSTR [start,jstringl,string2
Remarks name is assigned a value that is the position of the first
instance of string2 in stringl. The first character in stringl
IRP
Function Repeats a block of statements with string substitution
Mode MASM,Ideal
Syntax IRP parameter,<argl[,arg2] ..• >
statements
ENDM
Remarks The statements within the repeat block are assembled
once for each argument in the list enclosed in angle
brackets. The list may contain as many arguments as
you want. The arguments may be any text, such as
symbols, strings, numbers, and so on. Each time the
block is assembled, the next argument in the list is
substituted for any instance of parameter in the enclosed
statements.
You must always surround the argument list with angle
brackets « », and arguments must be separated by
commas. Use the ENDM directive to end the repeat
block.
You can use IRP both inside and outside of macros.
See also IRPC,REPT
Example IRP reg,<ax,bx,cx,dx>
push reg
ENDM
IRPC
Function Repeats a block of statements with character substitution
Mode MASM,Ideal
Syntax IRPC parameter, string
statements
ENDM
JUMPS
Function Enables stretching of conditional jumps to near or far
addresses
Mode MASM, Ideal
Syntax JUMPS
LABEL
Function Defines a symbol with a specified type
Mode MASM,Ideal
Syntax MASMmode:
name LABEL type
Ideal mode:
LABEL name type
Remarks name is a symbol that you have not previously defined
in the source file. type describes the size of the symbol
and whether it refers to code or data. It can be one of the
following:
• NEAR, FAR, or PROC. PROC is the same as either
NEAR or FAR, depending on the memory set using
the MODEL directive
• BYTE, WORD, DATAPTR, DWORD, FWORD,
PWORD, QWORD, TBYTE, or a structure name
The label will only be accessible from within the current
source file, unless you use the PUBLIC directive to make
it accessible from other source files.
Notice that in Ideal mode, name comes after the LABEL
directive.
Use LABEL to access different-sized items than those in
the data structure; see the example that follows.
See also
Example WORDS LABEL WORD ;access "BYTES" as WORDS
BYTES DB 64 DUP (0)
mov WORDS[2],1 ;write WORD of 1
.LFCOND
Function Shows all statements in conditional blocks in the listing
Mode MASM
Syntax .LFCOND
Remarks .LFCOND enables the listing of false conditional blocks
in assembly listings ..LFCOND is not affected by the IX
option.
See also %CONDS
%LINUM
Function Sets the width of the line-number field in listing file
Mode MASM,Ideal
Syntax %LINUM size
Remarks %LlNUM allows you to set how many columns the line
numbers take up in the listing file. size must be a
constant. If you want to make your listing as narrow as
possible, you can reduce the width of this field. Also, if
your source file contains more than 9,999 lines, you can
increase the width of this field so that the line numbers
are not truncated.
The default width for this field is 4 columns.
Example %LINUM 5 iallows up to line 99999
.LIST
Function Shows source lines in the listing
Mode MASM
Syntax .LIST
See also %LIST
Example .XLIST iturn off listing
INCLUDE MORE. INC
.LIST iturn on listing
LOCAL
Function Defines local variables for macros and procedures
Mode MASM,Ideal
Syntax In macros:
LOCAL symbol [,symbol] .••
In procedures:
LOCAL name:type[:count] [,name:type[:count]] ••• [=symbol]
Remarks LOCAL can be used both inside macro definitions
started with the MACRO directive and within proce-
dures defined with PROC. It behaves slightly differently
depending on where it is used.
LOCALS
Function Enables local symbols
Mode MASM, Ideal
Syntax LOCALS [prefix]
Remarks Local symbols normally start with two at-signs (@@),
which is the default, and are only visible inside blocks
whose boundaries are defined by the PROC/ENDP pair
within a procedure or by nonlocal symbols outside a
procedure. You define a nonlocal symbol using PROC,
LABEL, or the colon operator. If you use the LOCALS
directive, any symbols between pairs of nonlocal
symbols can only be accessed from within tha t block.
This lets you reuse symbol names inside procedures and
other blocks.
%MACS
Function Enables listing of macro expansions
Mode MASM, Ideal
Syntax %MACS
Remarks %MACS reverses the effect of a previous %NOMACS
directive, so that the lines resulting from macro expan-
sions appear in the listing. (Same as .LALL.)
See also .LALL, %NOMACS, .SALL, .XALL
Example %MACS
MyMac 1,2,3 ;expansion appears in listing
MASM51
Function Enables assembly of some MASM 5.1 enhancements
Mode MASM,Ideal
Syntax MASM51
Remarks MASM51 enables the following capabilities that are not
normally available with Turbo Assembler:
• SUBSTR, CATSTR, SIZESTR, and INSTR directives
• Line continuation with backslash (\)
If you also enable Quirks mode with the QUIRKS
directive, these additional features become available:
• Local labels defined with @@ and referred to with @F
and@B
• Redefinition of variables inside PROCs
• Extended model PROCs are all PUBLIC.
See also NOMASM51
Example MASM51
MyStr CATSTR <ABC>,<XYz> ;MYSTR = "ABCXYZ"
Table 3.1: Default Segments and Types for Tiny Memory Model
Directive Name Align Combine Class Group
Table 3.3: Default Segments and Types for Medium Memory Model
Directive Name Align Combine Class Group
Table 3.4: Default Segments and Types for Compact Memory Model
Directive Name Align Combine Class Group
Table 3.5: Default Segments and Types for Large or Huge Memory Model
Directive Name Align Combine Class Group
MODEL
Function Sets the memory model for simplified segmentation
directives
Mode MASM,Ideal
Syntax MODEL
See also .MODEL
MULTERRS
Function Allows multiple errors to be reported on a single source
line
Mode MASM,Ideal
Syntax MULTERRS
Remarks MUL TERRS lets more than one error or warning
message appear for each source line. This is sometimes
helpful in locating the cause of a subtle error or when
the source line contains more than one error.
Note that sometimes additional error messages can be a
"chain reaction" caused by the first error condition;
these "chain" error messages may desist once you
correct the first error.
See also NOMULTERRS
Example MULTERRS
mov ax, [bp+abc iproduces two errors:
i1) Undefined symbol: abc
i2) Need right square bracket
% NEWPAGE
Function Starts a new page in the listing file
Mode MASM, Ideal
Syntax %NEWPAGE
Remarks The source lines appearing after %NEWPAGE will
begin at the start of a new page in the listing file. (Same
as PAGE with no arguments.)
See also PAGE
Example %NEWPAGE
; Appears on flrst line of new page
%NOCONDS
Function Disables the placement of statements in false conditional
blocks in the listing file
Mode MASM,Ideal
Syntax %NOCONDS
Remarks %NOCONDS overrides the listing control. When this
control is in effect, the listing won't show statements
within conditional blocks, even those that evaluate as
%NOCREF
Function Disables cross-reference listing (CREF)
Mode MASM, Ideal
Syntax %NOCREF [symbol, ..• ]
Remarks %NOCREF stops cross-reference information from
being accumulated for symbols encountered from this
point forward in the source file.
If you use %NOCREF alone without specifying any
symbols, cross-referencing is disabled completely. If you
supply one or more symbol names, cross-referencing is
disabled only for those symbols. (Same as .XCREF.)
See also %CREF, .CREF, .XCREF, %CREFALL, %CREFREF,
%CREFUREF
Example %XCREF xyz
rNAL DW 0 i CREF shows rNAL defined here
xyz DB 0 idoesn't appear in CREF
%NOCTLS
Function Disables printing of listing controls
Mode MASM, Ideal
Syntax %NOCTLS
Remarks %NOCTLS reverses the effect of a previous %CTLS
directive, which caused all listing-control directives to
be placed in the listing file. After issuing %NOCTLS, all
subsequent listing-control directives will not appear in
the listing file.
NOEMUL
Function Forces generation of real 80x87 floating-poin t
instructions
Mode MASM, Ideal
Syntax NOEMUL
Remarks NOEMUL sets Turbo Assembler to generate real
floating-point instructions to be executed by an 80x87
coprocessor. You can combine this directive with the
EMUL directive when you wish to genera te real
floating-point instructions in one portion of a file and
emulated instructions in another portion.
NOEMUL is the normal floating-point assembly mode
that's in effect when Turbo Assembler starts to assemble
a file.
See also EMUL
Example NOEMUL ;assemble real FP instructions
finit
EMUL ;back to emulation
%NOINCL
Function Disables listing of include files
Mode MASM, Ideal
Syntax %N01NCL
Remarks %NOINCL stops all subsequent INCLUDE file source
lines from appearing in the listing until a %INCL is
enabled. This is useful if you have a large INCLUDE file
that contains things such as a lot of EQU definitions that
never change.
See also %INCL
NOJUMPS
Function Disables stretching of conditional jumps
Mode MASM,Ideal
Syntax NOJUMPS
Remarks If you use NOJUMPS in conjunction with JUMPS, you
can control where in your source file conditional jumps
should be expanded to reach their destination addresses.
This is the default mode Turbo Assembler uses when it
first starts assembling a file.
See also JUMPS
%NOLIST
Function Disables output to listing file
Mode MASM, Ideal
Syntax %NOLIST
Remarks %NOLIST stops all output to the listing file until a sub-
sequent %LIST turns the listing back on. This directive
overrides all other listing controls. (Same as .XLIST.)
See also %LIST, .UST, .XLIST
Example %NOLIST
add dx,ByteVar inot in listing
NOLOCALS
Function Disables local symbols
Mode MASM,Ideal
Syntax NOLOCALS
Remarks If local symbols are enabled with the LOCALS directive,
any symbol starting with two at-signs (@@) is con-
sidered to be a local symbol. If you use symbols in your
% NOMACS
Function Lists only macro expansions that generate code
Mode MASM, Ideal
Syntax %NOMACS
Remarks %NOMACS prevents the listing source lines that gener-
ate no code from being listed, for example, comments,
EQU and = definitions, SEGMENT and GROUP
directives.
This is the default listing mode for macros that's in effect
when Turbo Assembler first starts assembling a source
file. (Same as .XALL.)
See also .LALL, %MACS,.SALL
NOMASM51
Function Disables assembly of certain MASM 5.1 enhancements
Mode MASM,Ideal
Syntax NOMASM51
Remarks Disables the MASM 5.1 features described under the
MASM51 directive. This is the default mode when
Turbo Assembler first starts assembling your source file.
CATSTR ENDP
NOMULTERRS
Function Allows only a single error to be reported on a source
line.
Mode MASM,Ideal
Syntax NOMULTERRS
Remarks NOMULTERRS only lets one error or warning message
appear for each source line. If a source line contains
multiple errors, Turbo Assembler reports the most-
significant error first. When you correct this error, in
many cases the other error messages disappear as well.
If you prefer to decide for yourself which are the most
important messages, you can use the MULTERRS
directive to see all the messages for each source line.
By default, Turbo Assembler uses this error-reporting
mode when first assembling a source file.
See also MULTERRS
Example NOMULTERRS
mov ax, [bp+abc ;one error:
;1) Undefined symbol: abc
Will produce the single error message:
**Error** MULTERRS.ASM(6) Undefined symbol: ABC
% NOTRUNC
Function Wordwraps too-long fields in listing file
Mode MASM,Ideal
Syntax %NOTRUNC
Remarks The object code field of the listing file has enough room
to show the code emitted for most instructions and data
allocations. You can adjust the width of this field with
the % BIN directive. If a single source line emits more
code than can be displayed on a single line, the rest is
normally truncated and therefore not visible. Use the
%NOTRUNC directive when you wish to see all the
code that was generated.
%NOTRUNC also controls whether the source lines in
the listing file are truncated or will wrap to the next line.
Use the %TEXT directive to set the width of the source
field.
See also %BIN, %TEXT, %TRUNC
Example %NOTRUNC
DQ 4 DUP (1.2,3.4) iwraps to multiple lines
ORG
Function Sets the location counter in the current segment
Mode MASM,Ideal
Syntax ORG expression
Remarks expression must not contain any forward-referenced
symbol names. It can either be a constant or an offset
from a symbol in the current segment or from $, the
curren t location counter.
You can back up the location counter before data or code
that has already been admitted into a segment. You can
use this to go back and fill in table entries whose values
weren't known at the time the table was defined. Be
careful when using this technique-you may acci-
dentally overwrite something you didn't intend to.
The ORG directive can be used to connect a label with a
specific absolute address. The ORG directive can also
set the starting location for .COM files (ORG lOOh).
See also SEGMENT
Example PROG SEGMENT
ORG lOOh ;starting offset for .COM file
P186
Function Enables assembly of 80186 instructions
Mode MASM, Ideal
See also 186, .8086, .286, .286C, .286P, .386, .386C, .386P, P8086,
P286,P286P,P386,P386P
P286
Function Enables assembly of all 80286 instructions
Mode MASM, Ideal
See also .8086, .186, .286, .286C, .286P, .386, .386C, .386P, P8086,
P286N, P286P, P386, P386N, P386P
P286P
Function Enables assembly of privileged 80286 instructions
Mode MASM,Ideal
See also .8086, .186, .286C, .286P, .286, .386, .386C, .386P, P8086,
P286,P286~,P386,P386~,P386P
P287
Function Enables assembly of 80287 coprocessor instructions
Mode MASM, Ideal
See also .8087, .287, .387, P8087, P~087, P387
P386
Function Enables assembly of all 80386 instructions
Mode MASM, Ideal
See also .8086, .186, .286C, .286, .286P, .386C, .386P, .386, P8086,
P286, P286~, P286P, P386~, P386P
P386N
Function Enables assembly of non-privileged 80386 instructions
Mode MASM, Ideal
See also .8086, .186, .286C, .286, .286P, .386C, .386P, .386, P8086,
P286,P286~,P286P,P386,P386P
P387
Function Enables assembly of 80387 coprocessor instructions
Mode MASM, Ideal
See also .8087, .287, .387, 8087, PN087, P287
P8086
Function Enables assembly of 8086 instructions only
Mode MASM,Ideal
See also .186, .286C, .286, .286P, .386C, .386, .386P, .8086, P286,
P286N, P286P, P386, P386N, P386P
P8087
Function Enables assembly of 8087 coprocessor instructions
Mode MASM, Ideal
See also .287, .387, .8087, 8087, PN087, P287, P387
PAGE
Function Sets the listing page height and width, starts new pages
Mode MASM
Syntax PAGE [rows] [,eals]
PAGE +
Remarks rows specifies the number of lines that will appear on
each listing page. The minimum is 10 and the maximum
%PAGESIZE
Function Sets the listing page height and width
Mode MASM, Ideal
Syntax %PAGESIZE [rows] [,eols]
Remarks rows specifies the number of lines that will appear on
each listing page. The minimum is 10 and the maximum
is 255. cols specifies the number of columns wide the
page will be. The minimum width is 59; the maximum is
255.
If you omit either rows or cols, the current setting for that
parameter will remain unchanged. If you only want to
change the number of columns, make sure you precede
the column width with a comma; otherwise, you will
end up changing the number of rows instead.
See also PAGE
Example %PAGESIZE 66,132 ;wide listing, normal height
%PAGESIZE ,BO ;don't change rows, eols = BO
PN087
Function Prevents the assembling of coprocessor instructions
Mode MASM,Ideal
Syntax PN087
Remarks Normally, Borland's Turbo Assembler allows you to
assemble instructions for the 80x87 coprocessor family.
Use PN087 if you want to make sure you don't acci-
dentally use any coprocessor Instructions. Also, use
PN087 if your software doesn't have a floating-point
emulation package, and you know your program may
be run on systems without a numeric coprocessor.
See also .8087, .287, .387, P8087, P287, P387
Example PN087
fadd ithis generates an error
PROC
Function Defines the start of a procedure
Mode MASM,Ideal
Syntax MASMmode:
name PROC [distance] [USES registers,]
[argument [,argument]. •• ] [RETURNS argument [, argument]. •• ]
Ideal mode:
PROC name [distance] [USES registers,]
[argument [,argument] .•• ] [RETURNS argument [, argument] ••. ]
Remarks name is the name of a procedure. The optional distance
can be NEAR or FAR; it defaults to the size of the
default code memory model. If you are not using the
simplified segmentation directives (.MODEL, and so
on), the default size is NEAR. With the tiny, small, and
call ReadLine
PURGE
Function Removes a macro definition
Mode MASM,Ideal
Syntax PURGE macroname [,macroname] .••
Remarks PURGE deletes the macro definition specified by the
macroname argument. You can delete multiple macro
definitions by supplying all their names, separated by
commas.
You may need to use PURGE to restore the original
meaning of an instruction or directive whose behavior
you changed by defining a macro with the same name.
See also MACRO
Example PURGE add
add ax,4 jbehaves as normal ADD now
QUIRKS
Function Enables acceptance of MASM bugs
Mode MASM,Ideal
Syntax QUIRKS
Remarks QUIRKS allows you to assemble a source file that
makes use of one of the true MASM bugs. You should
try to stay away from using this directive, since it merely
perpetuates source code constructs that only work by
chance. Instead, you should really correct the offending
source code so that it does what you really intended.
See the section "Turbo Assembler Quirks Mode" (page
172) in Appendix B for a complete description of this
mode.
See also MASM,IDEAL
Example QUIRKS
BVAL DB 0
rnov BVAL,es ;load register into byte location
RADIX
Function Sets the default radix for integer constants in
expressions
Mode MASM, Ideal
Syntax RADIX
RECORD
Function Defines a record that contains bit fields
Mode MASM, Ideal
Syntax MASMmode:
name RECORD field [,field] •••
Ideal mode:
RECORD name field [, field] .••
Remarks name identifies the record so that you can use this name
later when allocating memory to contain records with
this format. Each field describes a group of bits in the
record and has the following format:
fieldname:width[=expression]
fieldname is the name of a field in the record. If you use
fieldname in an expression, it has the value of the number
REPT
Function Repeats a block of statements
Mode MASM,Ideal
Syntax REPT expression
statements
ENDM
Remarks expression must evaluate to a constant and cannot con-
tain any forward-referenced symbol names.
The statements within the repeat block are assembled as
many times as specified by expression.
REPT can be used both inside and outside of macros.
See also ENDM, IRP, IRPC
.SALL
Function Suppresses the listing of all statements in macro
expansions
Mode MASM
Syntax .SALL
Remarks Use .SALL to cut down the size of your listing file when
you want to see how a macro gets expanded.
See also .LALL, .XALL, %MACS, %NOMACS
Example .SALL
MyMacro 4 ;invoke macro
add ax,si ;this line follows MYMACRO in listing
SEGMENT
Function Defines a segment with full attribute control
Mode MASM,Ideal
Syntax MASMmode:
name SEGMENT [align] [combine] [use] [' class' ]
Ideal mode:
SEGMENT name [align] [combine] [use] ['class']
PROG ENDS
.SFCOND
Function Prevents statements in false conditional blocks from
appearing in the listing file
Mode MASM
Syntax .SFCOND
See also %CONDS, .LFCOND, %NOCONDS, .TFCOND
SIZESTR
Function Returns the number of characters in a string
Mode MASM51, Ideal
Syntax name SIZESTR string
Remarks name is assigned a numeric value that is the number of
characters in a string. A null string <> has a length of
zero.
.STACK
Function Defines the start of the stack segment
Mode MASM
Syntax .STACK [size]
Remarks size is the number of bytes to reserve for the stack. If you
do not supply a size, the .STACK directive reserves 1 Kb
(1024 bytes).
You usually only need to use .STACK if you are writing
a standalone assembler program. If you are writing an
assembler routine that will be called from a high-level
language, that language will normally have set up any
stack that is required.
See also .CODE, .CONST, .DATA, .DATA?, .FARDATA,
.FARDATA?, .MODEL, STACK
Example .STACK 200h iallocate 512 byte stack
STACK
Function Defines the start of the stack segment
Mode MASM,Ideal
See also .CODE, .CONST, .DATA, .DATA?, .FARDATA,
.FARDATA?, .MODEL, .STACK
STRUC
Function Defines a structure
Mode MASM, Ideal
Syntax MASMmode:
name STRUC
fields
[name] ENDS
SUBSTR
Function Defines a new string as a substring of an existing string
Mode MASM51, Ideal
Syntax name SUBSTR string,position[,size]
SUBTTL
Function Sets subtitle in listing file
Mode MASM
Syntax SUBTTL text
Remarks The subtitle appears at the top of each page, after the
name of the source file, and after any title set with the
TITLE directive.
You may place as many SUBTTL directives in your
program as you wish. Each directive changes the sub-
title that will be placed at the top of the next listing page.
See also % SUB TTL
%SUBTTL
Function Sets subtitle in listing file
Mode MASM,Ideal
Syntax %SUBTTL "text"
Remarks The subtitle text appears at the top of each page, after the
name of the source file, and after any title set with the
%SYMS
Function Enables symbol table in listing file
Mode MASM,Ideal
Syntax %SYMS
Remarks Placing %SYMS anywhere in your source file causes the
symbol table to appear at the end of the listing file. (The
symbol table shows all the symbols you defined in your
source file.)
This is the default symbol listing mode used by Turbo
Assembler when it starts assembling a source file.
See also %NOSYMS
Example %SYMS ;symbols now appear in listing file
% TAB SIZE
Function Sets tab column width in the listing file
Mode MASM,Ideal
Syntax %TABSIZE width
Remarks width is the number of columns between tabs in the
listing file. The default tab column width is 8 columns.
See also %PAGE, %PCNT, %BIN, %TEXT
Example %TABSIZE 4 ;small tab columns
.TFCOND
Function Toggles conditional block-listing mode
Mode MASM
Syntax .TFCOND
Remarks Normally, conditional blocks are not listed by Turbo
Assembler, and the first .TFCOND encountered enables
a listing of conditional blocks. If you use the IX
command-line option, conditional blocks start off being
listed, and the first .TFCOND encountered disables
listing them. Each time .TFCOND appears in the source
file, the state of false conditional listing is reversed.
See also %CONDS, .LFCOND, %NOCONDS, .SFCOND
TITLE
Function Sets title in listing file
Mode MASM
Syntax TITLE text
Remarks The title text appears at the top of each page, after the
name of the source file and before any subtitle set with
the SUBTIL directive.
% TITLE
Function Sets title in listing file
Mode MASM,Ideal
Syntax %TITLE "text"
Remarks The title text appears at the top of each page, after the
name of the source file and before any subtitle set with
the %SUBTTL directive. Make sure that you place the
title text between quotes ("").
You may only use the %TITLE directive once in your
program.
See also SUBTTL, % SUB TTL, TITLE
Example %TITLE "I/O Library"
%TRUNC
Function Truncates listing fields that are too long
Mode MASM,Ideal
Syntax %TRUNC
Remarks %TRUNC reverses the effect of a previous %NO-
TRUNC directive. This directive changes the object-code
field and the source-line field so that too-wide fields are
truncated and excess information is lost.
See also %NOTRUNC
Example %TRUNC
DD 1,2,3,4,5 idon't see all fields
UFARDATA
Function Defines the start of an uninitialized far data segment
Mode MASM,Ideal
See also .CODE, .DATA, .FARDATA, .FARDATA?, .MODEL,
.STACK
UNION
Function Defines a union
Mode MASM, Ideal (disabled by QUIRKS)
Syntax MASMmode:
NAME UNION
fields
[name] ENDS
Ideal mode:
UNION NAME
fields
ENDS [name]
USES
Function Indicates register usage for procedures
Mode MASM,Ideal
Syntax USES register [,register] •••
Remarks USES appears within a PROC/ENDP pair and indicates
which registers you want to have pushed at the begin-
ning of the procedure and which ones you want popped
just before the procedure returns.
register can be any register that can be legally PUSHed
or POPped. There is a limit of 8 registers per procedure.
Notice that you separate register names with commas,
not with spaces like you do when specifying the
registers as part of the PROC directive. You can also
specify these registers on the same line as the PROC
directive, but this directive makes your procedure
declaration easier to read and also allows you to put the
USES directive inside a macro that you can define to set
up your procedure entry and exit.
You must use this directive before the first instruction
that actually generates code in your procedure.
Note: USES is only available when used with language
extensions to a .MODEL statement.
See also ARG, LOCALS, PROC
Example MyProe PROC
USES ex,si,di
mov ex,lO
rep movsb
WARN
Function Enables a warning message
Mode MASM, Ideal
Syntax WARN [warnc1ass]
Chapter3,Offecffves 159
.XALL
Function Lists only macro expansions that generate code or data
Mode MASM
See also .LALL, %MACS, %NOMACS, .SALL
.XCREF
Function Disables cross-reference listing (CREF)
Mode MASM
See also %CREF, .CREF, %NOCREF
.XLIST
Function Disables output to listing file
Mode MASM
See also %LIST, .LIST, %NOLIST
A
Turbo Assembler Syntax Summary
This appendix uses a modified Backus-Naur form (BNF) to summarize the
syntax for Turbo Assembler expressions, both in MASM mode and in Ideal
mode.
Note: In the following sections, the ellipses (... ) mean the same element is
repeated as many times as it is found.
Lexical Grammar
valid_line
II white_space valid_line
• punctuation valid_line
II number_string valid_line
• id_string valid_line
II null
white_space
• space_char white_space
• space_char
id_string
• id_char id_strng2
id_strng2
• id_chr2 id_strng2
• null
• $, %, - I ?, alphabetic characters
id_chr2
• id_chars plus numerics
number_string
• num_string
• str_string
num_string
• digits alphanums
• digits ',' digits exp
• digits exp ; Only if MASM mode in aDD, DQ, or DT
digits
• digit digits
• digit
digit
.0 through 9
alpha
• alphabetic characters
exp
• E + digits
• E -digits
.E digits
• null
str_string
iii Quoted string, quote enterable by two quotes in a row
punctuation
I!!I Everything that is not a space_char, id_char, "", 1I1It, or digits
The period (.) character is handled differently in MASM mode and Ideal
mode. This character is not required in floating-point numbers in MASM
mode and also cannot be part of a symbol name in Ideal mode. In MASM
mode, it is sometimes the start of a symbol name and sometimes a punc-
tuation character used as the structure member selector.
Here are the rules for the period (.) character:
a. When it is the first character on the line, or in other special cases like
EXTRN and PUBLIC symbols, it gets attached to the following
symbol if the character that follows it is an id_chr2, as defined in the
previous rules.
mexprl
• 'SHORT' mexprl
• '. TYPE' mexprl
• 'SMALL' mexprl (16-bit offset cast [386 only])
• 'LARGE' mexprl (32-bit offset cast [386 only])
.mexpr2
mexpr2
• mexpr3 'OR' mexpr3 .. .
• mexpr3 'XOR' mexpr3 .. .
• mexpr3
mexpr3
• mexpr4 'AND' mexpr4 ...
• mexpr4
mexpr4
• 'NOT' mexpr4
.mexpr5
mexpr5
• mexpr6 'EQ' mexpr6 .. .
• mexpr6 'NE' mexpr6 .. .
• mexpr6 'LT' mexpr6 .. .
• mexpr6 'LE' mexpr6 .. .
• mexpr6 'GT' mexpr6 .. .
mexpr6
• mexpr7 '+' mexpr7 .. .
iii mexpr7 '-' mexpr 7 .. .
• mexpr7
mexpr7
• mexprB '*' mexprB .. .
• mexprB 'I' mexprB .. .
• mexprB 'MOD'mexprB .. .
• mexprB 'SHR' mexprB .. .
• mexprB 'SHL' mexprB .. .
II mexprB
mexprS
• mexpr9 'PTR' mexprB
• mexpr9
• 'OFFSET' mexprB
• 'SEG' mexprB
• 'TYPE' mexprB
• 'THIS' mexprB
mexpr9
• mexprl0 ';' mexprl0 ...
II mexprl0
mexprl0
• '+' mexprl0
• '-' mexprl0
• mexprll
mexpr12
• mexpr13 mexpr13 '" (Implied addition only if '[' or '(' present)
• mexpr12 mexpr13 ',' mexpr8
mexpr13
• 'LENGTH' id
• 'SIZE' id
• 'WIDTH' id
• 'MASK' id
• '(' mexprl ')'
• '[' mexprl ']'
.id
• const
pointer
• 'SMALL' pointer (16-bit offset cast [386 only])
• 'LARGE' pointer (32-bit offset cast [386 only])
• type 'PTR' pointer
• type 'LOW' pointer (Low caste operation)
• type 'HIGH' pointer (High caste operation)
• type pointer
• pointer2
type
• 'UNKNOWN'
• 'BYTE'
pointer2
• pointer3 ',' id (Structure item operation)
• pointer3
pointer3
• expr ':' pointer3
.expr
expr
• 'SYMTYPE' expr (Symbol type operation)
• expr2
expr2
• expr3 'OR' expr3 '"
I! expr3 'XOR' expr3 '"
.expr3
expr3
• expr4 'AND' expr4 ,,'
.expr4
exprS
• expr6 'EQ' expr6 .. .
• expr6 'NE' expr6 .. .
• expr6 'LT' expr6 .. .
• expr6 'LE' expr6 .. .
• expr6 'GT' expr6 .. .
• expr6 'GE' expr6 .. .
• expr6
expr6
• expr7 '+' expr7 .. .
• expr7 '-' expr7 .. .
• expr7
expr7
• exprB ,*, exprB .. .
• exprB '/' exprB .. .
• exprB 'MOD' exprB .. .
• exprB 'SHR' exprB .. .
II exprB 'SHL' exprB .. .
81 exprB
exprB
• '+' exprB
• '-' exprB
• expr9
expr9
• 'HIGH' expr9
exprl0
• 'OFFSET' pointer
• 'SEG' pointer
• 'SIZE' id
• 'LENGTH' id
• 'WIDTH' id
• 'MASK' id
aid
• const
• '(' pointer ')'
• '[' pointer '] (Always means 'contents-of ')
Compatibility Issues
Turbo Assembler in MASM mode is very compatible with MASM version
4.0, and additionally supports all the extensions provided by MASM
versions 5.0 and 5.1. However, 100% compatibility is an ideal that can only
be approached, since there is no formal specification for the language and
different versions of MASM are not even compatible with each other.
For most programs, you will have no problem using Turbo Assembler as a
direct replacement for MASM version 4.0 or 5.1. Occasionally, Turbo
Assembler will issue a warning or error message where MASM would not,
which usually means that MASM has not detected an erroneous statement.
For example, MASM accepts
abc EQU [BP+2]
PUBLIC abc
and generates a nonsense object file. Turbo Assembler correctly detects this
and many other questionable constructs.
If you are having trouble assembling a program with Turbo Assembler, you
might try using the QUIRKS directive; for example,
TASM IJQUIRKS MYFILE
which may make your program assemble properly. If it does, add QUIRKS
to the top of your source file. Even better, review this appendix and
determine which statement in your source file needs the QUIRKS directive.
Then you can rewrite the line(s) of code so that you don't even have to use
QUIRKS.
If you're using certain features of MASM version 5.1, you'll need MASM51
in your source file. These capabilities are discussed later in this appendix.
QUIRKS
MASM51
c
Turbo Assembler Highlights
Besides its high compatibility with MASM, Turbo Assembler has a number
of enhancements that you can use simultaneously with the typical MASM-
style statements. These enhancements can be used both in Ideal mode and
in MASM mode. (Chapter 12 in the User's Guide provides you with more
details about Ideal mode.)
Here we'll introduce you to each of the enhancements and point you to
where more-detailed discussions of each topic can be found in the manual.
GLOBAL Directive
The GLOBAL directive lets you define variables as a cross between an
EXTRN and a PUBLIC. This means you can put GLOBAL definitions in a
header file that's included in all source modules and then define the data in
just one module. This gives you greater flexibility, since you can initialize
Local Symbols
The LOCALS and NOLOCALS directives control whether symbols that
start with two at-signs (00) are local to a block of code.
For more information on local symbols, refer to the section "Local Labels"
in Chapter 10 of the User's Guide. These two directives are also defined in
Chapter 3 in this book.
Ideal Mode
Turbo Assembler's Ideal mode gives you a new and more rational way to
construct expressions and instruction operands. By learning just a few
simple rules, you can handle complex instruction operands in a better
manner. (See Chapter 12 of the User's Guide for an introduction to the
power of Ideal mode.)
Constant Segments
The Turbo Assembler lets you use a constant value any time that a segment
value should be supplied. You can also add a constant value to a segment.
For example,
jrnp FAR PTR OFFFFh:O ijump into the ROM BIOS
LOWDATA SEGMENT AT 0
ASSUME DS:LOWDATA+40h iDS points to BIOS data area
mov ax,DS:[3FH] iread word from BIOS data area
LOWDATA ENDS
The section entitled ''The SEGMENT Directive" in Chapter 10 of the User's
Guide explains this in more detail.
Alternate Directives
The Turbo Assembler provides alternative keywords for a number of
directives, in particular those that start with a period (.). All alternative
listing control directives start with a percent sign (%), and all alternative
processor control directives start with a P.
Refer to Chapter 3 in this book for a complete list of all the directives that
Turbo Assembler supports.
Predefined Variables
The Turbo Assembler defines a number of variables that have a value you
can access from your source files. These include ??date, ??time, ??filename,
and ??version, in addition to the predefined variables supported for MASM
5.0 compatibility.
Take a look at Chapter I, "Predefined Symbols," of this book for a
definition of these variables.
A Quick Example
Let's start with an example to illustrate MAKE's usefulness. Suppose
you're writing some programs to help you display information about
nearby star systems. You have one program-GETSTARS-that reads in a
text file listing star systems, does some processing on it, then produces a
binary data file with the resulting information in it.
GETSTARS uses certain definitions, stored in STARDEFS.INC, and certain
routines, stored in STARLIB.ASM (and declared in STARLIB.lNC). In
addition, the program GETSTARS itself is broken up into three files:
• GSP ARSE.ASM
• GSCOMP.ASM
• GETSTARS.ASM
The first two files, GSPARSE and GSCOMP, have corresponding include
files (GSPARSE.INC and GSCOMP.INC). The third file, GETSTARS.ASM,
has the main body of the program. Of the three files, only GSCOMP.ASM
and GETSTARS.ASM make use of the STARLIB routines.
Here are the include files needed by each assembler file:
STARLIB.ASM None
GSP ARSE.ASM STARDEFS.INC
GSCOMP.ASM STARDEFS.INC,STARLIB.INC
GETSTARS.ASM STARDEFS.INC,STARLIB.lNC,GSP ARSE.INC,
GSCOMP.INC
Creating a Makefile
A makefile is just a combination of the two lists just given: dependencies
and the commands needed to satisfy them.
For example, let's take the lists given, combine them, massage them a little,
and produce the following:
Using a Makefile
Assuming you've created MAKE FILE like the one we've described
here-and, of course, assuming that the source code files exist-then all
you have to do is type the command
make
Stepping Through
Here's a step-by-step example to help clarify the previous description.
Suppose that GETSTARS.EXE and all the .OBI files exist, and that
GETSTARS.EXE is more recent than any of the .OBI files, and, likewise,
each .OBI file is more recent than any of its dependencies.
If you then en ter the command
make
nothing happens, since there is no need to update anything.
Now, suppose that you modify STARLIB.ASM and STARLIB.INC,
changing, say, the value of some constant. When you enter the command
make
MAKE sees that STARLIB.ASM is more recent than STARLIB.OBI, so it
issues the command
tasm It Iml Is starlib.asm
It then sees that STARLIB.INC is more recent than GSCOMP.OBI, so it
issues the command
Creating Makefiles
A makefile contains the definitions and relationships needed to help MAKE
keep your program(s} up-to-date. You can create as many makefiles as you
want and name them whatever you. want; MAKEFILE is just the default
name that MAKE looks for if you don't specify a makefile when you run
MAKE.
All rules, definitions, and directives end with a new line; if a line is too long
(such as the TLINK command in the previous example), you can continue it
to the next line by placing a backslash (\) as the last character on the line.
Whitespace-blanks and tabs-is used to separate adjacent identifiers (such
as dependencies) and to indent commands within a rule.
Components of a Makefile
Creating a makefile is almost like writing a program with definitions,
commands, and directives. Here's a list of the constructs allowed in a
makefile:
Comments
Comments begin with a sharp (#) character; the rest of the line following
the # is ignored by MAKE. Comments can be placed anywhere and never
have to start in a particular column.
A backslash (\) will not continue a comment onto the next line; instead, you
must use a # on each line. In fact, you cannot use a backslash as a continu-
ation character in a line that has a comment. If it precedes the #, it is no
longer the last character on the line; if it follows the #, then it is part of the
comment itself.
Here are some examples of comments in a makefile:
t makefile for GETSTARS.EXE
t does complete project maintenance
getstars.exe: getstars.obj gscomp.obj gsparse.obj starlib.obj
t can't put a comment at the end of the next line
tlink starlib gsparse gscomp getstars, getstars,\
getstars, lib\math lib\io
t legal comment
t can't put a comment between the next two lines
getstars.obj: getstars.asm stardefs.inc starlib.inc gscomp.inc gsparse.inc
tasm It Iml Is getstars.asm t you can put a comment here
Explicit Rules
You are already familiar with explicit rules, since those are what you used
in the makefile example given earlier. Explicit rules take the form
target [target ••• ]: [source source ••• ]
[command]
[command]
where target is the file to be updated, source is a file upon which target
depends, and command is any valid MS-DOS command (including
invocation of .BAT files and execution of .COM and .EXE files).
Special Considerations
An explicit rule with no command lines following it is treated a little
differently than an explicit rule with command lines .
• If an explicit rule exists for a target with commands, the only files that the
target depends on are the ones listed in the explicit rule.
• If an explicit rule has no commands, the targets depend on the files given
in the explicit rule, and they also depend on any file that matches an
implicit rule for the target{s).
See the following section for a discussion of implicit rules.
Implicit Rules
MAKE allows you to define implicit rules as well. Implicit rules are
generalizations of explicit rules. What do we mean by that?
Here's an example that illustrates the relationship between the two types of
rules. Consider this explicit rule from the previous sample program:
starlib.obj: starlib.asm
tasm It Iml Is starlib.asm
This rule is a common one because it follows a general principle: An .OBJ
file is dependent on the .ASM file with the same file name and is created by
same name that ends in .ASM, and the .OBI file is created using the
command
tasm It Iml Is $<
where $< represents the file's name with the source (.ASM) extension."
(The symbol $< is a special macro and is discussed in the next section.)
The syntax for an implicit rule is
. source_extension. target_extension:
{command}
{command}
where fname is the same for both files. In other words, this implicit rule
replaces all explicit rules having the format
fname.target_extension: fname.source extension
{command}
{command}
Examples
Here are some examples of implicit rules:
.c.obj:
tcc -c $<
.asm.obj:
tasm $* /mx;
In the first implicit rule example, the target files are .OBJ files and their
source files are .C files. This example has one command line in the
command list; command-line syntax is covered later in this section.
The second example directs MAKE to assemble a given file from its .ASM
source file, using TASM with the IMX option.
Command Lists
We've talked about both explicit and implicit rules and how they can have
lists of commands. Let's talk about those commands and your options for
setting them up.
Commands in a command list must be indented-that is, preceded by at
least one blank or tab-and take the form
[ prefix ••• ] command_body
Each command line in a command list consists of an (optional) list of
prefixes, followed by a single command body.
Prefix
The prefixes allowed in a command modify the trea tmen t of these
commands by MAKE. The prefix is either the at (@) symbol or a hyphen (-)
followed immediately by a number.
Command Body
The command body is treated exactly as it would be if it were entered as a
line to COMMAND.COM, with the exception that redirection and pipes are
not supported.
MAKE executes the following built-in commands by invoking a copy of
COMMAND.COM to perform them:
BREAK CD CHDIR CLS COPY
CTTY DATE DEL DIR ERASE
MD MKDIR PATH PROMPT REN
RENAME SET TIME TYPE VER
VERIFY VOL
MAKE searches for any other command name using the MS-DOS search
algorithm:
• The current directory is searched first, followed by each directory in the
path.
Ii In each directory, first a file with the extension .COM is checked, then an
.EXE, and finally a .BAT.
• If a .BAT file is found, a copy of COMMAND.COM is invoked to execute
the batch file.
Obviously, if an extension is supplied in the command line, MAKE searches
only for that extension.
Macros
Often certain commands, file names, or options are used again and again in
your makefile. In the examples at the start of this appendix, all the TASM
commands looked for the source in the current directory. Suppose you
wanted to control which subdirectories the source files came from and
where the output is placed. You could go through and modify each line of
your makefile everytime you change these, or you could define macros to
semi-automate the process.
A macro is a name that represents some string of characters. A macro
definition gives a macro name and the expansion text; thereafter, when
MAKE encounters the macro name, it replaces the name with the
expansion text.
Suppose you define the following macros at the start of your makefile:
SRC = c: \ASM\
OUT = OBJS\
INC = C:\INC\
Now, if the rest of your makefile is
getstars.exe: $(OUT)getstars.obj $(OUT)gsparse \
$ (OUT)gscomp.obj $ (OUT) starlib.obj
tlink $ (OUT)starlib $(OUT)gsparse $(OUT)gscomp $(OUT)getstart, \
$(OUT)getstars, $(OUT)getstars, lib\math lib\io
getstars.obj: $(SRC)getstars.asm $(INC)stardefs.inc \
$(INC)starlib.inc $ (INC)gscomp.inc \
$(INC)gsparse.inc
tasm It Iml Is li$(INC) $(SRC)getstars.asm, $(OUT)getstars.obj
Defining Macros
Macro definitions take the form
macro_name=expansion text
where macro_name is the name of the macro: A string of letters and digits
with no whitespace in it, though you can have whitespace between
macro_name and the equal sign (=). The expansion text is any arbitrary string
containing letters, digits, whites pace, and punctuation; it is ended by
newline.
If macro_name has previously been defined, either by a macro definition in
the makefile or by the -D option on the MAKE command line, the new
definition replaces the old.
Case is significant in macros; that is, the macros named mdl, Mdl, and
MDL are all considered different.
Using Macros
Macros are invoked in your makefile with the format
$ (macro_name)
The parentheses are required for all invocations, even if the macro name is
just one character long, with the exception of three special predefined
Special Considerations
Macros in macros: Macro cannot be invoked on the left (macro_name) side
of a macro definition. They can be used on the right (expansion text) side,
but they are not expanded until the macro being defined is invoked. In
other words, when a macro invocation is expanded, any macros embedded
in its expansion text are also expanded.
Macros in rules: Macro invocations are expanded immediately in rule
lines.
Macros in directives: Macro invocations are expanded immediately in !if
and !elif directives. If the macro being invoked in an !if or !elif directive is
not currently defined, it is expanded to the value 0 (FALSE).
Macros in commands: Macro invocations in commands are expanded
when the command is executed.
Predefined Macros
MAKE comes with several special macros built in: $d, $*, $<, $:, $., and $&.
The first is a defined test macro used in the conditional directives !if and
!elif; the others are file name macros used in explicit and implicit rules. In
addition, the current SET environment strings are automatically loaded as
macros, and the macro _MAKE_ is defined to be 1 (one).
Defined Test Macro ($d) The defined test macro $d expands to 1 if the
given macro name is defined, or to 0 if it is not. The content of the macro's
expansion text does not matter. This special macro is allowed only in!if and
!elif directives.
For example, you could modify the explicit GETSTARS.EXE rule already
given to look like this:
getstars.exe: getstars.obj gscomp.obj gsparse.obj starlib.obj
tlink starlib gsparse gscomp $*, $*, $*, \
lib\emu lib\math lib\io
When the command in this rule is executed, the macro $* is replaced by the
target file name (sans extension), getstars. For implicit rules, this macro is
very useful.
For example, an implicit rule for TASM might look like this:
.asm.obj:
tasm It $*
Full File Name Macro ($<)
The full file name macro ($<) is also used in the commands for an explicit
or implicit rule. In an explicit rule, $< expands to the full target file name
(including extension), like this:
Directives
Turbo Assembler's MAKE allows something that other versions of MAKE
don't: directives similiar to those allowed for assembler itself. You can use
these directives to include other makefiles, to make the rules and com-
mands conditional, to print out error messages, and to "undefine" macros.
Directives in a make file begin with an exclamation point (!) as the first
character of the line, unlike assembler, which uses the sharp character (#).
Here is the complete list of MAKE directives:
File-Inclusion Directive
A file-inclusion directive (!include) specifies a file to be included into the
makefile for interpretation at the point of the directive. It takes this form:
!include II filename II
Conditional Directives
Conditional directives (!if, !elif, !else, and !endif) give a programmer a
measure of flexibility in constructing makefiles. Rilles and macros can be
conditionalized so that a command-line macro definition (using the -D
option) can enable or disable sections of the makefile.
The format of these directives parallels that of the assembler preprocessor:
!if expression
[ lines ]
!endif
!if expression
[ lines ]
!else
Error Directive
The error directive (!error) causes MAKE to stop and print a fatal
diagnostic containing the text after terror. It takes the format
!error any_text
This directive is designed to be included in conditional directives to allow a
user-defined condition. For example, you could insert the following code in
front of the first explicit rule:
! if ! $d (MDL)
f if MDL is not defined
!error MDL not defined
!endif
If you reach this spot without having defined MDL, then MAKE will stop
with this error message:
Fatal makefile 5: Error directive: MDL not defined
Undef Directive
The undefine directive (!undef) causes any definition for the named macro
to be forgotten. If the macro is currently undefined, this directive has no
effect. The syntax follows:
!undef macro name
Using MAKE
You now know a lot about how to write makefiles; now's the time to learn
how to use them with MAKE.
Command-Line Syntax
The simplest way to use MAKE is to type the command
make
at the MS-DOS prompt. MAKE then looks for MAKEFILE; if it can't find it,
it looks for MAKEFILE.MAK; if it can't find that, it halts with an error
message.
Fatals
Don't know how to make XXXXXXXX
This message is issued when MAKE encounters a nonexistent file name in
the build sequence, and no rule exists that would allow the file name to be
built.
Errors
Bad file name format in include statement
Include file names must be surrounded by quotes or angle brackets. The file
name was missing the opening quote or angle bracket.
Bad undef statement syntax
An !undef statement must contain a single identifier and nothing else as
the body of the statement.
Character constant too long
Character constants can be only one or two characters long.
Command arguments too long
The arguments to a command executed by MAKE were more than 127
characters-a limit imposed by MS-DOS.
Command syntax error
This message occurs if
• The first rule line of the makefile contained any leading whitespace.
• An implicit rule did not consist of .ext.ext:.
• An explicit rule did not contain a name before the: character.
• A macro definition did not contain a name before the = character.
Invoking TLINK
You can invoke TLINK at the DOS command line by typing tlink with or
without parameters.
When invoked without parameters, TLINK displays a summary of
parameters and options that looks like this:
Turbo Link Version 2.0 Copyright (c) 1987,1988 Borland International
The syntax is: TLINK objfiles, exefile, mapfile, libfiles
@xxxx indicates use response file xxxx
Options:/m = map file with publics
Ix = no map file at all
Ii = initialize all segments
II = include source line numbers
Is = detailed map of segments
In = no default libraries
Id = warn if duplicate symbols in libraries
Ic = lowercase significant in symbols
13 = enable 32-bit processing
Iv = include full symbolic debug information
Ie = ignore Extended Dictionary
It = create COM file
In TLINK's summary display, the line
The syntax is: TLINK objfiles, exefile, mapfile, libfiles
specifies that you supply file names in the given order, separating the file
types with commas.
For example, if you supply the command line
tlink Ic mainline wd In tx,fin,mfin,lib\comm lib\support
TLINK will interpret it to mean that
• Case is significant during linking (Ie).
FileName Contents
LISTOBJS mainline+
wdt
In tx
LISTLIBS lib\commt
lib \ suppo rt
Length Alignment!
Address (Bytes) Class Segment Name Group Module Combining
For each segment in each module, this map includes the address, length in
bytes, class, segment name, group, module, and ACBP information.
The 11 Option
The II option creates a section in the .MAP file for source code line
numbers. To use it, you must have created the .OBI files by compiling with
the -y (Line numbers ... On) option. If you tell TLINK to create no map at all
(using the Ix option), this option will have no effect.
The Ii Option
The Ii option causes trailing segments to be output into the executable file
even if the segments do not contain data records. Note that this is not
normally necessary.
The In Option
The In option causes the linker to ignore default libraries specified by some
compilers. This option is necessary if the default libraries are in another
directory, because TLINK does not support searching for libraries. You may
want to use this option when linking modules written in another language.
The /d Option
Normally, TLINK will not warn you if a symbol appears in more than one
library file. If the symbol must be included in the program, TLINK will use
the copy of that symbol in the first file mentioned on the command line.
Since this is a commonly used feature, TLINK does not normally warn
about the duplicate symbols. The following hypothetical situation
illustrates how you might want to use this feature.
Suppose you have two libraries: one called SUPPORT.LIB, and a supple-
mental one called DEBUGSUP.LIB. Suppose also that DEBUGSUP.LIB
contains duplicates of some of the routines in SUPPORT.LIB (but the
duplicate routines in DEBUGSUP.LIB include slightly different
functionality, such as debugging versions of the routines). If you include
DEBUGSUP.LIB first in the link command, you will get the debugging
routines and not the routines in SUPPORT.LIB.
If you are not using this feature or are not sure which routines are
duplicated, you may include the Id option. This will force TLINK to list all
symbols duplicated in libraries, even if those symbols are not going to be
used in the program.
The Id option also forces TLINK to warn about symbols that appear both in
an .OB] and a .LIB file. In this case, since the symbol that appears in the first
(left-most) file listed on the command line is the one linked in, the symbol
in the .OB] file is the one that will be used.
The Ie Option
The library files that are shipped with Turbo C all contain an Extended
Dictionary with information that enables TLINK to link faster with those
libraries. This Extended Dictionary can also be added to any other library
file using the IE option with TLIB (see the section on TLIB, beginning on
page 220).
Although linking with libraries that contain an Extended Dictionary is
faster, there are two reasons you might want to use the Ie switch, which
disables the use of the Extended Dictionary:
The It Option
If you compiled your file in the tiny memory model and link it with this
switch toggled on, TLINK will generate a .COM file instead of the usual
.EXE file.
When It is used, the default extension for the executable file is .COM.
Note: .COM files may not exceed 64K in size, may not have any segment-
relative fixups, may not define a stack segment, and must have a starting
address equal to 0:100h. When an extension other than .COM is used for
the executable file (.BIN, for example), the starting address may be either
0:0 or O:l00h.
The Iv Option
The Iv option directs TLINK to include debugging information in the
executable file.
Note: When linking· with the Iv option, TLINK initializes all segments, If
you have a program that runs differently when linked with debug
information, you have an uninitialized variable somewhere.
The 13 Option
The 13 option should be used when one or more of the object modules
linked has been produced by TASM or a compatible asembler, and contains
32-bit code for the 80386 processor. This option increases the memory
requirements of TLINK and slows down linking, so it should be used only
when necessary.
Restrictions
As we said earlier, TLINK is lean and mean; it does not have an excessive
supply of options. Following are the only serious restrictions to TLINK:
• Overlays are not supported.
Error Messages
TLINK has three types of errors: fatal errors, nonfatal errors, and warnings.
a A fatal error causes TLINK to stop immediately; the .EXE and .MAP files
are deleted.
D A nonfatal error does not delete .EXE or .MAP files, but you shouldn't
try to execute the .EXE file.
mWarnings are just that: warnings of conditions that you probably want to
fix. When warnings occur .EXE and .MAP files are still created.
The following generic names and values appear in the error messages listed
in this section. When you get an error message, the appropriate name or
value is substituted.
<sname> symbol name
<mname> module name
<fname> file name
XXXXh a 4-digit hexadecimal number, followed by 'h'
Fatal Errors
When fatal errors happen, TLINK stops and deletes the .EXE and .MAP
files.
Nonfatal Errors
TLINK has only two nonfatal errors. As mentioned, when a nonfatal error
occurs, the .EXE and .MAP files are not deleted. Here are the error
messages:
XXX is unresolved in module YYY
The named symbol is referenced in the given module but is not defined
anywhere in the set of object files and libraries included in the link. Check
the spelling of the symbol for correctness.
Fixup overflow, frame =xxxxh, target =xxxxh,
offset =xxxxh in module XXXXXXX
This indicates an incorrect data or code reference in an object file that
TLINK must fix up at link time. In a fix up, the object file indicates the name
of a memory location being referenced and the name of a segment that the
memory location should be in. The frame value is the segment where the
memory location should be according to the object file. The target value is
the segment where the memory location actually is. The offset field is the
offset within the target segment where the memory location is.
This message is most often caused by a mismatch of memory models. A
near call to a function in a different code segment is the most likely cause.
This error can also result if you generate a near call to a data variable or a
data reference to a function.
To diagnose the problem, generate a map with public symbols (1m). The
value of the target and offset fields in the error message should be the
address of the symbol being referenced. If the target and offset fields do not
match some symbol in the map, look for the symbol nearest to the address
given in the message. The reference is in the named module, so look in the
source file of that module for the offending reference.
If these techniques do not identify the cause of the failure, or if you are
programming in assembly language or some other high-level language
besides Turbo Assembler, there may be other possible causes for this
Warnings
TLINK has only three warnings. The first two deal with duplicate
definitions of symbols; the third, applicable to tiny model programs,
indicates that no stack has been defined. Here are the messages:
Warning: XXX is duplicated in module YYY
The named symbol is defined twice in the named module. This could
happen in Turbo Assembler object files, for example, if two different pascal
names were spelled using different cases in a source file.
Warning: XXX defined in module YYY is duplicated in module ZZZ
The named symbol is defined in each of the named modules. This could
happen if a given object file is named twice in the command line, or if one
of the two copies of the symbol were misspelled.
Warning: no stack
This warning is issued if no stack segment is defined in any of the object
files or in any of the libraries included in the link. This is a normal message
for the tiny memory model in Turbo C, or for any application program that
will be converted to a .COM file. For other programs, this indicates an error.
If a Turbo Assembler program produces this message for any but the tiny
memory model, check the COx start-up object files to be sure they are
correct.
Component Description
TLIB Operations
TLIB recognizes three action symbols (-, +, *), which you can use singly or
combined in pairs for a total of five distinct operations. For operations that
use a pair of characters, the order of the characters is not important. The
action symbols and what they do are listed here:
+ Add TUB adds the named file to the library. If the file has no
extension given, TUB assumes an extension of .OBJ. If
the file is itself a library (with a .LIB extension), then the
operation adds all of the mod ules in the named library to
the target library.
If a module being added already exists, TUB displays a
message and does not add the new module.
Remove TUB removes the named module from the library. If the
module does not exist in the library, TUB displays a
message.
Extract TUB creates the named file by copying the corre-
sponding module from the library to the file. If the
module does not exist, TUB displays a message and does
not create a file. If the named file already exists, it is
overwritten.
-+ Replace TUB replaces the named module with the corre-
+- sponding file. This is just shorthand for a remove
followed by an add operation.
_tfo
Extract & TUB copies the named module to the
-
tfo
Remove corresponding file name and then removes it from the
library. This is just a shorthand for an extract followed by
a remove operation.
A remove operation only needs a module name, but TLIB allows you to
enter a full path name with drive and extension included. However,
everything but the module name is ignored.
It is not possible to rename modules in a library. To rename a module, you
must first extract and remove it, rename the file just created, and, finally,
add it back into the library.
Creating a Library
To create a library, you simply add modules to a library that does not yet
exist.
Examples
Here are some simple examples demonstrating the different things you can
do with TLIB.
Order of Precedence
Remember that each of GREP's options is a switch: Its state reflects the way
you last "flipped" it. At any given time, each option can only be on or off.
Each occurrence of a given option on the command line overrides its
previous definition. For example,
grep -r -i- -d -i -r- main( my*.asm
Given this command line, GREP will run with the -d option on, the -i
option on, and the -r option off.
You can install your preferred default setting for each option in GREP.COM
with the -u option. For example, if you want GREP to always do a verbose
search (-z on), you can install it with the following command:
grep -u -z
Example 2
Command line: grep -r ["a-z]main\ *( *.asm
Matches: main(i:integer)
main(i,j:integer)
if (main ()) halt;
Matches: A:\data.fil
c:\Data.Fil
B:\DATA.FIL
Command-Line Options
OBJXREF command-line options fall into two categories: control options
and report options.
Control Options
Control options modify the default behavior of OBJXREF (the default is
that none of these options are enabled).
II Ignore case differences in public names: Use this option if you use
TLINK without the Ie option (which makes case differences
significant).
IF Include Full library: All object modules in specified .LIB files are
included even if no public names they contain are referenced by an
object module being processed by OBJXREF. This provides
information on the entire contents of a library file. (See example 4 in
the section "OBJXREF Examples.")
N Verbose output: Lists names of files read and displays totals of public
names, modules, segments, and classes.
IZ Include Zero Length Segment Definitions: Object modules may define
a segment without allocating any space in it. Listing these zero length
segment definitions normally makes the module size reports harder to
use but it can be valuable if you are trying to remove all definitions of
a segment.
Report Options
Report options govern what sort of report is generated, and the amount of
detail OBJXREF provides.
Response Files
The command line is limited by DOS to a maximum of 128 characters. If
your list of options and file names will exceed this limit, you must place
your file names in a response file.
A response file is a text file that you make with an text editor. Since you
may already have prepared a list of the files that make up your program for
other Turbo Assembler programs, OBJXREF recognizes several response
file types.
Response files are called from the command line using one of the following
options. The response file name must follow the option without an
intervening space (lLresp not IL resp).
More than one response file can be specified on the command line, and
additional .OBJ and .LIB file names may precede or follow them.
The ID Command
If you want OBJXREF to look for .OBJ files in a directory other than the
current one, include the directory name on the command line, prefixed
with/D:
C:>OBJXREF/Ddirl[;dir2[;dir3]]
or
C:>OBJXREF/Ddirl[/Ddir2] [/Ddir3]
OBJXREF will search each of the directories in the specified order for all
object and library files. If you don't use the ID option, only the current
directory will be searched. However, if you use a ID option, the current
directory will not be searched unless it is included in the directory list. For
example, to first search the BORLAND directory for files and then search
the current directory, you would type
C:>OBJXREF/Dborland;
If multiple search directories are specified, and a file matching the file
specification is found, OBJXREF will include the file as part of the cross-
reference. OBJXREF will only continue to search the other directories for
the same file specification if the file specification contains wildcards.
The 10 Command
The 10 option allows you to specify an output file where OBJXREF will
send any reports generated. It has the following syntax:
The IN Command
You can limit the modules, segments, classes, or public names that
OBJXREF reports on by entering the appropriate name on the command
line, prefixed with the IN command. For example,
OBJXREF <filelist> /RM /NTest
tells OBJXREF to generate a report listing information only for the module
named Test.
•CODE
SAYBYE PROC NEAR ;defines Say Bye
mov dx,OFFSET GOODBYE
mov ah,9
int 21h
ret
SAYBYE ENDP
START PROC NEAR ; defines Start
mov ax,@data
mov ds,ax
call SAYHELLO ;refers to SayHello
i TEST2.ASM
•MODEL small
EXTRN HELLO: BYTE irefers to Hello
PUBLIC GOODBYE imakes Goodbye public
PUBLIC SAY HELLO imakes SayHello public
•DATA
GOODBYE DB 'Goodbye' ,10, 13, , $' idefines Goodbye
•CODE
SAY HELLO PROC NEAR idefines SayHello
mov dx,OFFSET HELLO irefers to Hello
mov ah,9
int 2lh
ret
SAY HELLO ENDP
END
The object modules compiled from them are TEST1.0BJ and TEST2.0BJ.
You can tell OBJXREF what kind of report to generate about these .OBJ files
by entering the file names on the command line, followed by a JR and a
second letter denoting report type.
Note: The examples that follow show only fragments of the output.
GOODBYE TEST2
HELLO TEST!
NOTUSED TEST!
SAYHELLO TEST2
Warnings
WARNING: Unable to open input file rrrr
The input file rrrr could not be located or opened. OBJXREF proceeds to the
next file.
WARNING: Unknown option - 0000
The option name 0000 is not recognized by OBJXREF. OBJXREF ignores the
option.
WARNING: Unresolved symbol nnnn in module mmmm
The public name nnnn referenced in module mmmm is not defined in any of
the .OBJ or .LIB files specified. OBJXREF flags the symbol in any reports it
generates as being referenced but not defined.
WARNING: Invalid file specification ffff
Some part of the file name ffff is invalid. OBJXREF proceeds to the next file.
WARNING: No files matching ffff
The file named ffff listed on the command line or in a response file could
not be located or opened. OBJXREF skips to the next file.
WARNING: Symbol nnnndefined in mmmml duplicated in mmmm2
Public name nnnn is defined in modules mmmml and mmmm2. OBJXREF
ignores the second definition.
R~sponse Files
TCREF also accepts ASCII files as command strings. Simply precede the file
name with an @ sign to include a file in the command string. For example,
TCREF @dofoo
where DOFOO contains
foo1+foo2+foo3,foo
will do the same thing as the previous example.
Switches
TCREF accepts all the switches present in TLINK, but most of them are
discarded. TCREF only uses these switches:
./e makes GLOBAL report case-sensitive.
Output
TCREF takes great care to make semantic sense of symbols. Cross-reference
information is useless when symbols with the same name but different
meanings are lumped together. TCREF therefore takes into account the
SCOPE of a symbol when producing its reports. Cross-reference infor-
mation is always listed for the source file and source line number.
E
Error Messages
This chapter describes all the messages that Turbo Assembler generates.
Messages usually appear on the screen, but you can redirect them to a file
or printer using the standard DOS redirection mechanism of putting the
device or file name on the command line, preceded by the greater than (»
symbol. For example,
TASM MYFILE >ERRORS
Turbo Assembler generates several types" of messages:
IIinformation messages
• warning messages
• error messages
• fatal error messages
Information Messages
Turbo Assembler displays two information messages, one when it starts
assembling your source file(s) and another when it has finished assembling
each file. Here's a sample startup display:
Turbo Assembler Version 1.00 Copyright (C)" 1988 Borland International
Assembling file: TEST.ASM
ENDIF
MYSYM EQU 1
Forward references may not be used in the argument to any of the IFxxx
directives, nor as the count in a DUP expression.
Illegal immediate
Aninstruction has an immediate (constant) operand where one is not
allowed. For example,
mov 4,al
Illegal indexing mode
An instruction has an operand that specifies an illegal combination of
registers. For example,
You must always use left and right parentheses in matching pairs.
Need right square bracket
An expression that references a memory location does not end with a ] to
match the [that started the expression. For example,
mov ax, lsi ierror, no closing ] after SI
You must always follow the period operator with the name of a member in
the structure to its left.
Not expecting group or segment quantity
You have used a group or segment name where it can't be used. For
example,
This usually happens when you type END instead of ENDIF to end a
conditional block.
Open procedure
The end of the source file has been reached as defined with the END
directive, but a procedure block started with the PROC directive has not
been ended with the ENDP directive. For example,
MYFUNC PROC
END ino ENDIF before ENDP
This usually happens when you type END instead of ENDP to end a
procedure block.
Open segment
The end of the source file has been reached as defined with the END
directive, but a segment started with the SEGMENT directive has not been
ended with the ENDS directive. For example,
DATA SEGMENT
END ;no ENDS before END
This usually happens when you type END instead of ENDS to end a
segment.
Since MASM mode does not require the brackets, this is only a warning.
Positive count expected
A DUP expression has a repeat count less than zero. For example,
BUF -1 DUP (?) ;error, count < 0
The count preceding a DUP must always be lor greater.
does not specify a source file to assemble. See Chapter 3 of the User's
Guide for a complete description of the Turbo Assembler command line.
Invalid number after
You have specified a valid command-line switch (option), but have not
supplied a valid numeric argument following the switch. See Chapter 3
of the User's Guide for a discussion of the command-line options.
Maximum macro expansion size exceeded
A macro expanded in to more text than would fit in the macro expansion
area. Since this area is up to 64 Kb long, you will usually only see this
message if you have a macro with a bug in it, causing it to expand in-
definitely.
Out of hash space
The hash space has one entry for each symbol you define in your
program. It starts out allowing 16,384 symbols to be defined, as long as
Turbo Assembler is running with enough free memory. If your program
Index 275
80287 coprocessor # character 189
.287 directive 54, 134 ! character, MAKE utility 200
80387 coprocessor \ character, makefile comments 189
.387 directive 55, 135 _ character, Turbo C and 122
.8086 directive 56 =directive 58
.8087 directive 56 Ideal vs. MASM mode 173
80186 processor .. operator 16
.186 directive 53, 133 I operator 19
80286 processor ? operator 20
.286 directive 53, 133, 134 ! operator, within macros 48
.286C directive 53 & operator, within macros 46
.286P directive 54 % sign
80386 processor directives 52
.386 directive 54, 134 within macros 48
.386C directive 55 @-sign
.386P directive 55, 134, 135 local symbols and 117
arithmetic operations 13 makefile prefix 194
Ideal vs. MASM mode 179 TLINK and 212
8087 coprocessor Iml option, case sensitivity 5
.8087 directive 56, 135
emulating 127 A
.186 directive 53
action symbols (TLIB) 223
.286 directive 53
addition
.287 directive 54
operator 16, 21
.386 directive 54
.387 directive 55 alias values 5
ALIGN directive 58
8086 processor
Ideal vs. MASM mode 174
.8086 directive 56, 135
.ALPHA directive 59
<> (angle brackets) operator
within macros 47 AND operator 21
.286C directive 53 angle brackets, within macros 47
ARG directive 60
.386C directive 55
[ ] operator 21 BYTE type and 61
Turbo Debugger and 60, 139
.286P directive 54
.386P directive 55 arithmetic operations 13
+ (binary) operator 16 Ideal vs. MASM mode 174
- (binary) operator 17 assembling
: (colon) directive 57 conditional 80
: (colon) operator 19 directives 103-109
ENDIF directive 82
local symbols and 117
- (hyphen), makefile prefix 194 error messages 85
() operator 15 EXITM directive %
listing files 114
;; operator, within macros 49
. (period) character MAKE utility and 183-209
ASSUME directive 62
Ideal vs. MASM mode 163
. (period) operator 18
+ (unary) operator 16 B
- (unary) operator 18 BASIC See Turbo Basic
Index 277
.CREF directive 68 DF directive 75
%CREFALL directive 69 Turbo Debugger and 75
%CREFREF directive 69 directives 51-160, See also individual
%CREFUREF directive 70 listings
cross-reference byte storage 72
disabling 126 code segment 64, 65
in listing files 68, 69, 126, 160 comments 66
un referenced symbols 69 communal variables 65
TCREF utility 244-247 conditional assembly SO, 82,
cross-reference utility See TCREF 103-109,114,148,154
utility, See OBJXREF utility conditional jumps 112, 128
CS register coprocessor emulation 81
.CODE directive and 64 cross-reference 68, 69, 126, 160
%CfLS directive 70 current segment 132
@curseg symbol 8 data segment 67, 68, 71-72, 95, 156
data size 77, 78, 79
D disabling symbol table 131
doubleword storage 73
/D option, OBJXREF 237
equate 58, 84
/ d option, TLINK 215
error messages 85-94,130, 132, 159
data
even address 94, 95
allocating 20, 23, 28
expressions 143
size
external symbols 96
DQ directive 77
false conditionals 125, 148
DT directive 78
far data 156
SIZE operator 38
global symbols 100
types
Ideal mode 102
UNKNOWN 43
Ideal vs. MASM mode 180
uninitialized 71
include file listing 127
.DATA? directive 71
include files 109
.DATA directive 71
integer constants 143
@data symbol 8
labels 113
data segment
linking libraries 110
directives 67,68,71-72
listing controls 126
EVENDATA directive 95
listing files 67-70, 74, 109, 114, 115,
uninitialized 156
125, 128, 131, 135-137,138, 142,
data structures See structures
145,148,152-155,160
DATAPTR operator 22
local symbols 117, 128
DATASEG directive 72
local variables 115
@DataSize symbol 9, 121
macro expansion 96, 114, 119, 129,
date 9
160
??date symbol 9
macros 119, 141, 145
DB directive 72
MAKE utility 200
DD directive 73
MASM mode 120, 129,142
Turbo Debugger and 73
memory model 121, 124
debugging 60,73,75,79, 116, 139
module names 125
map files and 213
near data 57
%DEPTH directive 74
pointers 75, 77
Index 279
ERRIFNB directive 93 OF directive 75
ERRIFNDEF directive 93 DP directive 77
.ERRNB directive 93 .FARDATA? directive 98
.ERRNDEF directive 94 FARDATA directive 99
.ERRNZ directive 94 .FARDATA directive 98
!error directive 204 operator 24
error messages 249-274 UFARDATA directive 156
conditional assembly 85 FAR operator 24
directives 85-94, 130, 132, 159 ?FARDATA? directive 98
disabling 132 @fardata? symbol 10
fatal 272 FARDATA directive 99
macros 93 .FARDATA directive 98
MAKE utility 204, 207 @fardata symbol 9,
multiple 124 fatal error messages 272
OBJXREF243 file names 10
symbols 87,91-94 ??filename symbol 10
TUNK217 @FileName symbol 10
warning 250 files
errors, programming See also pitfalls assembly 10
EVEN directive 94 forcing compilation 206
EVENDATA directive 95 including (MAKE) 201
exclamation mark, within macros 48 listing See also listing files
.EXE files, TLINK 211 MAKE utility 183-209
EXITM directive 96 managing (MAKE) 183-209
explicit rules (makefiles) 189 naming, TUB 223
expressions object 220-226
byte size 22 OBJXREF utility 234-244
doubleword size 23 output (OBJXREF) 237
evaluating 48 response 234
far pointer size 25, 36 response (OBJXREF) 236
integer constants 143 searches (GREP) 227-233
operators in 13-45 floating-point
order of evaluation 14 emulation 127
quad word size 36 Ideal vs. MASM mode 179
size of 34 Ideal vs. MASM mode 172
ten-byte size 40 instructions 1
word size 45 suppressing assembly 137
Extended Dictionary 215, 221 forward references
creating 226 FAR operator 24
flag, TUB 222 forward slash operator 19
external symbols See symbols, FWORD operator 25
external
EXTRN directive 96 G
Ideal vs. MASM mode 97
GE operator 25
general-purpose registers See also
F individual listings
far data 9, 10 GLOBAL directive 100
Index 281
.LFCOND directive 114 LOW operator 29
libraries LT operator 30
creating extended dictionaries 226
including 110 M
object module 220-226, 234-244
linking See also TLINK utility
1m option
TLINK213
high-level languages 121
libraries 110
1m option, TLINK 211
MACRO directive 119
Turbo Pasca1121
macros
%LINUM directive 114
conditional assembly 107,108
%LIST directive 115
conditional assembly directives
.L1ST directive 115
106
listing files 115
defining 119
%BIN directive 63
deleting 141
conditional assembly 154
error messages 88, 89, 90, 93
conditional blocks 114
expansion
control directives 67, 70, 126, 138,
directives 129
142, 180
EXITM directive 96
cross-reference information 68 69
126, 160, 244-247 ' , listing files 119, 160
suppressing listing 145
directives 52, 74
IRP directive and 111
disabling 128, 160
IRPC directive and 112
error messages 86
listing 114, 138
false conditionals in 125, 148
local variables 115
fonnat 114, 125, 131, 135, 136, 137,
MAKE utility 196
152-155
operators within 46-49
include files in 109, 127
%MACS directive 119
macro expansion 114, 119, 129
MAKE utility 183-209
suppressing macros 145
aborting 205
titles 152, 154, 155
BUILTINS.MAKE file 205
unreferenced symbols 69
case sensitivity 206
LOCAL directive 115
command-line options 206
Turbo Debugger and 116
creating makefiles 188-204
local symbols 117
directives 200
disabling 128
error messages 207
Ideal vs. MASM mode 118, 178
example 184
local variables 115
forcing compilation 206
LOCALS directive 117
macros 196
logical operations
syntax 204
AND 21
TOUCH utility 206
Ideal vs. MASM mode 174
map files, TLINK 211, 213
NOT 32
MASK operator 30
OR 33
MASM51 directive 120, 171
SHL37
MASM compatibility 171-176
SHR38
80386 processor 179
XOR45
ALIGN directive 174
LOOP instruction
alternate directives 180
Ideal vs. MASM mode 179
Index 283
NOLOCALS directive 128 allocated data 28
%NOMACS directive 129 comments 49
NOMASM51 directive 129 data size 38
NOMULTERRS directive 130 division 19,31
%NOSYMS directive 131 equality 24
NOT operator 32 expression evaluate 48
NOTHING keyword 63 expression size 23,25,34,36,40,45
%NOTOC directive 51 greater than 25, 26
%NOTRUNC directive 131 GREP229
NOWARN directive 132 Ideal vs. MASM mode 21
numeric coprocessor inequality 31
emulating 81, 127 less than 28, 30
suppressing assembly 137 literal text string 47
logical 21, 32, 33, 37,38,45
o macros 46-49
modulus 31
/0 option, OB]XREF 237 multiplication 16
object See object files
offset size 27,39
object files
order of precedence 14, 15
cross referencing 234-244
pointers 34, 37
libraries 220-226
quoted character 48
module name 125
records 44
object mod ules
repeating 23
cross-referencer (OB]XREF)
segment address 36
warnings 244 substitute 46
cross-referencing 244
subtraction 17
OB]XREF244
symbol 40, 41, 42
OB]XREF utility 234-244
options, command line See
TLIB220
command-line options
OB]XREF utility 234-244
OR operator 33
changing directories 237
ORG directive 132
command-line options 235
%OUT directive 133
/D option 237
overlays, TLINK utility 216
error messages 243
examples 238
/N option 238 P
reports 235, 239 P8086 directive 135
syntax 234 P8087 directive 135
OFFSET operator 33 P186 directive 133
offsets P286 directive 133
size operator 27 P287 directive 134
SMALL operator 39 P386 directive 134
operands P387 directive 135
memory 21 P286N directive 134
THIS operator 41 P386N directive 134
operators 13-49, See also individual P286P directive 134
listings P386P directive 135
addition 16, 21 PAGE directive 135
Index 285
types 145 slash, operator 19
alphabetical order 59 SMALL operator 39
ASSUME directive 62 square brackets, operator 21
combine types 146 stack
constant ARG directive 60
Ideal vs. MASM mode 179 STACK directive 149
current 8, 132 stack segment directive 149
data 156 .STACK directive 149
defmingl45 strings
directives 145 concatenating 64
memory model 121, 124 defining 64, 151
OFFSET operator 33 directives 151
simplified 6,8,9, 10 DISPLAY directive 76
end of 84 displaying 76
groups 8, 101 literal 47
Ideal mode 101 position 110
names 62 quoted 48
NOTHING keyword 63 size 148
OFFSET operator 33 STRUC directive 149
ordering 76, 148 Ideal vs. MASM mode 150
override 19 vs. UNION 156
Ideal vs. MASM mode 179 structures
registers See also individual defining 149
listings directive 149
Ideal vs. MASM mode 173 ENDS directive 84
Quirks mode 173 LABEL directive and 113
sequential order 148 nesting 151
size 11 period operator 18
stack 149 SUBsrR directive 120, 151
semicolon, within macros 49 subtraction
.SEQ directive 148 Ideal vs. MASM mode 17
.SFCOND directive 148 operator 17
shifts SUBTTL directive 152
Ideal vs. MASM mode 181 %SUBTTL directive 152
SHL operator 37 symbol tables
SHR operator 38 listing files 153
SHL operator 37 suppressing 131
SHORT operator 37 symbols 5-11
SHR operator 38 aliases 5
sign, changing 18 @code6
signed instructions @CodeSize6
Ideal vs. MASM mode 174 communal 65
simplified segment directives 6, 8, 9, Ideal vs. MASM mode 66
10 multiple 66
memory model 121, 124 OCpu7
size of data See data, size cross-referencing 69
SIZE operator 38 @curseg8
SIZESTR directive 120, 148 @data8
Index 287
U local 115
UDATASEG directive 156 predefined
UFARDATA directive 156 Ideal vs. MASM mode 180
unconditional jumps See jumps, redefining 120
unconditional ??version symbol 11
!undef directive 204 version number (Turbo Assembler)
underscore 11
local symbols and 117
Turbo C and 122 W
UNION directive ISO, 156 WARN directive 159
vs. STRUC 156
warning messages 250
unions
directives 159
directive 156
disabling 132
Ideal vs. MASM mode 178 TLINK217
UNKNOWN operator 43 WIDTH operator 44
USES directive 158 wildcards See DOS wildcards
utilities 183-247
WORD operator 45
GREP 227-233 words
MAKE 183-209 DW directive 79
OBJXREF 234-244
WORD operator 45
TCREF 244-247 @WordSize symbol 11
TUB 220-226
TUNK 210-220
X
V Ix option, TLINK 211
.xALL directive 160
Iv option, TLINK216 .xCREF directive 160
variables
.XLIST directive 160
communal 65 XOR operator 45
global (OBJXREF utility) 234
BORLANO INTERNATIONAL, INC , 1800 GREEN HILLS ROAD, PD BOX 660001 , scans VALLEY, CA 95066-0001 PART# 15MN-ASD02-10 BaR 0852