The assembly language described in this manual offers full direct access to the x86 instruction set. The assembler may also be used in connection with SunOS.

22 KB – 204 Pages

PAGE – 2 ============
PleaseRecycleÓ 1995 Sun Microsystems, Inc. 2550 Garcia Avenue, Mountain View, California 94043-1100 U.S.A. All rights reserved. This product or document is protected by copyright and distributed under licenses restricting its use, copying, distribution and decompilation. No part of this product or document may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. Portions of this product may be derived from the UNIX ¨ system, licensed from UNIX Systems Laboratories, Inc., a wholly owned subsidiary of Novell, Inc., and from the Berkeley 4.3 BSD system, licensed from the University of California. Third-party software, including font technology in this product, is protected by copyright and licensed from SunÕs Suppliers. RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR 52.227-19. The product described in this manual may be protected by one or more U.S. patents, foreign patents, or pending applications. TRADEMARKSSun, Sun Microsystems, the Sun logo, SunSoft, the SunSoft logo, Solaris, SunOS, OpenWindows, DeskSet, ONC, ONC+, and NFS are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. UNIX is a registere dtrademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd. OPEN LOOK is a registered trademark of Novell, Inc. PostScript and Display PostScript are trademarks of Adobe Systems, Inc. All SPARC trademarks are trademarks or registered trademarks of SPARC International, Inc. in the United States and other countries. SPARCcenter, SPARCcluster, SPARCompiler, SPARCdesign, SPARC811, SPARCengine, SPARCprinter, SPARCserver, SPARCstation, SPARCstorage, SPARCworks, microSPARC, microSPARC-II, and UltraSPARCare licensed exclusively to Sun Microsystems, Inc. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc. The OPEN LOOK¨ and Sunª Graphical User Interfaces were developed by Sun Microsystems, Inc. for its users and licensees. Sun acknowledges the pioneering efforts of Xerox in researching and developing the concept of visual or graphical user interfaces for the computer industry. Sun holds a non-exclusive license from Xerox to the Xerox Graphical User Interface, which license also covers SunÕs licensees who implement OPEN LOOK GUIÕs and otherwise comply with SunÕs written license agreements. X Window System is a trademark of X Consortium, Inc. THIS PUBLICATION IS PROVIDED ÒAS ISÓ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN, THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION. SUN MICROSYSTEMS, INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAMS(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME.

PAGE – 3 ============
iiiContentsPreface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvii 1.Assembler Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Source Files in Assembly Language Format. . . . . . . . . . . . . . . .2 File Organization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Values and Symbol Types. . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 Expression Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 Expression Semantics (Absolute vs. Relocatable) . . . . . . . .9 Machine Instruction Syntax . . . . . . . . . . . . . . . . . . . . . . . . . .10 Instruction Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12 Pseudo Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 General Pseudo Operations . . . . . . . . . . . . . . . . . . . . . . . . . .14 Symbol DeÞnition Pseudo Operations . . . . . . . . . . . . . . . . .19

PAGE – 4 ============
ivx86 Assembly Language Reference ManualÑNovember 1995 2.Instruction-Set Mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Notational Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26 Segment Register Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . .26 Load Full Pointer (lds,les, lfs, lgs, and lss) . . . . . . . . . . . . .26 Pop Stack into Word (pop). . . . . . . . . . . . . . . . . . . . . . . . . . .27 Push Word/Long onto Stack ( push). . . . . . . . . . . . . . . . . . .28 I/O Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Input from Port (in, ins) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Output from Port (out, outs) . . . . . . . . . . . . . . . . . . . . . . . . .31 Flag Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Load Flags into AH Register (lahf) . . . . . . . . . . . . . . . . . . . .32 Store AH into Flags (sahf). . . . . . . . . . . . . . . . . . . . . . . . . . . .33 Pop Stack into Flag (popf). . . . . . . . . . . . . . . . . . . . . . . . . . .33 Push Flag Register Onto Stack (pushf) . . . . . . . . . . . . . . . .34 Complement Carry Flag (cmc). . . . . . . . . . . . . . . . . . . . . . . .35 Clear Carry Flag (clc). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 Set Carry Flag (stc). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 Clear Interrupt Flag (cli). . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 Set Interrupt Flag (sti). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 Clear Direction Flag (cld) . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 Set Direction Flag (std) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 Arithmetic Logical Instructions . . . . . . . . . . . . . . . . . . . . . . . . . .38

PAGE – 5 ============
ContentsvInteger Addition (add) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 Integer Add With Carry (adc) . . . . . . . . . . . . . . . . . . . . . . . .39 Integer Subtraction (sub) . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 Integer Subtraction With Borrow (sbb) . . . . . . . . . . . . . . . .41 Compare Two Operands (cmp) . . . . . . . . . . . . . . . . . . . . . . .42 Increment by 1 (inc). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 Decrease by 1 (dec) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44 Logical Comparison or Test (test) . . . . . . . . . . . . . . . . . . . . .45 Shift (sal, shl, sar, shr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 Double Precision Shift Left (shld) . . . . . . . . . . . . . . . . . . . . .48 Double Precision Shift Right (shrd). . . . . . . . . . . . . . . . . . . .49 OneÕs Complement Negation (not) . . . . . . . . . . . . . . . . . . . .50 TwoÕs Complement Negation (neg). . . . . . . . . . . . . . . . . . . .50 Check Array Index Against Bounds (bound). . . . . . . . . . . .51 Logical And (and) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52 Logical Inclusive OR (or) . . . . . . . . . . . . . . . . . . . . . . . . . . . .54 Logical Exclusive OR (xor). . . . . . . . . . . . . . . . . . . . . . . . . . .55 Multiply and Divide Instructions . . . . . . . . . . . . . . . . . . . . . . . .56 Signed Multiply (imul) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57 Unsigned Multiplication of AL, AX or EAX(mul) . . . . . . .58 Unsigned Divide (div). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 Signed Divide (idiv) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61 Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 Convert Byte to Word (cbtw) . . . . . . . . . . . . . . . . . . . . . . . . .62

PAGE – 6 ============
vix86 Assembly Language Reference ManualÑNovember 1995 Convert Word to Long (cwtl). . . . . . . . . . . . . . . . . . . . . . . . .63 Convert Signed Word to Signed Double Word (cwtd) . . . .63 Convert Signed Long to Signed Double Long (cltd). . . . . .64 Decimal Arithmetic Instructions . . . . . . . . . . . . . . . . . . . . . . . . .64 Decimal Adjust AL after Addition (daa) . . . . . . . . . . . . . . .64 Decimal Adjust AL after Subtraction (das). . . . . . . . . . . . . .65 ASCII Adjust after Addition (aaa). . . . . . . . . . . . . . . . . . . . .65 ASCII Adjust after Subtraction (aas). . . . . . . . . . . . . . . . . . .66 ASCII Adjust AX after Multiply (aam). . . . . . . . . . . . . . . . .67 ASCII Adjust AX before Division (aad) . . . . . . . . . . . . . . . .68 Coprocessor Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 Wait (wait, fwait). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 String Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 Move Data from String to String (movs). . . . . . . . . . . . . . . .70 Compare String Operands (cmps). . . . . . . . . . . . . . . . . . . . .71 Store String Data (stos) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 The Load String Operand (lods) . . . . . . . . . . . . . . . . . . . . . .73 Compare String Data (scas) . . . . . . . . . . . . . . . . . . . . . . . . . .75 Look-Up Translation Table (xlat). . . . . . . . . . . . . . . . . . . . . .76 Repeat String Operation (rep, repnz, repz) . . . . . . . . . . . . .77 Procedure Call and Return Instructions . . . . . . . . . . . . . . . . . . .78 Far Call Ñ Procedure Call (lcall). . . . . . . . . . . . . . . . . . . . . .78 Near Call Ñ Procedure Call (call) . . . . . . . . . . . . . . . . . . . . .79 Return from Procedure (ret). . . . . . . . . . . . . . . . . . . . . . . . . .80

PAGE – 8 ============
viiix86 Assembly Language Reference ManualÑNovember 1995 Bit Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 Bit Scan Forward (bsf). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 Bit Scan Reverse (bsr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 Bit Test (bt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101 Bit Test And Complement (btc) . . . . . . . . . . . . . . . . . . . . . . .102 Bit Test And Reset (btr). . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Bit Test And Set (bts). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103 Exchange Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103 Compare and Exchange (cmpxchg)[486] . . . . . . . . . . . . . . .103 Floating-Point Transcendental Instructions . . . . . . . . . . . . . . . .104 Floating-Point Sine (fsin) . . . . . . . . . . . . . . . . . . . . . . . . . . . .104 Floating-Point Cosine (fcos). . . . . . . . . . . . . . . . . . . . . . . . . .104 Floating-Point Sine and Cosine (fsincos) . . . . . . . . . . . . . . .104 Floating-Point Constant Instructions. . . . . . . . . . . . . . . . . . . . . .105 Floating-Point Load One (ßd) . . . . . . . . . . . . . . . . . . . . . . . .105 Processor Control Floating-Point Instructions. . . . . . . . . . . . . .105 Floating-Point Load Control Word (ßdcw). . . . . . . . . . . . . .105 Floating-Point Load Environment (ßdenv) . . . . . . . . . . . . .106 Miscellaneous Floating-Point Instructions. . . . . . . . . . . . . . . . .106 Floating-Point Different Reminder (fprem) . . . . . . . . . . . . .106 Floating-Point Comparison Instructions. . . . . . . . . . . . . . . . . . .106 Floating-Point Unsigned Compare (fucom). . . . . . . . . . . . .106 Floating-Point Unsigned Compare And Pop (fucomp) . . .107 Floating-Point Unsigned Compare And Pop Two (fucompp)107

PAGE – 9 ============
ContentsixLoad and Move Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . .108 Load Effective Address (lea). . . . . . . . . . . . . . . . . . . . . . . . . .108 Move (mov) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109 Move Segment Registers (movw) . . . . . . . . . . . . . . . . . . . . .109 Move Control Registers (mov). . . . . . . . . . . . . . . . . . . . . . . .110 Move Debug Registers (mov). . . . . . . . . . . . . . . . . . . . . . . . .111 Move Test Registers (mov) . . . . . . . . . . . . . . . . . . . . . . . . . . .111 Move With Sign Extend (movs x). . . . . . . . . . . . . . . . . . . . . .112 Move With Zero Extend (movzb) . . . . . . . . . . . . . . . . . . . . .112 Pop Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 Pop All General Registers (popa) . . . . . . . . . . . . . . . . . . . . .113 Push Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114 Push All General Registers (pusha). . . . . . . . . . . . . . . . . . . .114 Rotate Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114 Rotate With Carry Left (rcl) . . . . . . . . . . . . . . . . . . . . . . . . . .114 Rotate With Carry Right (rcr). . . . . . . . . . . . . . . . . . . . . . . . .115 Rotate Left (rol) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116 Rotate Right (ror). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117 Byte Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 Byte Set On Condition (setcc). . . . . . . . . . . . . . . . . . . . . . . . .118 Byte Swap (bswap) [486]. . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 Exchange Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 Exchange And Add (xadd) [486] . . . . . . . . . . . . . . . . . . . . . .120 Exchange Register / Memory With Register (xchg) . . . . . .120

PAGE – 10 ============
xx86 Assembly Language Reference ManualÑNovember 1995 Miscellaneous Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121 Write Back and Invalidate Cache (wbinvd) [486 only] . . . .121 Invalidate (invd) [486 only]. . . . . . . . . . . . . . . . . . . . . . . . . .122 Invalidate Page (invlpg) [486 only]. . . . . . . . . . . . . . . . . . . .122 LOCK PreÞx (lock). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 No Operation (nop). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123 Halt (hlt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124 Real Transfer Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125 Load Real (ßd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125 Store Real (fst) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125 Store Real and Pop (fstp) . . . . . . . . . . . . . . . . . . . . . . . . . . . .126 Exchange Registers (fxch). . . . . . . . . . . . . . . . . . . . . . . . . . . .126 Integer Transfer Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 Integer Load (Þld) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 Integer Store (Þst) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 Integer Store and Pop (Þstp). . . . . . . . . . . . . . . . . . . . . . . . . .127 Packed Decimal Transfer Instructions. . . . . . . . . . . . . . . . . . . . .128 Packed Decimal (BCD) Load (fbld). . . . . . . . . . . . . . . . . . . .128 Packed Decimal (BCD) Store and Pop (fbstp) . . . . . . . . . . .128 Addition Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 Real Add (fadd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 Real Add and Pop (faddp) . . . . . . . . . . . . . . . . . . . . . . . . . . .129 Integer Add (Þadd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 Subtraction Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130

PAGE – 11 ============
ContentsxiSubtract Real and Pop (fsub) . . . . . . . . . . . . . . . . . . . . . . . . .130 Subtract Real (fsubp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130 Subtract Real Reversed (fsubr). . . . . . . . . . . . . . . . . . . . . . . .130 Subtract Real Reversed and Pop (fsubrp). . . . . . . . . . . . . . .131 Integer Subtract (Þsubrp) . . . . . . . . . . . . . . . . . . . . . . . . . . . .131 Integer Subtract Reverse (Þsubr). . . . . . . . . . . . . . . . . . . . . .131 Multiplication Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132 Multiply Real (fmul) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132 Multiply Real and Pop (fmulp) . . . . . . . . . . . . . . . . . . . . . . .132 Integer Multiply (Þmul) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132 Division Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133 Divide Real (fdiv). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133 Divide Real and Pop (fdivp). . . . . . . . . . . . . . . . . . . . . . . . . .133 Divide Real Reversed (fdivr) . . . . . . . . . . . . . . . . . . . . . . . . .133 Divide Real Reversed and Pop (fdivrp) . . . . . . . . . . . . . . . .134 Integer Divide (Þdiv). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 Integer Divide Reversed (fidivr) . . . . . . . . . . . . . . . . . . . .134 Miscellaneous Arithmetic Operations. . . . . . . . . . . . . . . . . . . . .136 Square Root (fsqrt). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 Scale (fscale). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 Partial Remainder (fprem) . . . . . . . . . . . . . . . . . . . . . . . . . . .136 Round to Integer (frndint) . . . . . . . . . . . . . . . . . . . . . . . . . . .137 Extract Exponent and SigniÞcand (fxtract). . . . . . . . . . . . . .137 Absolute Value (fabs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137

22 KB – 204 Pages