x86 Assembly Language Reference Manual
  Sök endast i den här boken
Ladda ner denna bok i PDF

............................Contents


1. The SunOS Assembler for x86
1
....1.1 References 2

2. Assembler Input
3
....2.1 Source Files in Assembly Language Format 4
.......File Organization 4
.......Statements 5
.......Values and Symbol Types 6
.......Expressions 8
.......Expression Syntax 8
.......Expression Semantics (Absolute vs. Relocatable) 10
.......Machine Instruction Syntax 11
.......Instruction Description 13
....2.2 Pseudo Operations 17
.......General Pseudo Operations 17
.......Symbol Definition Pseudo Operations 22

3. Instruction-Set Mapping
25
....3.1 Introduction 25
.......Notational Conventions 25
.......References 27
....3.2 Segment Register Instructions 27
....... Load Full Pointer (lds, les, lfs, lgs, and lss) 27
.......Pop Stack into Word (pop) 27
.......Push Stack into Word(push) 27
....3.3 I/O Instructions 28
.......Input from Port (in, ins) 28
.......Output from Port (out, outs) 28
....3.4 Flag Instructions 28
.......Load Flags into AH Register (lahf) 28
.......Store AH into Flags (sahf) 28
.......Pop Stack into Flag (popf) 28
.......Push Stack into Flag (pushf) 28
.......Complement Carry Flag (cmc) 28
.......Clear Carry Flag (clc) 29
.......Set Carry Flag (stc) 29
.......Clear Interrupt Flag (cli) 29
.......Set Interrupt Flag (sti) 29
.......Clear Direction Flag (cld) 29
.......Set Direction Flag (std) 29
....3.5 Arithmetic Logical Instructions 29
.......Integer Addition (add) 29
.......Integer Add With Carry (adc) 29
.......Integer Subtraction (sub) 30
.......Integer Subtraction With Borrow (sbb) 30
.......Compare Two Operands (cmp) 30
.......Increment by 1 (inc) 30
.......Decrease by 1 (dec) 30
.......Logical Comparison or Test (test) 30
.......Shift (sal, shl, sar, shr) 30
.......Double Precision Shift Left (shld) 31
.......Double Precision Shift Right (shrd) 31
.......One's Complement Negation (not) 31
.......Two's Complement Negation (neg) 31
.......Check Array Index Against Bounds (bound) 31
.......Logical And (and) 31
.......Logical Inclusive OR (or) 31
.......Logical Exclusion OR (xor) 32
....3.6 Multiply and Divide Instructions 32
.......Signed Multiply (imul) 32
.......Unsigned Multiplication of AL, AX or EAX(mul) 32
.......Unsigned Divide (div) 32
.......Signed Divide (idiv) 32
....3.7 Conversion Instructions 33
.......Convert Byte to Word (cbtw) 33
....... Convert Word to Long (cwtl) 33
.......Convert Signed Word to Signed Double Word (cwtd). 33
.......Convert Signed Long to Signed Double Long (cltd) 33
....3.8 Decimal Arithmetic Instructions 33
.......Decimal Adjust AL after Addition (daa) 33
.......Decimal Adjust AL after Subtraction (das) 33
.......ASCII Adjust after Addition (aaa) 33
.......ASCII Adjust after Subtraction (aas) 33
.......ASCII Adjust AX after Multiply (aam) 34
.......ASCII Adjust AX before Division (aad) 34
....3.9 Coprocessor Instructions 34
.......Wait (wait, fwait) 34
...3.10 String Instructions 34
.......Move Data from String to String (movs, smov) 34
.......Compare String Operands (cmps, scmp) 34
.......Store String Data (stos, ssto) 34
.......The Load String Operand (lods, slod) 34
.......Compare String Data (scas, ssca) 35
.......Look-Up Translation Table (xlat) 35
.......Repeat Following String Operation (rep, repnz, repz) 35
...3.11 Procedure Call and Return Instructions 35
.......Call Procedure (call) 35
.......Return from Procedure (ret) 35
.......Long Return (lret) 35
.......Enter or Make a Stack Frame for Procedure Parameters (en-
......ter) 35
.......High Level Procedure Exit (leave) 36
...3.12 Jump Instructions 36
.......Jump if ECX is Zero (jcxz) 36
.......Loop Control with CX Counter (loop, loopnz, loopz) . 36
.......Jump (jmp, ljmp) 36
...3.13 Interrupt Instructions 36
.......Call to Interrupt Procedure (int, into) 36
.......Interrupt Return (iret) 36
...3.14 Protection Model Instructions 37
.......Store Local Descriptor Table Register (sldt) 37
.......Store Task Register (str) 37
.......Load Local Descriptor Table Register (lldt) 37
.......Load Task Register (ltr) 37
.......Verify a Segment for Reading or Writing (verr, verw). 37
.......Store Global/Interrupt Descriptor Table Register (sgdt,
......sidt) 37
.......Load Global/Interrupt Descriptor Table (lgdt, lidt) 37
.......Store Machine Status Word (smsw) 37
.......Load Machine Status Word (lmsw) 38
.......Load Access Rights (lar) 38
.......Load Segment Limit (lsl) 38
.......Clear Task-Switched (clts) 38
.......Adjust RPL Field of Selector (arpl) 38
...3.15 Bit Instructions 38
.......Bit Scan Forward 38
.......Bit Scan Reverse 38
.......Bit Test 38
.......Bit Test And Complement 38
.......Bit Test And Reset 39
.......Bit Test And Set 39
...3.16 Exchange Instructions 39
.......Compare and Exchange [486] 39
...3.17 Floating Point Transcendental 39
.......Floating Point Sine 39
.......Floating Point Cosine 39
.......Floating Point Sine and Cosine 39
...3.18 Floating Point Constant 39
.......Floating Point Load One 39
...3.19 Processor Control Floating Point 40
.......Floating Point Load Control Word 40
.......Floating Point Load Environment 40
...3.20 Other Floating Point 40
.......Floating Point Different Reminder 40
...3.21 Floating Point Comparison 40
.......Floating Point Unsigned Compare 40
.......Floating Point Unsigned Compare And Pop 40
.......Floating Point Unsigned Compare And Pop Two 40
...3.22 Load and Move Instructions 41
.......Load Effective Address 41
.......Move 41
.......Move Segment Registers 41
.......Move Control Registers 41
.......Move Debug Registers 41
.......Move Test Registers 41
.......Move With Sign Extend 41
.......Move With Zero Extend 42
...3.23 Pop Instructions 42
.......Pop All General Registers 42
...3.24 Push Instructions 42
.......Push All General Registers 42
...3.25 Rotate Instructions 42
.......Rotate With Carry Left 42
.......Rotate With Carry Right 42
.......Rotate Left 42
.......Rotate Right 42
...3.26 Byte Instructions 43
.......Byte Set On Condition 43
.......Byte Swap [486] 43
...3.27 Exchange Instructions 43
.......Exchange And Add [486] 43
.......Exchange Register / Memory With Register 43
...3.28 Miscellaneous Instructions 43
.......Write Back and Invalidate Cache [486 only] 43
.......Invalidate [486 only] 43
.......Invalidate Page [486 only] 43
.......LOCK Prefix (lock) 44
.......No Operation (nop) 44
.......Halt (hlt) 44
...3.29 Real Transfers 44
.......Load real 44
.......Store real 44
.......Store real and pop 44
.......Exchange registers 44
...3.30 Integer Transfers 45
.......Integer load 45
.......Integer store 45
.......Integer store and pop 45
...3.31 Packed Decimal Transfers 45
.......Packed decimal (BCD) load 45
.......Packed decimal (BCD) store and pop 45
...3.32 Additions 45
.......Real add 45
.......Real add and pop 45
.......Integer add 45
...3.33 Subtractions 46
.......Subtract real and pop 46
.......Subtract real 46
.......Subtract real reversed 46
.......Subtract real reversed and pop 46
.......Integer subtract 46
.......Integer subtract reverse 46
...3.34 Multiplications 46
.......Multiply real 46
.......Multiply real and pop 46
.......Integer multiply 47
...3.35 Divisions 47
.......Divide real 47
.......Divide real and pop 47
.......Divide real reversed 47
.......Divide real reversed and pop 47
.......Integer divide 47
.......Integer divide reversed 47
...3.36 Floating Point Opcode Errors 47
...3.37 Other Arithmetic Operations 48
.......Square root 48
.......Scale 48
.......Partial remainder 48
.......Round to integer 48
.......Extract exponent and significand 49
.......Absolute value 49
.......Change sign 49
...3.38 Comparison Instructions 49
.......Compare real 49
.......Compare real and pop 49
.......Compare real and pop twice 49
.......Integer compare 49
.......Integer compare and pop 49
.......Test 49
.......Examine 50
...3.39 Transcendental Instructions 50
.......Partial tangent 50
.......Partial arctangent 50
........x 2 - 1 50
.......Y * log2 X 50
.......Y * log2 (X+1) 50
...3.40 Constant Instructions 50
.......Load log E 50 2
.......Load log 10 50 2
.......Load log 2 51 10
.......Load log 2 51 e
.......Load pi 51
.......Load + 0 51
...3.41 Processor Control Instructions 51
........Initialize processor 51
........No operation 51
........Save state 51
........Store control word 51
........Store environment 51
........Store status word 52
........Restore state 52
........Set protected mode 52
........CPU wait 52
........Clear exceptions 52
........Decrement stack pointer 52
........Free registers 52
........Increment stack pointer 52

4. Assembler Output
53
....4.1 Introduction to Assembler Output 53
....4.2 Object Files in Extensible and Linking Format (ELF) 54
........ELF Header 55
........Section Header 56
........Sections 61
........Relocation Tables 63
........Symbol Tables 64
........String Tables 66

A. Using the Assembler Command Line
67
....A.1 Assembler Command Line 67
...A.2 Assembler Command Line Options 68
...A.3 Disassembling Object Code 69

Index..........................................................................................
71