Contents

Introduction....................................................... ix

Document Conventions.............................................. x

Chapter 1    Tools................................................... 1

Microsoft® CodeView® Debugger..................................... 2

CVPACK......................................................... 3

EXEHDR......................................................... 3

EXP............................................................. 4

HELPMAKE...................................................... 4

H2INC........................................................... 6

IMPLIB.......................................................... 7

LIB............................................................. 7

LINK............................................................ 8

MASM......................................................... 11

ML............................................................ 12

NMAKE........................................................ 14

PWB (Programmer’s WorkBench)................................... 16

PWBRMAKE.................................................... 17

QuickHelp....................................................... 18

RM............................................................ 19

UNDEL......................................................... 20

Chapter 2    Directives............................................... 21

Topical Cross-reference for Directives................................ 22

Directives....................................................... 25

Chapter 3    Symbols and Operators..................................... 39

Topical Cross-reference for Symbols................................. 40

Topical Cross-reference for Operators................................ 41

Predefined Symbols............................................ 43

Operators..................................................... 44

Run-Time Operators............................................ 48

Chapter 4    Processor............................................... 49

Topical Cross-reference for Processor Instructions...................... 50

Interpreting Processor Instructions................................... 53

Flags........................................................ 53

Clock Speeds.................................................. 54

Timings on the 8088 and 8086 Processors........................ 55

Timings on the 80286–80486 Processors......................... 56

Interpreting Encodings............................................. 56

Interpreting 80386/486 Encoding Extensions........................... 59

16-Bit Encoding................................................ 60

32-Bit Encoding................................................ 60

Address-Size Prefix.......................................... 60

Operand-Size Prefix.......................................... 60

Encoding Differences for 32-Bit Operations....................... 60

Scaled Index Base Byte....................................... 61

Instructions...................................................... 64

AAA    ASCII Adjust After Addition.................................. 64

AAD    ASCII Adjust Before Division................................. 64

AAM    ASCII Adjust After Multiply.................................. 65

AAS    ASCII Adjust After Subtraction................................ 65

ADC    Add With Carry............................................ 66

ADD    Add...................................................... 67

AND    Logical AND.............................................. 68

ARPL    Adjust Requested Privilege Level.............................. 69

BOUND    Check Array Bounds..................................... 69

BSF/BSR    Bit Scan............................................... 70

BSWAP    Byte Swap.............................................. 71

BT/BTC/BTR/BTS    Bit Tests....................................... 72

CALL    Call Procedure............................................ 73

CBW    Convert Byte to Word....................................... 74

CDQ    Convert Double to Quad..................................... 75

CLC    Clear Carry Flag............................................ 75

CLD    Clear Direction Flag......................................... 76

CLI    Clear Interrupt Flag.......................................... 76

CLTS    Clear Task Switched Flag................................... 76

CMC    Complement Carry Flag..................................... 77

CMP    Compare Two Operands..................................... 77

CMPS/CMPSB/CMPSW/CMPSD    Compare String..................... 79

CMPXCHG    Compare and Exchange................................ 80

CWD    Convert Word to Double.................................... 80

CWDE    Convert Word to Extended Double........................... 81

DAA    Decimal Adjust After Addition................................. 81

DAS    Decimal Adjust After Subtraction.............................. 82

DEC    Decrement................................................ 82

DIV    Unsigned Divide............................................ 83

ENTER    Make Stack Frame....................................... 84

HLT    Halt...................................................... 84

IDIV    Signed Divide.............................................. 85

IMUL    Signed Multiply............................................ 85

IN    Input from Port.............................................. 87

INC    Increment................................................. 88

INS/INSB/INSW/INSD    Input from Port to String..................... 89

INT    Interrupt.................................................. 89

INTO    Interrupt on Overflow...................................... 90

INVD    Invalidate Data Cache....................................... 91

INVLPG    Invalidate TLB Entry..................................... 91

IRET/IRETD    Interrupt Return..................................... 92

Jcondition    Jump Conditionally..................................... 92

JCXZ/JECXZ    Jump if CX is Zero.................................. 94

JMP    Jump Unconditionally........................................ 94

LAHF    Load Flags into AH Register................................. 96

LAR    Load Access Rights......................................... 96

LDS/LES/LFS/LGS/LSS    Load Far Pointer........................... 97

LEA    Load Effective Address...................................... 98

LEAVE    High Level Procedure Exit.................................. 99

LES/LFS/LGS    Load Far Pointer to Extra Segment..................... 99

LGDT/LIDT/LLDT    Load Descriptor Table........................... 99

LMSW    Load Machine Status Word................................ 100

LOCK    Lock the Bus............................................ 101

LODS/LODSB/LODSW/LODSD    Load Accumulator from String........ 101

LOOP/LOOPW/LOOPD    Loop.................................... 102

LOOPcondition/LOOPconditionW/LOOPconditionD    Loop Conditionally... 102

LSL    Load Segment Limit........................................ 103

LSS    Load Far Pointer to Stack Segment............................ 104

LTR    Load Task Register......................................... 104

MOV    Move Data............................................... 105

MOV    Move to/from Special Registers.............................. 106

MOVS/MOVSB/MOVSW/MOVSD    Move String Data................. 108

MOVSX    Move with Sign-Extend.................................. 108

MOVZX    Move with Zero-Extend.................................. 109

MUL    Unsigned Multiply......................................... 109

NEG    Two’s Complement Negation................................ 110

NOP    No Operation............................................. 111

NOT    One’s Complement Negation................................. 111

OR    Inclusive OR............................................... 112

OUT    Output to Port............................................ 113

OUTS/OUTSB/OUTSW/OUTSD    Output String to Port................ 113

POP    Pop..................................................... 114

POPA/POPAD    Pop All.......................................... 115

POPF/POPFD    Pop Flags........................................ 116

PUSH/PUSHW/PUSHD    Push..................................... 116

PUSHA/PUSHAD    Push All....................................... 117

PUSHF/PUSHFD    Push Flags..................................... 118

RCL/RCR/ROL/ROR    Rotate...................................... 118

REP    Repeat String.............................................. 120

REPcondition    Repeat String Conditionally........................... 122

RET/RETN/RETF    Return from Procedure.......................... 123

ROL/ROR    Rotate.............................................. 124

SAHF    Store AH into Flags....................................... 124

SAL/SAR    Shift................................................ 125

SBB    Subtract with Borrow....................................... 125

SCAS/SCASB/SCASW/SCASD    Scan String Flags.................... 126

SETcondition    Set Conditionally................................... 127

SGDT/SIDT/SLDT    Store Descriptor Table.......................... 128

SHL/SHR/SAL/SAR    Shift........................................ 129

SHLD/SHRD    Double Precision Shift............................... 131

SMSW    Store Machine Status Word................................ 133

STC    Set Carry Flag............................................. 134

STD    Set Direction Flag.......................................... 134

STI    Set Interrupt Flag........................................... 134

STOS/STOSB/STOSW/STOSD    Store String Data.................... 135

STR    Store Task Register........................................ 136

SUB    Subtract.................................................. 136

TEST    Logical Compare......................................... 137

VERR/VERW    Verify Read or Write................................ 138

WAIT    Wait................................................... 139

WBINVD    Write Back and Invalidate Data Cache...................... 140

XADD    Exchange and Add....................................... 140

XCHG    Exchange............................................... 141

XLAT/XLATB    Translate......................................... 141

XOR    Exclusive OR............................................. 142

Chapter 5    Coprocessor............................................ 145

Topical Cross-reference for Coprocessor Instructions................... 146

Interpreting Coprocessor Instructions................................ 148

F2XM1    2X–1................................................. 150

FABS    Absolute Value........................................... 150

FADD/FADDP/FIADD    Add...................................... 151

FBLD    Load BCD............................................... 151

FBSTP    Store BCD and Pop...................................... 151

FCHS    Change Sign............................................. 152

FCLEX/FNCLEX    Clear Exceptions................................ 152

FCOM/FCOMP/FCOMPP/FICOM/FICOMP    Compare................. 152

FCOS    Cosine.................................................. 154

FDECSTP    Decrement Stack Pointer............................... 154

FDISI/FNDISI    Disable Interrupts................................. 154

FDIV/FDIVP/FIDIV    Divide...................................... 155

FDIVR/FDIVRP/FIDIVR    Divide Reversed.......................... 156

FENI/FNENI    Enable Interrupts................................... 156

FFREE    Free Register........................................... 157

FIADD/FISUB/FISUBR/FIMUL/FIDIV/FIDIVR    Integer Arithmetic...... 157

FICOM/FICOMP    Compare Integer................................ 157

FILD    Load Integer............................................. 157

FINCSTP    Increment Stack Pointer................................ 158

FINIT/FNINIT    Initialize Coprocessor.............................. 158

FIST/FISTP    Store Integer....................................... 158

FLD/FILD/FBLD    Load.......................................... 159

FLD1/FLDZ/FLDPI/FLDL2E/FLDL2T/FLDLG2/FLDLN2    Load Constant. 159

FLDCW    Load Control Word..................................... 161

FLDENV/FLDENVW/FLDENVD    Load Environment State............. 161

FMUL/FMULP/FIMUL    Multiply................................... 161

FNinstruction    No-Wait Instructions................................ 162

FNOP    No Operation............................................ 163

FPATAN    Partial Arctangent...................................... 163

FPREM    Partial Remainder....................................... 163

FPREM1    Partial Remainder (IEEE Compatible)....................... 164

FPTAN    Partial Tangent.......................................... 165

FRNDINT    Round to Integer...................................... 165

FRSTOR/FRSTORW/FRSTORD    Restore Saved State................. 166

FSAVE/FSAVEW/FSAVED/FNSAVE/FNSAVEW/FNSAVED   
Save Coprocessor State........................................... 166

FSCALE    Scale................................................. 167

FSETPM    Set Protected Mode.................................... 167

FSIN    Sine.................................................... 168

FSINCOS    Sine and Cosine....................................... 168

FSQRT    Square Root............................................ 169

FST/FSTP/FIST/FISTP/FBSTP    Store.............................. 169

FSTCW/FNSTCW    Store Control Word............................. 170

FSTENV/FSTENVW/FSTENVD/FNSTENV/FNSTENVW/FNSTENVD   
Store Environment State........................................... 170

FSTSW/FNSTSW    Store Status Word.............................. 171

FSUB/FSUBP/FISUB    Subtract.................................... 171

FSUBR/FSUBRP/FISUBR    Subtract Reversed........................ 172

FTST    Test for Zero............................................ 173

FUCOM/FUCOMP/FUCOMPP    Unordered Compare................... 173

FWAIT    Wait.................................................. 174

FXAM    Examine................................................ 175

FXCH    Exchange Registers....................................... 176

FXTRACT    Extract Exponent and Significand........................ 176

FYL2X    Y log2(X).............................................. 176

FYL2XP1    Y log2(X+1).......................................... 177

Chapter 6    Macros................................................ 179

Introduction.................................................... 180

BIOS.INC...................................................... 180

CMACROS.INC, CMACROS.NEW................................. 180

MS-DOS.INC................................................... 183

MACROS.INC.................................................. 184

PROLOGUE.INC................................................ 185

WIN.INC...................................................... 185

Chapter 7    Tables................................................. 187

ASCII Codes.................................................... 188

Key Codes...................................................... 190

MS-DOS Program Segment Prefix (PSP)............................. 192

Color Display Attributes........................................... 193

Hexadecimal-Binary-Decimal Conversion............................. 194