x86-64 Complete Documentation
Instructions
Integer data move instructions
mov Move
MOV copies the contents of its source (second) operand into its
destination (first) operand.
In all forms of the MOV instruction, the two operands are the
same size, except for moving between a segment register and an
r/m32 operand. These instructions are treated exactly like the
corresponding 16-bit equivalent (so that, for example, \c{MOV
DS,EAX} functions identically to MOV DS,AX but saves a prefix
when in 32-bit mode), except that when a segment register is moved
into a 32-bit destination, the top two bytes of the result are
undefined.
MOV may not use CS as a destination.
CR4 is only a supported register on the Pentium and above.
Test registers are supported on 386/486 processors and on some non-Intel Pentium class processors.
Moves a full 64 bit immediate into a register. mov takes immediates up to 32 bits and sign extends them, which silently turns a large address into the wrong number, so NASM accepts movabs as the spelling that means "the whole 64 bits are here". It assembles to a 10 byte instruction, against 5 to 7 for the mov forms.
Load effective address
lea Load Effective Address
LEA, despite its syntax, does not access memory. It calculates
the effective address specified by its second operand as if it were
going to load or store data from it, but instead it stores the
calculated address into the register specified by its first operand.
This can be used to perform quite complex calculations (e.g. \c{LEA
EAX,[EBX+ECX*4+100]}) in one instruction.
LEA, despite being a purely arithmetic instruction which
accesses no memory, still requires square brackets around its second
operand, as if it were a memory reference.
The size of the calculation is the current address size, and the size that the result is stored as is the current operand size. If the address and operand size are not the same, then if the addressing mode was 32-bits, the low 16-bits are stored, and if the address was 16-bits, it is zero-extended to 32-bits before storing.
The basic 8 arithmetic operations
adc Add with Carry
ADC performs integer addition: it adds its two operands
together, plus the value of the carry flag, and leaves the result in
its destination (first) operand. The destination operand can be a
register or a memory location. The source operand can be a register,
a memory location or an immediate value.
The flags are set according to the result of the operation: in
particular, the carry flag is affected and can be used by a
subsequent ADC instruction.
In the forms with an 8-bit immediate second operand and a longer
first operand, the second operand is considered to be signed, and is
sign-extended to the length of the first operand. In these cases,
the BYTE qualifier is necessary to force NASM to generate this
form of the instruction.
To add two numbers without also adding the contents of the carry
flag, use ADD (ADD).
add Add
ADD performs integer addition: it adds its two operands
together, and leaves the result in its destination (first) operand.
The destination operand can be a register or a memory location.
The source operand can be a register, a memory location or an
immediate value.
The flags are set according to the result of the operation: in
particular, the carry flag is affected and can be used by a
subsequent ADC instruction.
In the forms with an 8-bit immediate second operand and a longer
first operand, the second operand is considered to be signed, and is
sign-extended to the length of the first operand. In these cases,
the BYTE qualifier is necessary to force NASM to generate this
form of the instruction.
and Logical AND
AND performs a bitwise AND operation between its two operands
(i.e. each bit of the result is 1 if and only if the corresponding
bits of the two inputs were both 1), and stores the result in the
destination (first) operand. The destination operand can be a
register or a memory location. The source operand can be a register,
a memory location or an immediate value.
In the forms with an 8-bit immediate second operand and a longer
first operand, the second operand is considered to be signed, and is
sign-extended to the length of the first operand. In these cases,
the BYTE qualifier is necessary to force NASM to generate this
form of the instruction.
The MMX instruction PAND (see PAND) performs the same
operation on the 64-bit MMX registers.
cmp Compare Two Operands
CMP performs a 'mental' subtraction of its second operand from
its first operand, and affects the flags as if the subtraction had
taken place, but does not store the result of the subtraction
anywhere.
In the forms with an 8-bit immediate second operand and a longer
first operand, the second operand is considered to be signed, and is
sign-extended to the length of the first operand. In these cases,
the BYTE qualifier is necessary to force NASM to generate this
form of the instruction.
The destination operand can be a register or a memory location. The source can be a register, memory location or an immediate value of the same size as the destination.
or Logical Inclusive OR
OR performs a bitwise OR operation between its two operands
(i.e. each bit of the result is 1 if and only if at least one of the
corresponding bits of the two inputs was 1), and stores the result
in the destination (first) operand.
In the forms with an 8-bit immediate second operand and a longer
first operand, the second operand is considered to be signed, and is
sign-extended to the length of the first operand. In these cases,
the BYTE qualifier is necessary to force NASM to generate this
form of the instruction.
The MMX instruction POR (see POR) performs the same
operation on the 64-bit MMX registers.
sbb Subtract with Borrow
SBB performs integer subtraction: it subtracts its second
operand, plus the value of the carry flag, from its first, and
leaves the result in its destination (first) operand. The flags are
set according to the result of the operation: in particular, the
carry flag is affected and can be used by a subsequent SBB
instruction.
In the forms with an 8-bit immediate second operand and a longer
first operand, the second operand is considered to be signed, and is
sign-extended to the length of the first operand. In these cases,
the BYTE qualifier is necessary to force NASM to generate this
form of the instruction.
To subtract one number from another without also subtracting the
contents of the carry flag, use SUB (SUB).
sub Subtract
SUB performs integer subtraction: it subtracts its second
operand from its first, and leaves the result in its destination
(first) operand. The flags are set according to the result of the
operation: in particular, the carry flag is affected and can be used
by a subsequent SBB instruction (SBB).
In the forms with an 8-bit immediate second operand and a longer
first operand, the second operand is considered to be signed, and is
sign-extended to the length of the first operand. In these cases,
the BYTE qualifier is necessary to force NASM to generate this
form of the instruction.
xor Logical Exclusive OR
XOR performs a bitwise XOR operation between its two operands
(i.e. each bit of the result is 1 if and only if exactly one of the
corresponding bits of the two inputs was 1), and stores the result
in the destination (first) operand.
In the forms with an 8-bit immediate second operand and a longer
first operand, the second operand is considered to be signed, and is
sign-extended to the length of the first operand. In these cases,
the BYTE qualifier is necessary to force NASM to generate this
form of the instruction.
The MMX instruction PXOR (see PXOR) performs the same
operation on the 64-bit MMX registers.
Bitwise testing
test Logical Compare
TEST performs a 'mental' bitwise AND of its two operands, and
affects the flags as if the operation had taken place, but does not
store the result of the operation anywhere.
The basic shift and rotate operations
rcl Rotate Left through Carry Flag
RCL and RCR perform a 9-bit, 17-bit or 33-bit bitwise
rotation operation, involving the given source/destination (first)
operand and the carry bit. Thus, for example, in the operation
RCL AL,1, a 9-bit rotation is performed in which AL is
shifted left by 1, the top bit of AL moves into the carry flag,
and the original value of the carry flag is placed in the low bit of
AL.
The number of bits to rotate by is given by the second operand. Only the bottom five bits of the rotation count are considered by processors above the 8086.
You can force the longer (286 and upwards, beginning with a C1
byte) form of RCL foo,1 by using a BYTE prefix: \c{RCL
foo,BYTE 1}. Similarly with RCR.
rcr Rotate Right through Carry Flag
RCL and RCR perform a 9-bit, 17-bit or 33-bit bitwise
rotation operation, involving the given source/destination (first)
operand and the carry bit. Thus, for example, in the operation
RCL AL,1, a 9-bit rotation is performed in which AL is
shifted left by 1, the top bit of AL moves into the carry flag,
and the original value of the carry flag is placed in the low bit of
AL.
The number of bits to rotate by is given by the second operand. Only the bottom five bits of the rotation count are considered by processors above the 8086.
You can force the longer (286 and upwards, beginning with a C1
byte) form of RCL foo,1 by using a BYTE prefix: \c{RCL
foo,BYTE 1}. Similarly with RCR.
rol Rotate Left
ROL and ROR perform a bitwise rotation operation on the given
source/destination (first) operand. Thus, for example, in the
operation ROL AL,1, an 8-bit rotation is performed in which
AL is shifted left by 1 and the original top bit of AL moves
round into the low bit.
The number of bits to rotate by is given by the second operand. Only the bottom five bits of the rotation count are considered by processors above the 8086.
You can force the longer (286 and upwards, beginning with a C1
byte) form of ROL foo,1 by using a BYTE prefix: \c{ROL
foo,BYTE 1}. Similarly with ROR.
ror Rotate Right
ROL and ROR perform a bitwise rotation operation on the given
source/destination (first) operand. Thus, for example, in the
operation ROL AL,1, an 8-bit rotation is performed in which
AL is shifted left by 1 and the original top bit of AL moves
round into the low bit.
The number of bits to rotate by is given by the second operand. Only the bottom five bits of the rotation count are considered by processors above the 8086.
You can force the longer (286 and upwards, beginning with a C1
byte) form of ROL foo,1 by using a BYTE prefix: \c{ROL
foo,BYTE 1}. Similarly with ROR.
sal Arithmetic Shift Left
SAL and SAR perform an arithmetic shift operation on the given
source/destination (first) operand. The vacated bits are filled with
zero for SAL, and with copies of the original high bit of the
source operand for SAR.
SAL is a synonym for SHL (see SHL). NASM will
assemble either one to the same code, but NDISASM will always
disassemble that code as SHL.
The number of bits to shift by is given by the second operand. Only the bottom five bits of the shift count are considered by processors above the 8086.
You can force the longer (286 and upwards, beginning with a C1
byte) form of SAL foo,1 by using a BYTE prefix: \c{SAL
foo,BYTE 1}. Similarly with SAR.
sar Arithmetic Shift Right
SAL and SAR perform an arithmetic shift operation on the given
source/destination (first) operand. The vacated bits are filled with
zero for SAL, and with copies of the original high bit of the
source operand for SAR.
SAL is a synonym for SHL (see SHL). NASM will
assemble either one to the same code, but NDISASM will always
disassemble that code as SHL.
The number of bits to shift by is given by the second operand. Only the bottom five bits of the shift count are considered by processors above the 8086.
You can force the longer (286 and upwards, beginning with a C1
byte) form of SAL foo,1 by using a BYTE prefix: \c{SAL
foo,BYTE 1}. Similarly with SAR.
shl Logical Shift Left
SHL and SHR perform a logical shift operation on the given
source/destination (first) operand. The vacated bits are filled with
zero.
A synonym for SHL is SAL (see SAL). NASM will
assemble either one to the same code, but NDISASM will always
disassemble that code as SHL.
The number of bits to shift by is given by the second operand. Only the bottom five bits of the shift count are considered by processors above the 8086.
You can force the longer (286 and upwards, beginning with a C1
byte) form of SHL foo,1 by using a BYTE prefix: \c{SHL
foo,BYTE 1}. Similarly with SHR.
shr Logical Shift Right
SHL and SHR perform a logical shift operation on the given
source/destination (first) operand. The vacated bits are filled with
zero.
A synonym for SHL is SAL (see SAL). NASM will
assemble either one to the same code, but NDISASM will always
disassemble that code as SHL.
The number of bits to shift by is given by the second operand. Only the bottom five bits of the shift count are considered by processors above the 8086.
You can force the longer (286 and upwards, beginning with a C1
byte) form of SHL foo,1 by using a BYTE prefix: \c{SHL
foo,BYTE 1}. Similarly with SHR.
Other basic integer arithmetic
dec Decrement by 1
DEC subtracts 1 from its operand. It does not affect the
carry flag: to affect the carry flag, use SUB something,1 (see
SUB). DEC affects all the other flags according to the result.
This instruction can be used with a LOCK prefix to allow atomic
execution.
See also INC (INC).
div Unsigned Divide
DIV performs unsigned integer division. The explicit operand
provided is the divisor; the dividend and destination operands are
implicit, in the following way:
-
For
DIV r/m8,AXis divided by the given operand; the quotient is stored inALand the remainder inAH. -
For
DIV r/m16,DX:AXis divided by the given operand; the quotient is stored inAXand the remainder inDX. -
For
DIV r/m32,EDX:EAXis divided by the given operand; the quotient is stored inEAXand the remainder inEDX.
Signed integer division is performed by the IDIV instruction:
see IDIV.
idiv Signed Divide
IDIV performs signed integer division. The explicit operand
provided is the divisor; the dividend and destination operands
are implicit, in the following way:
-
For
IDIV r/m8,AXis divided by the given operand; the quotient is stored inALand the remainder inAH. -
For
IDIV r/m16,DX:AXis divided by the given operand; the quotient is stored inAXand the remainder inDX. -
For
IDIV r/m32,EDX:EAXis divided by the given operand; the quotient is stored inEAXand the remainder inEDX.
Unsigned integer division is performed by the DIV instruction:
see DIV.
imul Signed Multiply
IMUL performs signed integer multiplication. For the
single-operand form, the other operand and destination are
implicit, in the following way:
-
For
IMUL r/m8,ALis multiplied by the given operand; the product is stored inAX. -
For
IMUL r/m16,AXis multiplied by the given operand; the product is stored inDX:AX. -
For
IMUL r/m32,EAXis multiplied by the given operand; the product is stored inEDX:EAX.
The two-operand form multiplies its two operands and stores the result in the destination (first) operand. The three-operand form multiplies its last two operands and stores the result in the first operand.
The two-operand form with an immediate second operand is in
fact a shorthand for the three-operand form, as can be seen by
examining the opcode descriptions: in the two-operand form, the
code /r takes both its register and r/m parts from the
same operand (the first one).
In the forms with an 8-bit immediate operand and another longer
source operand, the immediate operand is considered to be signed,
and is sign-extended to the length of the other source operand.
In these cases, the BYTE qualifier is necessary to force
NASM to generate this form of the instruction.
Unsigned integer multiplication is performed by the MUL
instruction: see MUL.
inc Increment by 1
INC adds 1 to its operand. It does not affect the carry
flag: to affect the carry flag, use ADD something,1 (see
ADD). INC affects all the other flags according to the result.
This instruction can be used with a LOCK prefix to allow atomic execution.
See also DEC (DEC).
mul Unsigned Multiply
MUL performs unsigned integer multiplication. The other operand
to the multiplication, and the destination operand, are implicit, in
the following way:
-
For
MUL r/m8,ALis multiplied by the given operand; the product is stored inAX. -
For
MUL r/m16,AXis multiplied by the given operand; the product is stored inDX:AX. -
For
MUL r/m32,EAXis multiplied by the given operand; the product is stored inEDX:EAX.
Signed integer multiplication is performed by the IMUL
instruction: see IMUL.
neg Two's Complement Negation
NEG replaces the contents of its operand by the two's complement
negation (invert all the bits and then add one) of the original
value. NOT, similarly, performs one's complement (inverts all
the bits).
not One's Complement Negation
NEG replaces the contents of its operand by the two's complement
negation (invert all the bits and then add one) of the original
value. NOT, similarly, performs one's complement (inverts all
the bits).
Double width shift
shld Integer Double Precision Shift Left
-
SHLDperforms a double-precision left shift. It notionally places its second operand to the right of its first, then shifts the entire bit string thus generated to the left by a number of bits specified in the third operand. It then updates only the first operand according to the result of this. The second operand is not modified. -
SHRDperforms the corresponding right shift: it notionally places the second operand to the left of the first, shifts the whole bit string right, and updates only the first operand.
For example, if EAX holds 0x01234567 and EBX holds
0x89ABCDEF, then the instruction SHLD EAX,EBX,4 would update
EAX to hold 0x12345678. Under the same conditions, \c{SHRD
EAX,EBX,4} would update EAX to hold 0xF0123456.
The number of bits to shift by is given by the third operand. Only the bottom five bits of the shift count are considered.
shrd Integer Double Precision Shift Right
-
SHLDperforms a double-precision left shift. It notionally places its second operand to the right of its first, then shifts the entire bit string thus generated to the left by a number of bits specified in the third operand. It then updates only the first operand according to the result of this. The second operand is not modified. -
SHRDperforms the corresponding right shift: it notionally places the second operand to the left of the first, shifts the whole bit string right, and updates only the first operand.
For example, if EAX holds 0x01234567 and EBX holds
0x89ABCDEF, then the instruction SHLD EAX,EBX,4 would update
EAX to hold 0x12345678. Under the same conditions, \c{SHRD
EAX,EBX,4} would update EAX to hold 0xF0123456.
The number of bits to shift by is given by the third operand. Only the bottom five bits of the shift count are considered.
Sign and zero extension
cbw Convert Byte to Word
All these instructions sign-extend a short value into a longer one, by replicating the top bit of the original value to fill the extended one.
CBW extends AL into AX by repeating the top bit of
AL in every bit of AH. CWDE extends AX into
EAX. CWD extends AX into DX:AX by repeating
the top bit of AX throughout DX, and CDQ extends
EAX into EDX:EAX.
cdq Convert Doubleword to Quadword
All these instructions sign-extend a short value into a longer one, by replicating the top bit of the original value to fill the extended one.
CBW extends AL into AX by repeating the top bit of
AL in every bit of AH. CWDE extends AX into
EAX. CWD extends AX into DX:AX by repeating
the top bit of AX throughout DX, and CDQ extends
EAX into EDX:EAX.
cdqe Convert Doubleword to Quadword
Sign extends eax into rax, so that a 32 bit signed value read from memory or returned by a syscall can be used in 64 bit arithmetic. It takes no operands and touches no other register. movsxd rax, eax does the same thing in two more bytes.
cqo Convert Quadword to Octaword
Sign extends rax into rdx:rax, filling rdx with copies of the sign bit. idiv divides that 128 bit pair, so signed division is written as cqo then idiv; forgetting the cqo leaves whatever rdx happened to hold in the high half and the result is nonsense rather than an error.
cwd Convert Word to Doubleword
All these instructions sign-extend a short value into a longer one, by replicating the top bit of the original value to fill the extended one.
CBW extends AL into AX by repeating the top bit of
AL in every bit of AH. CWDE extends AX into
EAX. CWD extends AX into DX:AX by repeating
the top bit of AX throughout DX, and CDQ extends
EAX into EDX:EAX.
cwde Convert Word to Doubleword
All these instructions sign-extend a short value into a longer one, by replicating the top bit of the original value to fill the extended one.
CBW extends AL into AX by repeating the top bit of
AL in every bit of AH. CWDE extends AX into
EAX. CWD extends AX into DX:AX by repeating
the top bit of AX throughout DX, and CDQ extends
EAX into EDX:EAX.
movsx Move with Sign-Extension
MOVSX sign-extends its source (second) operand to the length of
its destination (first) operand, and copies the result into the
destination operand. MOVZX does the same, but zero-extends
rather than sign-extending.
MOVSX sign-extends its source (second) operand to the length of
its destination (first) operand, and copies the result into the
destination operand. MOVZX does the same, but zero-extends
rather than sign-extending.
movsxd Move Doubleword to Quadword with Sign-Extension
Copies a 32 bit source into a 64 bit register, sign extending it. This is the instruction to reach for when a signed 32 bit value has to become a 64 bit one, because the ordinary mov eax, ... zero extends instead: writing any 32 bit register clears the top half of its 64 bit name.
MOVSX sign-extends its source (second) operand to the length of
its destination (first) operand, and copies the result into the
destination operand. MOVZX does the same, but zero-extends
rather than sign-extending.
movzx Move with Zero-Extend
MOVSX sign-extends its source (second) operand to the length of
its destination (first) operand, and copies the result into the
destination operand. MOVZX does the same, but zero-extends
rather than sign-extending.
MOVSX sign-extends its source (second) operand to the length of
its destination (first) operand, and copies the result into the
destination operand. MOVZX does the same, but zero-extends
rather than sign-extending.
MOVSX sign-extends its source (second) operand to the length of
its destination (first) operand, and copies the result into the
destination operand. MOVZX does the same, but zero-extends
rather than sign-extending.
MOVSX sign-extends its source (second) operand to the length of
its destination (first) operand, and copies the result into the
destination operand. MOVZX does the same, but zero-extends
rather than sign-extending.
Bit operations
bsf Bit Scan Forward
-
BSFsearches for the least significant set bit in its source (second) operand, and if it finds one, stores the index in its destination (first) operand. If no set bit is found, the contents of the destination operand are undefined. If the source operand is zero, the zero flag is set. -
BSRperforms the same function, but searches from the top instead, so it finds the most significant set bit.
Bit indices are from 0 (least significant) to 15 or 31 (most significant). The destination operand can only be a register. The source operand can be a register or a memory location.
bsr Bit Scan Reverse
-
BSFsearches for the least significant set bit in its source (second) operand, and if it finds one, stores the index in its destination (first) operand. If no set bit is found, the contents of the destination operand are undefined. If the source operand is zero, the zero flag is set. -
BSRperforms the same function, but searches from the top instead, so it finds the most significant set bit.
Bit indices are from 0 (least significant) to 15 or 31 (most significant). The destination operand can only be a register. The source operand can be a register or a memory location.
bt Bit Test
These instructions all test one bit of their first operand, whose index is given by the second operand, and store the value of that bit into the carry flag. Bit indices are from 0 (least significant) to 15 or 31 (most significant).
In addition to storing the original value of the bit into the carry
flag, BTR also resets (clears) the bit in the operand itself.
BTS sets the bit, and BTC complements the bit. BT does
not modify its operands.
The destination can be a register or a memory location. The source can be a register or an immediate value.
If the destination operand is a register, the bit offset should be in the range 0-15 (for 16-bit operands) or 0-31 (for 32-bit operands). An immediate value outside these ranges will be taken modulo 16/32 by the processor.
If the destination operand is a memory location, then an immediate bit offset follows the same rules as for a register. If the bit offset is in a register, then it can be anything within the signed range of the register used (ie, for a 32-bit operand, it can be (-2^31) to (2^31 - 1)
btc Bit Test and Complement
These instructions all test one bit of their first operand, whose index is given by the second operand, and store the value of that bit into the carry flag. Bit indices are from 0 (least significant) to 15 or 31 (most significant).
In addition to storing the original value of the bit into the carry
flag, BTR also resets (clears) the bit in the operand itself.
BTS sets the bit, and BTC complements the bit. BT does
not modify its operands.
The destination can be a register or a memory location. The source can be a register or an immediate value.
If the destination operand is a register, the bit offset should be in the range 0-15 (for 16-bit operands) or 0-31 (for 32-bit operands). An immediate value outside these ranges will be taken modulo 16/32 by the processor.
If the destination operand is a memory location, then an immediate bit offset follows the same rules as for a register. If the bit offset is in a register, then it can be anything within the signed range of the register used (ie, for a 32-bit operand, it can be (-2^31) to (2^31 - 1)
btr Bit Test and Reset
These instructions all test one bit of their first operand, whose index is given by the second operand, and store the value of that bit into the carry flag. Bit indices are from 0 (least significant) to 15 or 31 (most significant).
In addition to storing the original value of the bit into the carry
flag, BTR also resets (clears) the bit in the operand itself.
BTS sets the bit, and BTC complements the bit. BT does
not modify its operands.
The destination can be a register or a memory location. The source can be a register or an immediate value.
If the destination operand is a register, the bit offset should be in the range 0-15 (for 16-bit operands) or 0-31 (for 32-bit operands). An immediate value outside these ranges will be taken modulo 16/32 by the processor.
If the destination operand is a memory location, then an immediate bit offset follows the same rules as for a register. If the bit offset is in a register, then it can be anything within the signed range of the register used (ie, for a 32-bit operand, it can be (-2^31) to (2^31 - 1)
bts Bit Test and Set
These instructions all test one bit of their first operand, whose index is given by the second operand, and store the value of that bit into the carry flag. Bit indices are from 0 (least significant) to 15 or 31 (most significant).
In addition to storing the original value of the bit into the carry
flag, BTR also resets (clears) the bit in the operand itself.
BTS sets the bit, and BTC complements the bit. BT does
not modify its operands.
The destination can be a register or a memory location. The source can be a register or an immediate value.
If the destination operand is a register, the bit offset should be in the range 0-15 (for 16-bit operands) or 0-31 (for 32-bit operands). An immediate value outside these ranges will be taken modulo 16/32 by the processor.
If the destination operand is a memory location, then an immediate bit offset follows the same rules as for a register. If the bit offset is in a register, then it can be anything within the signed range of the register used (ie, for a 32-bit operand, it can be (-2^31) to (2^31 - 1)
The implied operation of this instruction is:
IBTS r/m16,AX,CL,reg16
IBTS r/m32,EAX,CL,reg32
Writes a bit string from the source operand to the destination.
CL indicates the number of bits to be copied, from the low bits
of the source. (E)AX indicates the low order bit offset in the
destination that is written to. For example, if CL is set to 4
and AX (for 16-bit code) is set to 5, bits 0-3 of src will
be copied to bits 5-8 of dst. This instruction is very poorly
documented, and I have been unable to find any official source of
documentation on it.
IBTS is supported only on the early Intel 386s, and conflicts
with the opcodes for CMPXCHG486 (on early Intel 486s). NASM
supports it only for completeness. Its counterpart is XBTS
(see XBTS).
The implied operation of this instruction is:
XBTS r/m16,reg16,AX,CL
XBTS r/m32,reg32,EAX,CL
Writes a bit string from the source operand to the destination. CL
indicates the number of bits to be copied, and (E)AX indicates the
low order bit offset in the source. The bits are written to the low
order bits of the destination register. For example, if CL is set
to 4 and AX (for 16-bit code) is set to 5, bits 5-8 of src will
be copied to bits 0-3 of dst. This instruction is very poorly
documented, and I have been unable to find any official source of
documentation on it.
XBTS is supported only on the early Intel 386s, and conflicts with
the opcodes for CMPXCHG486 (on early Intel 486s). NASM supports it
only for completeness. Its counterpart is IBTS (see IBTS).
Endianness handling
bswap Byte Swap
BSWAP swaps the order of the four bytes of a 32-bit register:
bits 0-7 exchange places with bits 24-31, and bits 8-15 swap with
bits 16-23. There is no explicit 16-bit equivalent: to byte-swap
AX, BX, CX or DX, XCHG can be used. When BSWAP
is used with a 16-bit register, the result is undefined.
movbe Move Data After Swapping Bytes
Move Data After Swapping Bytes
Decimal arithmetic
These instructions are used in conjunction with the add, subtract,
multiply and divide instructions to perform binary-coded decimal
arithmetic in unpacked (one BCD digit per byte - easy to
translate to and from ASCII, hence the instruction names) form.
There are also packed BCD instructions DAA and DAS: see
DAA.
-
AAA(ASCII Adjust After Addition) should be used after a one-byteADDinstruction whose destination was theALregister: by means of examining the value in the low nibble ofALand also the auxiliary carry flagAF, it determines whether the addition has overflowed, and adjusts it (and sets the carry flag) if so. You can add long BCD strings together by doingADD/AAAon the low digits, then doingADC/AAAon each subsequent digit. -
AAS(ASCII Adjust AL After Subtraction) works similarly toAAA, but is for use afterSUBinstructions rather thanADD. -
AAM(ASCII Adjust AX After Multiply) is for use after you have multiplied two decimal digits together and left the result inAL: it dividesALby ten and stores the quotient inAH, leaving the remainder inAL. The divisor 10 can be changed by specifying an operand to the instruction: a particularly handy use of this isAAM 16, causing the two nibbles inALto be separated intoAHandAL. -
AAD(ASCII Adjust AX Before Division) performs the inverse operation toAAM: it multipliesAHby ten, adds it toAL, and setsAHto zero. Again, the multiplier 10 can be changed.
These instructions are used in conjunction with the add, subtract,
multiply and divide instructions to perform binary-coded decimal
arithmetic in unpacked (one BCD digit per byte - easy to
translate to and from ASCII, hence the instruction names) form.
There are also packed BCD instructions DAA and DAS: see
DAA.
-
AAA(ASCII Adjust After Addition) should be used after a one-byteADDinstruction whose destination was theALregister: by means of examining the value in the low nibble ofALand also the auxiliary carry flagAF, it determines whether the addition has overflowed, and adjusts it (and sets the carry flag) if so. You can add long BCD strings together by doingADD/AAAon the low digits, then doingADC/AAAon each subsequent digit. -
AAS(ASCII Adjust AL After Subtraction) works similarly toAAA, but is for use afterSUBinstructions rather thanADD. -
AAM(ASCII Adjust AX After Multiply) is for use after you have multiplied two decimal digits together and left the result inAL: it dividesALby ten and stores the quotient inAH, leaving the remainder inAL. The divisor 10 can be changed by specifying an operand to the instruction: a particularly handy use of this isAAM 16, causing the two nibbles inALto be separated intoAHandAL. -
AAD(ASCII Adjust AX Before Division) performs the inverse operation toAAM: it multipliesAHby ten, adds it toAL, and setsAHto zero. Again, the multiplier 10 can be changed.
These instructions are used in conjunction with the add, subtract,
multiply and divide instructions to perform binary-coded decimal
arithmetic in unpacked (one BCD digit per byte - easy to
translate to and from ASCII, hence the instruction names) form.
There are also packed BCD instructions DAA and DAS: see
DAA.
-
AAA(ASCII Adjust After Addition) should be used after a one-byteADDinstruction whose destination was theALregister: by means of examining the value in the low nibble ofALand also the auxiliary carry flagAF, it determines whether the addition has overflowed, and adjusts it (and sets the carry flag) if so. You can add long BCD strings together by doingADD/AAAon the low digits, then doingADC/AAAon each subsequent digit. -
AAS(ASCII Adjust AL After Subtraction) works similarly toAAA, but is for use afterSUBinstructions rather thanADD. -
AAM(ASCII Adjust AX After Multiply) is for use after you have multiplied two decimal digits together and left the result inAL: it dividesALby ten and stores the quotient inAH, leaving the remainder inAL. The divisor 10 can be changed by specifying an operand to the instruction: a particularly handy use of this isAAM 16, causing the two nibbles inALto be separated intoAHandAL. -
AAD(ASCII Adjust AX Before Division) performs the inverse operation toAAM: it multipliesAHby ten, adds it toAL, and setsAHto zero. Again, the multiplier 10 can be changed.
These instructions are used in conjunction with the add, subtract,
multiply and divide instructions to perform binary-coded decimal
arithmetic in unpacked (one BCD digit per byte - easy to
translate to and from ASCII, hence the instruction names) form.
There are also packed BCD instructions DAA and DAS: see
DAA.
-
AAA(ASCII Adjust After Addition) should be used after a one-byteADDinstruction whose destination was theALregister: by means of examining the value in the low nibble ofALand also the auxiliary carry flagAF, it determines whether the addition has overflowed, and adjusts it (and sets the carry flag) if so. You can add long BCD strings together by doingADD/AAAon the low digits, then doingADC/AAAon each subsequent digit. -
AAS(ASCII Adjust AL After Subtraction) works similarly toAAA, but is for use afterSUBinstructions rather thanADD. -
AAM(ASCII Adjust AX After Multiply) is for use after you have multiplied two decimal digits together and left the result inAL: it dividesALby ten and stores the quotient inAH, leaving the remainder inAL. The divisor 10 can be changed by specifying an operand to the instruction: a particularly handy use of this isAAM 16, causing the two nibbles inALto be separated intoAHandAL. -
AAD(ASCII Adjust AX Before Division) performs the inverse operation toAAM: it multipliesAHby ten, adds it toAL, and setsAHto zero. Again, the multiplier 10 can be changed.
These instructions are used in conjunction with the add and subtract
instructions to perform binary-coded decimal arithmetic in
packed (one BCD digit per nibble) form. For the unpacked
equivalents, see AAA.
DAA should be used after a one-byte ADD instruction whose
destination was the AL register: by means of examining the value
in the AL and also the auxiliary carry flag AF, it
determines whether either digit of the addition has overflowed, and
adjusts it (and sets the carry and auxiliary-carry flags) if so. You
can add long BCD strings together by doing ADD/DAA on the
low two digits, then doing ADC/DAA on each subsequent pair
of digits.
DAS works similarly to DAA, but is for use after SUB
instructions rather than ADD.
These instructions are used in conjunction with the add and subtract
instructions to perform binary-coded decimal arithmetic in
packed (one BCD digit per nibble) form. For the unpacked
equivalents, see AAA.
DAA should be used after a one-byte ADD instruction whose
destination was the AL register: by means of examining the value
in the AL and also the auxiliary carry flag AF, it
determines whether either digit of the addition has overflowed, and
adjusts it (and sets the carry and auxiliary-carry flags) if so. You
can add long BCD strings together by doing ADD/DAA on the
low two digits, then doing ADC/DAA on each subsequent pair
of digits.
DAS works similarly to DAA, but is for use after SUB
instructions rather than ADD.
Atomic operations
cmpxchg Compare and Exchange
These two instructions perform exactly the same operation; however,
apparently some (not all) 486 processors support it under a
non-standard opcode, so NASM provides the undocumented
CMPXCHG486 form to generate the non-standard opcode.
CMPXCHG compares its destination (first) operand to the value in
AL, AX or EAX (depending on the operand size of the
instruction). If they are equal, it copies its source (second)
operand into the destination and sets the zero flag. Otherwise, it
clears the zero flag and copies the destination register to AL, AX or EAX.
The destination can be either a register or a memory location. The source is a register.
CMPXCHG is intended to be used for atomic operations in
multitasking or multiprocessor environments. To safely update a
value in shared memory, for example, you might load the value into
EAX, load the updated value into EBX, and then execute the
instruction LOCK CMPXCHG [value],EBX. If value has not
changed since being loaded, it is updated with your desired new
value, and the zero flag is set to let you know it has worked. (The
LOCK prefix prevents another processor doing anything in the
middle of this operation: it guarantees atomicity.) However, if
another processor has modified the value in between your load and
your attempted store, the store does not happen, and you are
notified of the failure by a cleared zero flag, so you can go round
and try again.
These two instructions perform exactly the same operation; however,
apparently some (not all) 486 processors support it under a
non-standard opcode, so NASM provides the undocumented
CMPXCHG486 form to generate the non-standard opcode.
CMPXCHG compares its destination (first) operand to the value in
AL, AX or EAX (depending on the operand size of the
instruction). If they are equal, it copies its source (second)
operand into the destination and sets the zero flag. Otherwise, it
clears the zero flag and copies the destination register to AL, AX or EAX.
The destination can be either a register or a memory location. The source is a register.
CMPXCHG is intended to be used for atomic operations in
multitasking or multiprocessor environments. To safely update a
value in shared memory, for example, you might load the value into
EAX, load the updated value into EBX, and then execute the
instruction LOCK CMPXCHG [value],EBX. If value has not
changed since being loaded, it is updated with your desired new
value, and the zero flag is set to let you know it has worked. (The
LOCK prefix prevents another processor doing anything in the
middle of this operation: it guarantees atomicity.) However, if
another processor has modified the value in between your load and
your attempted store, the store does not happen, and you are
notified of the failure by a cleared zero flag, so you can go round
and try again.
cmpxchg8b Compare and Exchange 8 Bytes
This is a larger and more unwieldy version of CMPXCHG: it
compares the 64-bit (eight-byte) value stored at [mem] with the
value in EDX:EAX. If they are equal, it sets the zero flag and
stores ECX:EBX into the memory area. If they are unequal, it
clears the zero flag and stores the memory contents into EDX:EAX.
CMPXCHG8B can be used with the LOCK prefix, to allow atomic
execution. This is useful in multi-processor and multi-tasking
environments.
xadd Exchange and Add
XADD exchanges the values in its two operands, and then adds
them together and writes the result into the destination (first)
operand. This instruction can be used with a LOCK prefix for
multi-processor synchronisation purposes.
xchg Exchange Register/Memory with Register
XCHG exchanges the values in its two operands. It can be used
with a LOCK prefix for purposes of multi-processor
synchronisation.
XCHG AX,AX or XCHG EAX,EAX (depending on the BITS
setting) generates the opcode 90h, and so is a synonym for
NOP (NOP).
Stack operations
BOUND expects its second operand to point to an area of memory
containing two signed values of the same size as its first operand
(i.e. two words for the 16-bit form; two doublewords for the 32-bit
form). It performs two signed comparisons: if the value in the
register passed as its first operand is less than the first of the
in-memory values, or is greater than or equal to the second, it
throws a BR exception. Otherwise, it does nothing.
ENTER constructs a stack frame for a high-level language
procedure call. The first operand (the iw in the opcode
definition above refers to the first operand) gives the amount of
stack space to allocate for local variables; the second (the ib
above) gives the nesting level of the procedure (for languages like
Pascal, with nested procedures).
The function of ENTER, with a nesting level of zero, is
equivalent to
PUSH EBP ; or PUSH BP in 16 bits
MOV EBP,ESP ; or MOV BP,SP in 16 bits
SUB ESP,operand1 ; or SUB SP,operand1 in 16 bits
This creates a stack frame with the procedure parameters accessible
upwards from EBP, and local variables accessible downwards from
EBP.
With a nesting level of one, the stack frame created is 4 (or 2)
bytes bigger, and the value of the final frame pointer EBP is
accessible in memory at [EBP-4].
This allows ENTER, when called with a nesting level of two, to
look at the stack frame described by the previous value of
EBP, find the frame pointer at offset -4 from that, and push it
along with its new frame pointer, so that when a level-two procedure
is called from within a level-one procedure, [EBP-4] holds the
frame pointer of the most recent level-one procedure call and
[EBP-8] holds that of the most recent level-two call. And so on,
for nesting levels up to 31.
Stack frames created by ENTER can be destroyed by the LEAVE
instruction: see LEAVE.
ENTER constructs a stack frame for a high-level language
procedure call. The first operand (the iw in the opcode
definition above refers to the first operand) gives the amount of
stack space to allocate for local variables; the second (the ib
above) gives the nesting level of the procedure (for languages like
Pascal, with nested procedures).
The function of ENTER, with a nesting level of zero, is
equivalent to
PUSH EBP ; or PUSH BP in 16 bits
MOV EBP,ESP ; or MOV BP,SP in 16 bits
SUB ESP,operand1 ; or SUB SP,operand1 in 16 bits
This creates a stack frame with the procedure parameters accessible
upwards from EBP, and local variables accessible downwards from
EBP.
With a nesting level of one, the stack frame created is 4 (or 2)
bytes bigger, and the value of the final frame pointer EBP is
accessible in memory at [EBP-4].
This allows ENTER, when called with a nesting level of two, to
look at the stack frame described by the previous value of
EBP, find the frame pointer at offset -4 from that, and push it
along with its new frame pointer, so that when a level-two procedure
is called from within a level-one procedure, [EBP-4] holds the
frame pointer of the most recent level-one procedure call and
[EBP-8] holds that of the most recent level-two call. And so on,
for nesting levels up to 31.
Stack frames created by ENTER can be destroyed by the LEAVE
instruction: see LEAVE.
ENTER constructs a stack frame for a high-level language
procedure call. The first operand (the iw in the opcode
definition above refers to the first operand) gives the amount of
stack space to allocate for local variables; the second (the ib
above) gives the nesting level of the procedure (for languages like
Pascal, with nested procedures).
The function of ENTER, with a nesting level of zero, is
equivalent to
PUSH EBP ; or PUSH BP in 16 bits
MOV EBP,ESP ; or MOV BP,SP in 16 bits
SUB ESP,operand1 ; or SUB SP,operand1 in 16 bits
This creates a stack frame with the procedure parameters accessible
upwards from EBP, and local variables accessible downwards from
EBP.
With a nesting level of one, the stack frame created is 4 (or 2)
bytes bigger, and the value of the final frame pointer EBP is
accessible in memory at [EBP-4].
This allows ENTER, when called with a nesting level of two, to
look at the stack frame described by the previous value of
EBP, find the frame pointer at offset -4 from that, and push it
along with its new frame pointer, so that when a level-two procedure
is called from within a level-one procedure, [EBP-4] holds the
frame pointer of the most recent level-one procedure call and
[EBP-8] holds that of the most recent level-two call. And so on,
for nesting levels up to 31.
Stack frames created by ENTER can be destroyed by the LEAVE
instruction: see LEAVE.
ENTER constructs a stack frame for a high-level language
procedure call. The first operand (the iw in the opcode
definition above refers to the first operand) gives the amount of
stack space to allocate for local variables; the second (the ib
above) gives the nesting level of the procedure (for languages like
Pascal, with nested procedures).
The function of ENTER, with a nesting level of zero, is
equivalent to
PUSH EBP ; or PUSH BP in 16 bits
MOV EBP,ESP ; or MOV BP,SP in 16 bits
SUB ESP,operand1 ; or SUB SP,operand1 in 16 bits
This creates a stack frame with the procedure parameters accessible
upwards from EBP, and local variables accessible downwards from
EBP.
With a nesting level of one, the stack frame created is 4 (or 2)
bytes bigger, and the value of the final frame pointer EBP is
accessible in memory at [EBP-4].
This allows ENTER, when called with a nesting level of two, to
look at the stack frame described by the previous value of
EBP, find the frame pointer at offset -4 from that, and push it
along with its new frame pointer, so that when a level-two procedure
is called from within a level-one procedure, [EBP-4] holds the
frame pointer of the most recent level-one procedure call and
[EBP-8] holds that of the most recent level-two call. And so on,
for nesting levels up to 31.
Stack frames created by ENTER can be destroyed by the LEAVE
instruction: see LEAVE.
LEAVE destroys a stack frame of the form created by the
ENTER instruction (see ENTER). It is functionally
equivalent to MOV ESP,EBP followed by POP EBP (or \c{MOV
SP,BP} followed by POP BP in 16-bit mode).
LEAVE destroys a stack frame of the form created by the
ENTER instruction (see ENTER). It is functionally
equivalent to MOV ESP,EBP followed by POP EBP (or \c{MOV
SP,BP} followed by POP BP in 16-bit mode).
LEAVE destroys a stack frame of the form created by the
ENTER instruction (see ENTER). It is functionally
equivalent to MOV ESP,EBP followed by POP EBP (or \c{MOV
SP,BP} followed by POP BP in 16-bit mode).
LEAVE destroys a stack frame of the form created by the
ENTER instruction (see ENTER). It is functionally
equivalent to MOV ESP,EBP followed by POP EBP (or \c{MOV
SP,BP} followed by POP BP in 16-bit mode).
pop Pop a Value from the Stack
POP loads a value from the stack (from [SS:SP] or
[SS:ESP]) and then increments the stack pointer.
The address-size attribute of the instruction determines whether
SP or ESP is used as the stack pointer: to deliberately
override the default given by the BITS setting, you can use an
a16 or a32 prefix.
The operand-size attribute of the instruction determines whether the
stack pointer is incremented by 2 or 4: this means that segment
register pops in BITS 32 mode will pop 4 bytes off the stack and
discard the upper two of them. If you need to override that, you can
use an o16 or o32 prefix.
The above opcode listings give two forms for general-purpose
register pop instructions: for example, POP BX has the two forms
5B and 8F C3. NASM will always generate the shorter form
when given POP BX. NDISASM will disassemble both.
POP CS is not a documented instruction, and is not supported on
any processor above the 8086 (since they use 0Fh as an opcode
prefix for instruction set extensions). However, at least some 8086
processors do support it, and so NASM generates it for completeness.
-
POPAWpops a word from the stack into each of, successively,DI,SI,BP, nothing (it discards a word from the stack which was a placeholder forSP),BX,DX,CXandAX. It is intended to reverse the operation ofPUSHAW(seePUSHA), but it ignores the value forSPthat was pushed on the stack byPUSHAW. -
POPADpops twice as much data, and places the results inEDI,ESI,EBP, nothing (placeholder forESP),EBX,EDX,ECXandEAX. It reverses the operation ofPUSHAD.
POPA is an alias mnemonic for either POPAW or POPAD,
depending on the current BITS setting.
Note that the registers are popped in reverse order of their numeric values in opcodes (see the register values).
-
POPAWpops a word from the stack into each of, successively,DI,SI,BP, nothing (it discards a word from the stack which was a placeholder forSP),BX,DX,CXandAX. It is intended to reverse the operation ofPUSHAW(seePUSHA), but it ignores the value forSPthat was pushed on the stack byPUSHAW. -
POPADpops twice as much data, and places the results inEDI,ESI,EBP, nothing (placeholder forESP),EBX,EDX,ECXandEAX. It reverses the operation ofPUSHAD.
POPA is an alias mnemonic for either POPAW or POPAD,
depending on the current BITS setting.
Note that the registers are popped in reverse order of their numeric values in opcodes (see the register values).
-
POPAWpops a word from the stack into each of, successively,DI,SI,BP, nothing (it discards a word from the stack which was a placeholder forSP),BX,DX,CXandAX. It is intended to reverse the operation ofPUSHAW(seePUSHA), but it ignores the value forSPthat was pushed on the stack byPUSHAW. -
POPADpops twice as much data, and places the results inEDI,ESI,EBP, nothing (placeholder forESP),EBX,EDX,ECXandEAX. It reverses the operation ofPUSHAD.
POPA is an alias mnemonic for either POPAW or POPAD,
depending on the current BITS setting.
Note that the registers are popped in reverse order of their numeric values in opcodes (see the register values).
push Push Value Onto the Stack
PUSH decrements the stack pointer (SP or ESP) by 2 or 4,
and then stores the given value at [SS:SP] or [SS:ESP].
The address-size attribute of the instruction determines whether
SP or ESP is used as the stack pointer: to deliberately
override the default given by the BITS setting, you can use an
a16 or a32 prefix.
The operand-size attribute of the instruction determines whether the
stack pointer is decremented by 2 or 4: this means that segment
register pushes in BITS 32 mode will push 4 bytes on the stack,
of which the upper two are undefined. If you need to override that,
you can use an o16 or o32 prefix.
The above opcode listings give two forms for general-purpose
register push instructions: for example, PUSH BX has the two
forms 53 and FF F3. NASM will always generate the shorter
form when given PUSH BX. NDISASM will disassemble both.
Unlike the undocumented and barely supported POP CS, PUSH CS
is a perfectly valid and sensible instruction, supported on all
processors.
The instruction PUSH SP may be used to distinguish an 8086 from
later processors: on an 8086, the value of SP stored is the
value it has after the push instruction, whereas on later
processors it is the value before the push instruction.
PUSHAW pushes, in succession, AX, CX, DX, BX,
SP, BP, SI and DI on the stack, decrementing the
stack pointer by a total of 16.
PUSHAD pushes, in succession, EAX, ECX, EDX,
EBX, ESP, EBP, ESI and EDI on the stack,
decrementing the stack pointer by a total of 32.
In both cases, the value of SP or ESP pushed is its
original value, as it had before the instruction was executed.
PUSHA is an alias mnemonic for either PUSHAW or PUSHAD,
depending on the current BITS setting.
Note that the registers are pushed in order of their numeric values in opcodes (see the register values).
See also POPA (POPA).
PUSHAW pushes, in succession, AX, CX, DX, BX,
SP, BP, SI and DI on the stack, decrementing the
stack pointer by a total of 16.
PUSHAD pushes, in succession, EAX, ECX, EDX,
EBX, ESP, EBP, ESI and EDI on the stack,
decrementing the stack pointer by a total of 32.
In both cases, the value of SP or ESP pushed is its
original value, as it had before the instruction was executed.
PUSHA is an alias mnemonic for either PUSHAW or PUSHAD,
depending on the current BITS setting.
Note that the registers are pushed in order of their numeric values in opcodes (see the register values).
See also POPA (POPA).
PUSHAW pushes, in succession, AX, CX, DX, BX,
SP, BP, SI and DI on the stack, decrementing the
stack pointer by a total of 16.
PUSHAD pushes, in succession, EAX, ECX, EDX,
EBX, ESP, EBP, ESI and EDI on the stack,
decrementing the stack pointer by a total of 32.
In both cases, the value of SP or ESP pushed is its
original value, as it had before the instruction was executed.
PUSHA is an alias mnemonic for either PUSHAW or PUSHAD,
depending on the current BITS setting.
Note that the registers are pushed in order of their numeric values in opcodes (see the register values).
See also POPA (POPA).
Jumps
ja Jump if above (CF == 0 and ZF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jae Jump if above or equal (CF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jb Jump if below (CF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jbe Jump if below or equal (CF == 1 or ZF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jc Jump if carry (CF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
JCXZ performs a short jump (with maximum range 128 bytes) if and
only if the contents of the CX register is 0. JECXZ does the
same thing, but with ECX.
je Jump if equal (ZF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jecxz Jump if ECX register is 0
JCXZ performs a short jump (with maximum range 128 bytes) if and
only if the contents of the CX register is 0. JECXZ does the
same thing, but with ECX.
jg Jump if greater (ZF == 0 and SF == OF)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jge Jump if greater or equal (SF == OF)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jl Jump if less (SF != OF)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jle Jump if less or equal (ZF == 1 or SF != OF)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jmp Jump Unconditionally
JMP jumps to a given address. The address may be specified as an
absolute segment and offset, or as a relative jump within the
current segment.
JMP SHORT imm has a maximum range of 128 bytes, since the
displacement is specified as only 8 bits, but takes up less code
space. NASM does not choose when to generate JMP SHORT for you:
you must explicitly code SHORT every time you want a short jump.
You can choose between the two immediate far jump forms (\c{JMP
imm:imm}) by the use of the WORD and DWORD keywords: \c{JMP
WORD 0x1234:0x5678}) or JMP DWORD 0x1234:0x56789abc.
The JMP FAR mem forms execute a far jump by loading the
destination address out of memory. The address loaded consists of 16
or 32 bits of offset (depending on the operand size), and 16 bits of
segment. The operand size may be overridden using \c{JMP WORD FAR
mem} or JMP DWORD FAR mem.
The JMP r/m forms execute a near jump (within the same
segment), loading the destination address out of memory or out of a
register. The keyword NEAR may be specified, for clarity, in
these forms, but is not necessary. Again, operand size can be
overridden using JMP WORD mem or JMP DWORD mem.
As a convenience, NASM does not require you to jump to a far symbol
by coding the cumbersome JMP SEG routine:routine, but instead
allows the easier synonym JMP FAR routine.
The JMP r/m forms given above are near calls; NASM will accept
the NEAR keyword (e.g. JMP NEAR [address]), even though it
is not strictly necessary.
jna Jump if not above (CF == 1 or ZF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jnae Jump if not above or equal (CF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jnb Jump if not below (CF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jnbe Jump if not below or equal (CF == 0 and ZF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jnc Jump if not carry (CF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jne Jump if not equal (ZF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jng Jump if not greater (ZF == 1 or SF != OF)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jnge Jump if not greater or equal (SF != OF)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jnl Jump if not less (SF == OF)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jnle Jump if not less or equal (ZF == 0 and SF == OF)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jno Jump if not overflow (OF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jnp Jump if not parity (PF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jns Jump if not sign (SF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jnz Jump if not zero (ZF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jo Jump if overflow (OF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jp Jump if parity (PF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jpe Jump if parity even (PF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jpo Jump if parity odd (PF == 0)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jrcxz Jump if RCX register is 0
JCXZ performs a short jump (with maximum range 128 bytes) if and
only if the contents of the CX register is 0. JECXZ does the
same thing, but with ECX.
js Jump if sign (SF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
jz Jump if zero (ZF == 1)
The conditional jump instructions execute a near (same segment)
jump if and only if their conditions are satisfied. For example,
JNZ jumps only if the zero flag is not set.
The ordinary form of the instructions has only a 128-byte range; the
NEAR form is a 386 extension to the instruction set, and can
span the full size of a segment. NASM will not override your choice
of jump instruction: if you want Jcc NEAR, you have to use the
NEAR keyword.
The SHORT keyword is allowed on the first form of the
instruction, for clarity, but is not necessary.
For details of the condition codes, see the condition codes.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
LOOP decrements its counter register (either CX or ECX -
if one is not specified explicitly, the BITS setting dictates
which is used) by one, and if the counter does not become zero as a
result of this operation, it jumps to the given label. The jump has
a range of 128 bytes.
LOOPE (or its synonym LOOPZ) adds the additional condition
that it only jumps if the counter is nonzero and the zero flag
is set. Similarly, LOOPNE (and LOOPNZ) jumps only if the
counter is nonzero and the zero flag is clear.
Conditional instructions
cmova Move if above (CF == 0 and ZF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovae Move if above or equal (CF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovb Move if below (CF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovbe Move if below or equal (CF == 1 or ZF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovc Move if carry (CF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmove Move if equal (ZF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovg Move if greater (ZF == 0 and SF == OF)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovge Move if greater or equal (SF == OF)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovl Move if less (SF != OF)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovle Move if less or equal (ZF == 1 or SF != OF)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovna Move if not above (CF == 1 or ZF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovnae Move if not above or equal (CF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovnb Move if not below (CF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovnbe Move if not below or equal (CF == 0 and ZF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovnc Move if not carry (CF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovne Move if not equal (ZF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovng Move if not greater (ZF == 1 or SF != OF)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovnge Move if not greater or equal (SF != OF)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovnl Move if not less (SF == OF)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovnle Move if not less or equal (ZF == 0 and SF == OF)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovno Move if not overflow (OF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovnp Move if not parity (PF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovns Move if not sign (SF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovnz Move if not zero (ZF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovo Move if overflow (OF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovp Move if parity (PF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovpe Move if parity even (PF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovpo Move if parity odd (PF == 0)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovs Move if sign (SF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
cmovz Move if zero (ZF == 1)
CMOV moves its source (second) operand into its destination
(first) operand if the given condition code is satisfied; otherwise
it does nothing.
For a list of condition codes, see the condition codes.
Although the CMOV instructions are flagged P6 and above, they
may not be supported by all Pentium Pro processors; the CPUID
instruction (CPUID) will return a bit which indicates whether
conditional moves are supported.
seta Set byte if above (CF == 0 and ZF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setae Set byte if above or equal (CF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setb Set byte if below (CF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setbe Set byte if below or equal (CF == 1 or ZF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setc Set byte if carry (CF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
sete Set byte if equal (ZF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setg Set byte if greater (ZF == 0 and SF == OF)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setge Set byte if greater or equal (SF == OF)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setl Set byte if less (SF != OF)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setle Set byte if less or equal (ZF == 1 or SF != OF)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setna Set byte if not above (CF == 1 or ZF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setnae Set byte if not above or equal (CF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setnb Set byte if not below (CF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setnbe Set byte if not below or equal (CF == 0 and ZF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setnc Set byte if not carry (CF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setne Set byte if not equal (ZF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setng Set byte if not greater (ZF == 1 or SF != OF)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setnge Set byte if not greater or equal (SF != OF)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setnl Set byte if not less (SF == OF)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setnle Set byte if not less or equal (ZF == 0 and SF == OF)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setno Set byte if not overflow (OF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setnp Set byte if not parity (PF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setns Set byte if not sign (SF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setnz Set byte if not zero (ZF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
seto Set byte if overflow (OF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setp Set byte if parity (PF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setpe Set byte if parity even (PF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setpo Set byte if parity odd (PF == 0)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
sets Set byte if sign (SF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
setz Set byte if zero (ZF == 1)
SETcc sets the given 8-bit operand to zero if its condition is
not satisfied, and to 1 if it is.
Call and return
call Call Procedure
CALL calls a subroutine, by means of pushing the current
instruction pointer (IP) and optionally CS as well on the
stack, and then jumping to a given address.
CS is pushed as well as IP if and only if the call is a far
call, i.e. a destination segment address is specified in the
instruction. The forms involving two colon-separated arguments are
far calls; so are the CALL FAR mem forms.
The immediate near call takes one of two forms (call imm16/imm32,
determined by the current segment size limit. For 16-bit operands,
you would use CALL 0x1234, and for 32-bit operands you would use
CALL 0x12345678. The value passed as an operand is a relative offset.
You can choose between the two immediate far call forms
(CALL imm:imm) by the use of the WORD and DWORD keywords:
CALL WORD 0x1234:0x5678) or CALL DWORD 0x1234:0x56789abc.
The CALL FAR mem forms execute a far call by loading the
destination address out of memory. The address loaded consists of 16
or 32 bits of offset (depending on the operand size), and 16 bits of
segment. The operand size may be overridden using \c{CALL WORD FAR
mem} or CALL DWORD FAR mem.
The CALL r/m forms execute a near call (within the same
segment), loading the destination address out of memory or out of a
register. The keyword NEAR may be specified, for clarity, in
these forms, but is not necessary. Again, operand size can be
overridden using CALL WORD mem or CALL DWORD mem.
As a convenience, NASM does not require you to call a far procedure
symbol by coding the cumbersome CALL SEG routine:routine, but
instead allows the easier synonym CALL FAR routine.
The CALL r/m forms given above are near calls; NASM will accept
the NEAR keyword (e.g. CALL NEAR [address]), even though it
is not strictly necessary.
ret Return from Procedure
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
-
RET, and its exact synonymRETN, popIPorEIPfrom the stack and transfer control to the new address. Optionally, if a numeric second operand is provided, they increment the stack pointer by a furtherimm16bytes after popping the return address. -
RETFexecutes a far return: after poppingIP/EIP, it then popsCS, and then increments the stack pointer by the optional argument if present.
Interrupts, system calls, and returns
INT1 and INT3 are short one-byte forms of the instructions
INT 1 and INT 3 (see INT). They perform a similar
function to their longer counterparts, but take up less code space.
They are used as breakpoints by debuggers.
-
INT1, and its alternative synonymsINT01andICEBP, is an instruction used by in-circuit emulators (ICEs). It is present, though not documented, on some processors down to the 286, but is only documented for the Pentium Pro.INT3is the instruction normally used as a breakpoint by debuggers. -
INT3, and its synonymINT03, is not precisely equivalent toINT 3: the short form, since it is designed to be used as a breakpoint, bypasses the normalIOPLchecks in virtual-8086 mode, and also does not go through interrupt redirection.
int Call to Interrupt Procedure
INT causes a software interrupt through a specified vector
number from 0 to 255.
The code generated by the INT instruction is always two bytes
long: although there are short forms for some INT instructions,
NASM does not generate them when it sees the INT mnemonic. In
order to generate single-byte breakpoint instructions, use the
INT3 or INT1 instructions (see INT1) instead.
INT1 and INT3 are short one-byte forms of the instructions
INT 1 and INT 3 (see INT). They perform a similar
function to their longer counterparts, but take up less code space.
They are used as breakpoints by debuggers.
-
INT1, and its alternative synonymsINT01andICEBP, is an instruction used by in-circuit emulators (ICEs). It is present, though not documented, on some processors down to the 286, but is only documented for the Pentium Pro.INT3is the instruction normally used as a breakpoint by debuggers. -
INT3, and its synonymINT03, is not precisely equivalent toINT 3: the short form, since it is designed to be used as a breakpoint, bypasses the normalIOPLchecks in virtual-8086 mode, and also does not go through interrupt redirection.
INT1 and INT3 are short one-byte forms of the instructions
INT 1 and INT 3 (see INT). They perform a similar
function to their longer counterparts, but take up less code space.
They are used as breakpoints by debuggers.
-
INT1, and its alternative synonymsINT01andICEBP, is an instruction used by in-circuit emulators (ICEs). It is present, though not documented, on some processors down to the 286, but is only documented for the Pentium Pro.INT3is the instruction normally used as a breakpoint by debuggers. -
INT3, and its synonymINT03, is not precisely equivalent toINT 3: the short form, since it is designed to be used as a breakpoint, bypasses the normalIOPLchecks in virtual-8086 mode, and also does not go through interrupt redirection.
INT1 and INT3 are short one-byte forms of the instructions
INT 1 and INT 3 (see INT). They perform a similar
function to their longer counterparts, but take up less code space.
They are used as breakpoints by debuggers.
-
INT1, and its alternative synonymsINT01andICEBP, is an instruction used by in-circuit emulators (ICEs). It is present, though not documented, on some processors down to the 286, but is only documented for the Pentium Pro.INT3is the instruction normally used as a breakpoint by debuggers. -
INT3, and its synonymINT03, is not precisely equivalent toINT 3: the short form, since it is designed to be used as a breakpoint, bypasses the normalIOPLchecks in virtual-8086 mode, and also does not go through interrupt redirection.
int3 Interrupt 3 (debug trap)
INT1 and INT3 are short one-byte forms of the instructions
INT 1 and INT 3 (see INT). They perform a similar
function to their longer counterparts, but take up less code space.
They are used as breakpoints by debuggers.
-
INT1, and its alternative synonymsINT01andICEBP, is an instruction used by in-circuit emulators (ICEs). It is present, though not documented, on some processors down to the 286, but is only documented for the Pentium Pro.INT3is the instruction normally used as a breakpoint by debuggers. -
INT3, and its synonymINT03, is not precisely equivalent toINT 3: the short form, since it is designed to be used as a breakpoint, bypasses the normalIOPLchecks in virtual-8086 mode, and also does not go through interrupt redirection.
INTO performs an INT 4 software interrupt (see INT)
if and only if the overflow flag is set.
IRET returns from an interrupt (hardware or software) by means
of popping IP (or EIP), CS and the flags off the stack
and then continuing execution from the new CS:IP.
IRETW pops IP, CS and the flags as 2 bytes each, taking
6 bytes off the stack in total. IRETD pops EIP as 4 bytes,
pops a further 4 bytes of which the top two are discarded and the
bottom two go into CS, and pops the flags as 4 bytes as well,
taking 12 bytes off the stack.
IRET is a shorthand for either IRETW or IRETD, depending
on the default BITS setting at the time.
IRET returns from an interrupt (hardware or software) by means
of popping IP (or EIP), CS and the flags off the stack
and then continuing execution from the new CS:IP.
IRETW pops IP, CS and the flags as 2 bytes each, taking
6 bytes off the stack in total. IRETD pops EIP as 4 bytes,
pops a further 4 bytes of which the top two are discarded and the
bottom two go into CS, and pops the flags as 4 bytes as well,
taking 12 bytes off the stack.
IRET is a shorthand for either IRETW or IRETD, depending
on the default BITS setting at the time.
IRET returns from an interrupt (hardware or software) by means
of popping IP (or EIP), CS and the flags off the stack
and then continuing execution from the new CS:IP.
IRETW pops IP, CS and the flags as 2 bytes each, taking
6 bytes off the stack in total. IRETD pops EIP as 4 bytes,
pops a further 4 bytes of which the top two are discarded and the
bottom two go into CS, and pops the flags as 4 bytes as well,
taking 12 bytes off the stack.
IRET is a shorthand for either IRETW or IRETD, depending
on the default BITS setting at the time.
IRET returns from an interrupt (hardware or software) by means
of popping IP (or EIP), CS and the flags off the stack
and then continuing execution from the new CS:IP.
IRETW pops IP, CS and the flags as 2 bytes each, taking
6 bytes off the stack in total. IRETD pops EIP as 4 bytes,
pops a further 4 bytes of which the top two are discarded and the
bottom two go into CS, and pops the flags as 4 bytes as well,
taking 12 bytes off the stack.
IRET is a shorthand for either IRETW or IRETD, depending
on the default BITS setting at the time.
syscall Fast System Call
Asks the operating system to do something. rax holds the call number, the arguments go in rdi, rsi, rdx, r10, r8 and r9 in that order, and the result comes back in rax, with a small negative number meaning an error. rcx and r11 are destroyed by the call itself, so anything kept in them has to be saved first.
Programs here run as Linux programs, so this is the only way a program reaches the console or the file system. The syscall page lists the calls this emulator implements.
SYSENTER executes a fast call to a level 0 system procedure or
routine. Before using this instruction, various MSRs need to be set
up:
-
SYSENTER_CS_MSRcontains the 32-bit segment selector for the privilege level 0 code segment. (This value is also used to compute the segment selector of the privilege level 0 stack segment.) -
SYSENTER_EIP_MSRcontains the 32-bit offset into the privilege level 0 code segment to the first instruction of the selected operating procedure or routine. -
SYSENTER_ESP_MSRcontains the 32-bit stack pointer for the privilege level 0 stack.
SYSENTER performs the following sequence of operations:
-
Loads the segment selector from the
SYSENTER_CS_MSRinto theCSregister. -
Loads the instruction pointer from the
SYSENTER_EIP_MSRinto theEIPregister. -
Adds 8 to the value in
SYSENTER_CS_MSRand loads it into theSSregister. -
Loads the stack pointer from the
SYSENTER_ESP_MSRinto theESPregister. -
Switches to privilege level 0.
-
Clears the
VMflag in theEFLAGSregister, if the flag is set. -
Begins executing the selected system procedure.
In particular, note that this instruction des not save the values of
CS or (E)IP. If you need to return to the calling code, you
need to write your code to cater for this.
For more information, see the Intel Architecture Software Developer's Manual, Volume 2.
SYSEXIT executes a fast return to privilege level 3 user code.
This instruction is a companion instruction to the SYSENTER
instruction, and can only be executed by privilege level 0 code.
Various registers need to be set up before calling this instruction:
-
SYSENTER_CS_MSRcontains the 32-bit segment selector for the privilege level 0 code segment in which the processor is currently executing. (This value is used to compute the segment selectors for the privilege level 3 code and stack segments.) -
EDXcontains the 32-bit offset into the privilege level 3 code segment to the first instruction to be executed in the user code. -
ECXcontains the 32-bit stack pointer for the privilege level 3 stack.
SYSEXIT performs the following sequence of operations:
-
Adds 16 to the value in
SYSENTER_CS_MSRand loads the sum into theCSselector register. -
Loads the instruction pointer from the
EDXregister into theEIPregister. -
Adds 24 to the value in
SYSENTER_CS_MSRand loads the sum into theSSselector register. -
Loads the stack pointer from the
ECXregister into theESPregister. -
Switches to privilege level 3.
-
Begins executing the user code at the
EIPaddress.
For more information on the use of the SYSENTER and SYSEXIT
instructions, see the Intel Architecture Software Developer's
Manual, Volume 2.
SYSRET is the return instruction used in conjunction with the
SYSCALL instruction to provide fast entry/exit to an operating system.
-
The
ECXregister, which points to the next sequential instruction after the correspondingSYSCALLinstruction, is copied into theEIPregister. -
Bits [63-48] of the
STARregister specify the selector that is copied into theCSregister. -
Bits [63-48]+1000b of the
STARregister specify the selector that is copied into theSSregister. -
Bits [1-0] of the
SSregister are set to 11b (RPL of 3) regardless of the value of bits [49-48] of theSTARregister.
The CS and SS registers should not be modified by the operating
system between the execution of the SYSCALL instruction and its
corresponding SYSRET instruction.
For more information, see the SYSCALL and SYSRET Instruction Specification
(AMD document number 21086.pdf).
Flag register instructions
clc Clear Carry Flag
These instructions clear various flags. CLC clears the carry
flag; CLD clears the direction flag; CLI clears the
interrupt flag (thus disabling interrupts); and CLTS clears the
task-switched (TS) flag in CR0.
To set the carry, direction, or interrupt flags, use the STC,
STD and STI instructions (STC). To invert the carry
flag, use CMC (CMC).
cld Clear Direction Flag
These instructions clear various flags. CLC clears the carry
flag; CLD clears the direction flag; CLI clears the
interrupt flag (thus disabling interrupts); and CLTS clears the
task-switched (TS) flag in CR0.
To set the carry, direction, or interrupt flags, use the STC,
STD and STI instructions (STC). To invert the carry
flag, use CMC (CMC).
These instructions clear various flags. CLC clears the carry
flag; CLD clears the direction flag; CLI clears the
interrupt flag (thus disabling interrupts); and CLTS clears the
task-switched (TS) flag in CR0.
To set the carry, direction, or interrupt flags, use the STC,
STD and STI instructions (STC). To invert the carry
flag, use CMC (CMC).
cmc Complement Carry Flag
CMC changes the value of the carry flag: if it was 0, it sets it
to 1, and vice versa.
lahf Load AH from Flags
LAHF sets the AH register according to the contents of the
low byte of the flags word.
The operation of LAHF is:
AH <-- SF:ZF:0:AF:0:PF:1:CF
See also SAHF (SAHF).
-
POPFWpops a word from the stack and stores it in the bottom 16 bits of the flags register (or the whole flags register, on processors below a 386). -
POPFDpops a doubleword and stores it in the entire flags register.
POPF is an alias mnemonic for either POPFW or POPFD,
depending on the current BITS setting.
See also PUSHF (PUSHF).
-
POPFWpops a word from the stack and stores it in the bottom 16 bits of the flags register (or the whole flags register, on processors below a 386). -
POPFDpops a doubleword and stores it in the entire flags register.
POPF is an alias mnemonic for either POPFW or POPFD,
depending on the current BITS setting.
See also PUSHF (PUSHF).
-
POPFWpops a word from the stack and stores it in the bottom 16 bits of the flags register (or the whole flags register, on processors below a 386). -
POPFDpops a doubleword and stores it in the entire flags register.
POPF is an alias mnemonic for either POPFW or POPFD,
depending on the current BITS setting.
See also PUSHF (PUSHF).
-
POPFWpops a word from the stack and stores it in the bottom 16 bits of the flags register (or the whole flags register, on processors below a 386). -
POPFDpops a doubleword and stores it in the entire flags register.
POPF is an alias mnemonic for either POPFW or POPFD,
depending on the current BITS setting.
See also PUSHF (PUSHF).
-
PUSHFWpushes the bottom 16 bits of the flags register (or the whole flags register, on processors below a 386) onto the stack. -
PUSHFDpushes the entire flags register onto the stack.
PUSHF is an alias mnemonic for either PUSHFW or PUSHFD,
depending on the current BITS setting.
See also POPF (POPF).
-
PUSHFWpushes the bottom 16 bits of the flags register (or the whole flags register, on processors below a 386) onto the stack. -
PUSHFDpushes the entire flags register onto the stack.
PUSHF is an alias mnemonic for either PUSHFW or PUSHFD,
depending on the current BITS setting.
See also POPF (POPF).
-
PUSHFWpushes the bottom 16 bits of the flags register (or the whole flags register, on processors below a 386) onto the stack. -
PUSHFDpushes the entire flags register onto the stack.
PUSHF is an alias mnemonic for either PUSHFW or PUSHFD,
depending on the current BITS setting.
See also POPF (POPF).
-
PUSHFWpushes the bottom 16 bits of the flags register (or the whole flags register, on processors below a 386) onto the stack. -
PUSHFDpushes the entire flags register onto the stack.
PUSHF is an alias mnemonic for either PUSHFW or PUSHFD,
depending on the current BITS setting.
See also POPF (POPF).
sahf Store AH into Flags
SAHF sets the low byte of the flags word according to the
contents of the AH register.
The operation of SAHF is:
AH --> SF:ZF:0:AF:0:PF:1:CF
See also LAHF (LAHF).
SALC is an early undocumented instruction similar in concept to
SETcc (SETcc). Its function is to set AL to zero if
the carry flag is clear, or to 0xFF if it is set.
stc Set Carry Flag
These instructions set various flags. STC sets the carry flag;
STD sets the direction flag; and STI sets the interrupt flag
(thus enabling interrupts).
To clear the carry, direction, or interrupt flags, use the CLC,
CLD and CLI instructions (CLC). To invert the carry
flag, use CMC (CMC).
std Set Direction Flag
These instructions set various flags. STC sets the carry flag;
STD sets the direction flag; and STI sets the interrupt flag
(thus enabling interrupts).
To clear the carry, direction, or interrupt flags, use the CLC,
CLD and CLI instructions (CLC). To invert the carry
flag, use CMC (CMC).
These instructions set various flags. STC sets the carry flag;
STD sets the direction flag; and STI sets the interrupt flag
(thus enabling interrupts).
To clear the carry, direction, or interrupt flags, use the CLC,
CLD and CLI instructions (CLC). To invert the carry
flag, use CMC (CMC).
String instructions
CMPSB compares the byte at [DS:SI] or [DS:ESI] with the
byte at [ES:DI] or [ES:EDI], and sets the flags accordingly.
It then increments or decrements (depending on the direction flag:
increments if the flag is clear, decrements if it is set) SI and
DI (or ESI and EDI).
The registers used are SI and DI if the address size is 16
bits, and ESI and EDI if it is 32 bits. If you need to use
an address size not equal to the current BITS setting, you can
use an explicit a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, ES CMPSB). The use of ES for the load from [DI]
or [EDI] cannot be overridden.
CMPSW and CMPSD work in the same way, but they compare a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and
REPNZ) may be used to repeat the instruction up to CX (or
ECX - again, the address size chooses which) times until the
first unequal or equal byte is found.
cmpsd Compare Scalar Double-Precision Floating-Point Values
CMPSB compares the byte at [DS:SI] or [DS:ESI] with the
byte at [ES:DI] or [ES:EDI], and sets the flags accordingly.
It then increments or decrements (depending on the direction flag:
increments if the flag is clear, decrements if it is set) SI and
DI (or ESI and EDI).
The registers used are SI and DI if the address size is 16
bits, and ESI and EDI if it is 32 bits. If you need to use
an address size not equal to the current BITS setting, you can
use an explicit a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, ES CMPSB). The use of ES for the load from [DI]
or [EDI] cannot be overridden.
CMPSW and CMPSD work in the same way, but they compare a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and
REPNZ) may be used to repeat the instruction up to CX (or
ECX - again, the address size chooses which) times until the
first unequal or equal byte is found.
CMPSB compares the byte at [DS:SI] or [DS:ESI] with the
byte at [ES:DI] or [ES:EDI], and sets the flags accordingly.
It then increments or decrements (depending on the direction flag:
increments if the flag is clear, decrements if it is set) SI and
DI (or ESI and EDI).
The registers used are SI and DI if the address size is 16
bits, and ESI and EDI if it is 32 bits. If you need to use
an address size not equal to the current BITS setting, you can
use an explicit a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, ES CMPSB). The use of ES for the load from [DI]
or [EDI] cannot be overridden.
CMPSW and CMPSD work in the same way, but they compare a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and
REPNZ) may be used to repeat the instruction up to CX (or
ECX - again, the address size chooses which) times until the
first unequal or equal byte is found.
CMPSB compares the byte at [DS:SI] or [DS:ESI] with the
byte at [ES:DI] or [ES:EDI], and sets the flags accordingly.
It then increments or decrements (depending on the direction flag:
increments if the flag is clear, decrements if it is set) SI and
DI (or ESI and EDI).
The registers used are SI and DI if the address size is 16
bits, and ESI and EDI if it is 32 bits. If you need to use
an address size not equal to the current BITS setting, you can
use an explicit a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, ES CMPSB). The use of ES for the load from [DI]
or [EDI] cannot be overridden.
CMPSW and CMPSD work in the same way, but they compare a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and
REPNZ) may be used to repeat the instruction up to CX (or
ECX - again, the address size chooses which) times until the
first unequal or equal byte is found.
INSB inputs a byte from the I/O port specified in DX and
stores it at [ES:DI] or [ES:EDI]. It then increments or
decrements (depending on the direction flag: increments if the flag
is clear, decrements if it is set) DI or EDI.
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the load from [DI] or [EDI] cannot be
overridden.
INSW and INSD work in the same way, but they input a word or
a doubleword instead of a byte, and increment or decrement the
addressing register by 2 or 4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
See also OUTSB, OUTSW and OUTSD (OUTSB).
INSB inputs a byte from the I/O port specified in DX and
stores it at [ES:DI] or [ES:EDI]. It then increments or
decrements (depending on the direction flag: increments if the flag
is clear, decrements if it is set) DI or EDI.
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the load from [DI] or [EDI] cannot be
overridden.
INSW and INSD work in the same way, but they input a word or
a doubleword instead of a byte, and increment or decrement the
addressing register by 2 or 4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
See also OUTSB, OUTSW and OUTSD (OUTSB).
INSB inputs a byte from the I/O port specified in DX and
stores it at [ES:DI] or [ES:EDI]. It then increments or
decrements (depending on the direction flag: increments if the flag
is clear, decrements if it is set) DI or EDI.
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the load from [DI] or [EDI] cannot be
overridden.
INSW and INSD work in the same way, but they input a word or
a doubleword instead of a byte, and increment or decrement the
addressing register by 2 or 4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
See also OUTSB, OUTSW and OUTSD (OUTSB).
LODSB loads a byte from [DS:SI] or [DS:ESI] into AL.
It then increments or decrements (depending on the direction flag:
increments if the flag is clear, decrements if it is set) SI or
ESI.
The register used is SI if the address size is 16 bits, and
ESI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, ES LODSB).
LODSW and LODSD work in the same way, but they load a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
LODSB loads a byte from [DS:SI] or [DS:ESI] into AL.
It then increments or decrements (depending on the direction flag:
increments if the flag is clear, decrements if it is set) SI or
ESI.
The register used is SI if the address size is 16 bits, and
ESI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, ES LODSB).
LODSW and LODSD work in the same way, but they load a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
LODSB loads a byte from [DS:SI] or [DS:ESI] into AL.
It then increments or decrements (depending on the direction flag:
increments if the flag is clear, decrements if it is set) SI or
ESI.
The register used is SI if the address size is 16 bits, and
ESI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, ES LODSB).
LODSW and LODSD work in the same way, but they load a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
LODSB loads a byte from [DS:SI] or [DS:ESI] into AL.
It then increments or decrements (depending on the direction flag:
increments if the flag is clear, decrements if it is set) SI or
ESI.
The register used is SI if the address size is 16 bits, and
ESI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, ES LODSB).
LODSW and LODSD work in the same way, but they load a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
MOVSB copies the byte at [DS:SI] or [DS:ESI] to
[ES:DI] or [ES:EDI]. It then increments or decrements
(depending on the direction flag: increments if the flag is clear,
decrements if it is set) SI and DI (or ESI and EDI).
The registers used are SI and DI if the address size is 16
bits, and ESI and EDI if it is 32 bits. If you need to use
an address size not equal to the current BITS setting, you can
use an explicit a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, es movsb). The use of ES for the store to [DI]
or [EDI] cannot be overridden.
MOVSW and MOVSD work in the same way, but they copy a word
or a doubleword instead of a byte, and increment or decrement the
addressing registers by 2 or 4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
MOVSB copies the byte at [DS:SI] or [DS:ESI] to
[ES:DI] or [ES:EDI]. It then increments or decrements
(depending on the direction flag: increments if the flag is clear,
decrements if it is set) SI and DI (or ESI and EDI).
The registers used are SI and DI if the address size is 16
bits, and ESI and EDI if it is 32 bits. If you need to use
an address size not equal to the current BITS setting, you can
use an explicit a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, es movsb). The use of ES for the store to [DI]
or [EDI] cannot be overridden.
MOVSW and MOVSD work in the same way, but they copy a word
or a doubleword instead of a byte, and increment or decrement the
addressing registers by 2 or 4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
MOVSB copies the byte at [DS:SI] or [DS:ESI] to
[ES:DI] or [ES:EDI]. It then increments or decrements
(depending on the direction flag: increments if the flag is clear,
decrements if it is set) SI and DI (or ESI and EDI).
The registers used are SI and DI if the address size is 16
bits, and ESI and EDI if it is 32 bits. If you need to use
an address size not equal to the current BITS setting, you can
use an explicit a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, es movsb). The use of ES for the store to [DI]
or [EDI] cannot be overridden.
MOVSW and MOVSD work in the same way, but they copy a word
or a doubleword instead of a byte, and increment or decrement the
addressing registers by 2 or 4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
OUTSB loads a byte from [DS:SI] or [DS:ESI] and writes
it to the I/O port specified in DX. It then increments or
decrements (depending on the direction flag: increments if the flag
is clear, decrements if it is set) SI or ESI.
The register used is SI if the address size is 16 bits, and
ESI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, es outsb).
OUTSW and OUTSD work in the same way, but they output a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
OUTSB loads a byte from [DS:SI] or [DS:ESI] and writes
it to the I/O port specified in DX. It then increments or
decrements (depending on the direction flag: increments if the flag
is clear, decrements if it is set) SI or ESI.
The register used is SI if the address size is 16 bits, and
ESI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, es outsb).
OUTSW and OUTSD work in the same way, but they output a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
OUTSB loads a byte from [DS:SI] or [DS:ESI] and writes
it to the I/O port specified in DX. It then increments or
decrements (depending on the direction flag: increments if the flag
is clear, decrements if it is set) SI or ESI.
The register used is SI if the address size is 16 bits, and
ESI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
The segment register used to load from [SI] or [ESI] can be
overridden by using a segment register name as a prefix (for
example, es outsb).
OUTSW and OUTSD work in the same way, but they output a
word or a doubleword instead of a byte, and increment or decrement
the addressing registers by 2 or 4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
SCASB compares the byte in AL with the byte at [ES:DI]
or [ES:EDI], and sets the flags accordingly. It then increments
or decrements (depending on the direction flag: increments if the
flag is clear, decrements if it is set) DI (or EDI).
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the load from [DI] or [EDI] cannot be
overridden.
SCASW and SCASD work in the same way, but they compare a
word to AX or a doubleword to EAX instead of a byte to
AL, and increment or decrement the addressing registers by 2 or
4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and
REPNZ) may be used to repeat the instruction up to CX (or
ECX - again, the address size chooses which) times until the
first unequal or equal byte is found.
SCASB compares the byte in AL with the byte at [ES:DI]
or [ES:EDI], and sets the flags accordingly. It then increments
or decrements (depending on the direction flag: increments if the
flag is clear, decrements if it is set) DI (or EDI).
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the load from [DI] or [EDI] cannot be
overridden.
SCASW and SCASD work in the same way, but they compare a
word to AX or a doubleword to EAX instead of a byte to
AL, and increment or decrement the addressing registers by 2 or
4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and
REPNZ) may be used to repeat the instruction up to CX (or
ECX - again, the address size chooses which) times until the
first unequal or equal byte is found.
SCASB compares the byte in AL with the byte at [ES:DI]
or [ES:EDI], and sets the flags accordingly. It then increments
or decrements (depending on the direction flag: increments if the
flag is clear, decrements if it is set) DI (or EDI).
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the load from [DI] or [EDI] cannot be
overridden.
SCASW and SCASD work in the same way, but they compare a
word to AX or a doubleword to EAX instead of a byte to
AL, and increment or decrement the addressing registers by 2 or
4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and
REPNZ) may be used to repeat the instruction up to CX (or
ECX - again, the address size chooses which) times until the
first unequal or equal byte is found.
SCASB compares the byte in AL with the byte at [ES:DI]
or [ES:EDI], and sets the flags accordingly. It then increments
or decrements (depending on the direction flag: increments if the
flag is clear, decrements if it is set) DI (or EDI).
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the load from [DI] or [EDI] cannot be
overridden.
SCASW and SCASD work in the same way, but they compare a
word to AX or a doubleword to EAX instead of a byte to
AL, and increment or decrement the addressing registers by 2 or
4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and
REPNZ) may be used to repeat the instruction up to CX (or
ECX - again, the address size chooses which) times until the
first unequal or equal byte is found.
STOSB stores the byte in AL at [ES:DI] or [ES:EDI],
and sets the flags accordingly. It then increments or decrements
(depending on the direction flag: increments if the flag is clear,
decrements if it is set) DI (or EDI).
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the store to [DI] or [EDI] cannot be
overridden.
STOSW and STOSD work in the same way, but they store the
word in AX or the doubleword in EAX instead of the byte in
AL, and increment or decrement the addressing registers by 2 or
4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
STOSB stores the byte in AL at [ES:DI] or [ES:EDI],
and sets the flags accordingly. It then increments or decrements
(depending on the direction flag: increments if the flag is clear,
decrements if it is set) DI (or EDI).
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the store to [DI] or [EDI] cannot be
overridden.
STOSW and STOSD work in the same way, but they store the
word in AX or the doubleword in EAX instead of the byte in
AL, and increment or decrement the addressing registers by 2 or
4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
STOSB stores the byte in AL at [ES:DI] or [ES:EDI],
and sets the flags accordingly. It then increments or decrements
(depending on the direction flag: increments if the flag is clear,
decrements if it is set) DI (or EDI).
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the store to [DI] or [EDI] cannot be
overridden.
STOSW and STOSD work in the same way, but they store the
word in AX or the doubleword in EAX instead of the byte in
AL, and increment or decrement the addressing registers by 2 or
4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
STOSB stores the byte in AL at [ES:DI] or [ES:EDI],
and sets the flags accordingly. It then increments or decrements
(depending on the direction flag: increments if the flag is clear,
decrements if it is set) DI (or EDI).
The register used is DI if the address size is 16 bits, and
EDI if it is 32 bits. If you need to use an address size not
equal to the current BITS setting, you can use an explicit
a16 or a32 prefix.
Segment override prefixes have no effect for this instruction: the
use of ES for the store to [DI] or [EDI] cannot be
overridden.
STOSW and STOSD work in the same way, but they store the
word in AX or the doubleword in EAX instead of the byte in
AL, and increment or decrement the addressing registers by 2 or
4 instead of 1.
The REP prefix may be used to repeat the instruction CX (or
ECX - again, the address size chooses which) times.
No operation
nop No Operation
NOP performs no operation. Its opcode is the same as that
generated by XCHG AX,AX or XCHG EAX,EAX (depending on the
processor mode; see XCHG).
Extensions
Everything else the assembler accepts, under the heading NASM files it under. These have no page of their own: the only description of them we are free to publish is the one line below, and blink implements a part of them.
RAO-INT weakly ordered atomic operations
aaddaandaoraxorInterleaved flags arithmetic
adcxadoxAVX-512 mask register instructions
addbadddaddqaddwandbanddandnbandndandnqandnwandqandwkaddkaddbkadddkaddqkaddwkandkandbkanddkandnkandnbkandndkandnqkandnwkandqkandwkmovkmovbkmovdkmovqkmovwknotknotbknotdknotqknotwkorkorbkordkorqkortestkortestbkortestdkortestqkortestwkorwkshiftlkshiftlbkshiftldkshiftlqkshiftlwkshiftrkshiftrbkshiftrdkshiftrqkshiftrwkshlkshlbkshldkshlqkshlwkshrkshrbkshrdkshrqkshrwktestktestbktestdktestqktestwkunpckkunpckbwkunpckdkunpckdqkunpckqkunpckwkunpckwdkxnorkxnorbkxnordkxnorqkxnorwkxorkxorbkxordkxorqkxorwmovbmovwnotbnotdnotqnotworbordorqortestortestbortestdortestqortestworwshiftlshiftlbshiftldshiftlqshiftlwshiftrshiftrbshiftrdshiftrqshiftrwshlbshlqshlwshrbshrqshrwtestbtestdtestqtestwunpckunpckbwunpckdunpckdqunpckqunpckwunpckwdxnorxnorbxnordxnorqxnorwxorbxordxorqxorwWillamette Streaming SIMD instructions (SSE2)
addpdaddsdandnpdandpdcmpeqpdcmpeqsdcmplepdcmplesdcmpltpdcmpltsdcmpneqpdcmpneqsdcmpnlepdcmpnlesdcmpnltpdcmpnltsdcmpordpdcmpordsdcmppdcmpunordpdcmpunordsdcomisdcvtdq2pdcvtdq2pscvtpd2dqcvtpd2picvtpd2pscvtpi2pdcvtps2dqcvtps2pdcvtsd2sicvtsd2sscvtsi2sdcvtss2sdcvttpd2dqcvttpd2picvttps2dqcvttsd2sidivpddivsdmaxpdmaxsdminpdminsdmovapdmovhpdmovlpdmovmskpdmovsdmovupdmulpdmulsdorpdshufpdsqrtpdsqrtsdsubpdsubsducomisdunpckhpdunpcklpdxorpdKatmai Streaming SIMD instructions (SSE -- a.k.a. KNI, XMM, MMX2)
addpsaddssandnpsandpscmpeqpscmpeqsscmplepscmplesscmpltpscmpltsscmpneqpscmpneqsscmpnlepscmpnlesscmpnltpscmpnltsscmpordpscmpordsscmppscmpsscmpunordpscmpunordsscomisscvtpi2pscvtps2picvtsi2sscvtss2sicvttps2picvttss2sidivpsdivssldmxcsrmaxpsmaxssminpsminssmovapsmovhlpsmovhpsmovlhpsmovlpsmovmskpsmovntpsmovssmovupsmulpsmulssorpsrcppsrcpssrsqrtpsrsqrtssshufpssqrtpssqrtssstmxcsrsubpssubssucomissunpckhpsunpcklpsxorpsPrescott New Instructions (SSE3)
addsubpdaddsubpshaddpdhaddpshsubpdhsubpslddqumovddupmovshdupmovsldupIntel AES instructions
aesdecaesdeclastaesencaesenclastaesimcaeskeygenassistIntel AES Key Locker
aesdec128klaesdec256klaesdecwide128klaesdecwide256klaesenc128klaesenc256klaesencwide128klaesencwide256klencodekey128encodekey256loadiwkeyBMI1 and BMI2 bit operations
andnbextrblsiblsmskblsrbzhilzcntpdeppexttzcntSegment handling instructions
arpllarldsleslfslgdtlgslidtlkgslldtloadallloadall286lsllssltrrdfsbaserdgsbasesgdtsidtsldtstrswapgsverrverwwrfsbasewrgsbaseMachine control and management instructions
bb0_resetbb1_resetcltscpu_readcpu_writecpuiddmintlmswrdmrdmsrrdmsrlistsmintsmintoldsmswumovurdmsruwrmsrwrmsrwrmsrlistwrmsrnsAMD XOP bit operations
blcfillblciblcicblcmskblcsblsfillblsict1mskctzmskPenryn New Instructions (SSE4.1)
blendpdblendpsblendvpdblendvpsdppddppsextractpsinsertpsmovntdqampsadbwpackusdwpblendvbpblendwpcmpeqqpextrbpextrdpextrqpextrwphminposuwpinsrbpinsrdpinsrqpmaxsbpmaxsdpmaxudpmaxuwpminsbpminsdpminudpminuwpmovsxbdpmovsxbqpmovsxbwpmovsxdqpmovsxwdpmovsxwqpmovzxbdpmovzxbqpmovzxbwpmovzxdqpmovzxwdpmovzxwqpmuldqpmulldptestroundpdroundpsroundsdroundssIntel Memory Protection Extensions (MPX)
bndclbndcnbndcubndldxbndmkbndmovbndstxPermanently undefined instructions
ccmpccmpaccmpaeccmpbccmpbeccmpcccmpeccmpfccmpgccmpgeccmplccmpleccmpnaccmpnaeccmpnbccmpnbeccmpncccmpneccmpngccmpngeccmpnlccmpnleccmpnoccmpnsccmpnzccmpoccmpsccmptccmpzctestctestactestaectestbctestbectestcctestectestfctestgctestgectestlctestlectestnactestnaectestnbctestnbectestncctestnectestngctestngectestnlctestnlectestnoctestnsctestnzctestoctestsctesttctestzfwaitud0ud1ud2ud2aud2budbxlatxlatbdoc 319433-034 May 2018
cldemotemovdir64bmovdiripconfigMemory management and control
clflushclflushoptclwbclzeroinvdinvlpginvlpgainvpcidpcommitwbinvdwbnoinvdVMX/SVM Instructions
clgistgivmcallvmclearvmfuncvmlaunchvmloadvmmcallvmptrldvmptrstvmreadvmresumevmrunvmsavevmwritevmxoffvmxonIntel Control-Flow Enforcement Technology (CET)
clrssbsyendbr32endbr64incsspdincsspqrdsspdrdsspqrstorsspsaveprevsspsetssbsywrssdwrssqwrussdwrussqUser interrupts
cluisenduipistuitestuiuiretNehalem New Instructions (SSE4.2)
crc32pcmpestripcmpestrmpcmpgtqpcmpistripcmpistrmpopcntMMX (SIMD using the x87 register file)
emmsmovdpackssdwpacksswbpackuswbpaddbpadddpaddsbpaddsiwpaddswpaddusbpadduswpaddwpandpandnpavebpavgusbpcmpeqbpcmpeqdpcmpeqwpcmpgtbpcmpgtdpcmpgtwpdistibpf2idpfaccpfaddpfcmpeqpfcmpgepfcmpgtpfmaxpfminpfmulpfrcppfrcpit1pfrcpit2pfrsqit1pfrsqrtpfsubpfsubrpi2fdpmachriwpmaddwdpmagwpmulhriwpmulhrwapmulhrwcpmulhwpmullwpmvgezbpmvlzbpmvnzbpmvzbporprefetchprefetchwpslldpsllqpsllwpsradpsrawpsrldpsrlqpsrlwpsubbpsubdpsubsbpsubsiwpsubswpsubusbpsubuswpsubwpunpckhbwpunpckhdqpunpckhwdpunpcklbwpunpckldqpunpcklwdIntel Software Guard Extensions (SGX)
enclsencluenclvInstructions from ISE doc 319433-040, June 2020
enqcmdenqcmdsxresldtrkxsusldtrkAMD SSE4A
extrqinsertqmovntsdmovntssx87 floating point
f2xm1fabsfaddfaddpfbldfbstpfchsfclexfcmovbfcmovbefcmovefcmovnbfcmovnbefcmovnefcmovnufcmovufcomfcomifcomipfcompfcomppfcosfdecstpfdisifdivfdivpfdivrfdivrpfemmsfeniffreeffreepfiaddficomficompfidivfidivrfildfimulfincstpfinitfistfistpfisttpfisubfisubrfldfld1fldcwfldenvfldl2efldl2tfldlg2fldln2fldpifldzfmulfmulpfnclexfndisifnenifninitfnopfnsavefnstcwfnstenvfnstswfpatanfpremfprem1fptanfrndintfrstorfsavefscalefsetpmfsinfsincosfsqrtfstfstcwfstenvfstpfstswfsubfsubpfsubrfsubrpftstfucomfucomifucomipfucompfucomppfxamfxchfxtractfyl2xfyl2xp1Introduced in Deschutes but necessary for SSE support
fxrstorfxrstor64fxsavefxsave64Intel SMX
getsecGalois field operations (GFNI)
gf2p8affineinvqbgf2p8affineqbgf2p8mulbvgf2p8affineinvqbvgf2p8affineqbvgf2p8mulbSystematic names for the hinting nop instructions
hint_nophint_nop0hint_nop1hint_nop10hint_nop11hint_nop12hint_nop13hint_nop14hint_nop15hint_nop16hint_nop17hint_nop18hint_nop19hint_nop2hint_nop20hint_nop21hint_nop22hint_nop23hint_nop24hint_nop25hint_nop26hint_nop27hint_nop28hint_nop29hint_nop3hint_nop30hint_nop31hint_nop32hint_nop33hint_nop34hint_nop35hint_nop36hint_nop37hint_nop38hint_nop39hint_nop4hint_nop40hint_nop41hint_nop42hint_nop43hint_nop44hint_nop45hint_nop46hint_nop47hint_nop48hint_nop49hint_nop5hint_nop50hint_nop51hint_nop52hint_nop53hint_nop54hint_nop55hint_nop56hint_nop57hint_nop58hint_nop59hint_nop6hint_nop60hint_nop61hint_nop62hint_nop63hint_nop7hint_nop8hint_nop9Power management
hltmonitormonitordmonitorqmonitorwmonitorxmwaitmwaitxpausetpauseumonitorumwaitHistory reset
hresetI/O instructions
inoutExtended Page Tables VMX instructions
inveptinvvpidIntel Advanced Matrix Extensions (AMX)
ldtilecfgsttilecfgt2rpntlvwz0t2rpntlvwz0rst2rpntlvwz0rst1t2rpntlvwz0t1t2rpntlvwz1t2rpntlvwz1rst2rpntlvwz1rst1t2rpntlvwz1t1tcmmimfp16pstcmmrlfp16pstconjtcmmimfp16pstconjtfp16tcvtrowd2pstcvtrowps2bf16htcvtrowps2bf16ltcvtrowps2phhtcvtrowps2phltdpbf16pstdpbf8pstdpbhf8pstdpbssdtdpbsudtdpbusdtdpbuudtdpfp16pstdphbf8pstdphf8pstileloaddtileloaddrstileloaddrst1tileloaddt1tilemovrowtilereleasetilestoredtilezerotmmultf32psttcmmimfp16psttcmmrlfp16psttdpbf16psttdpfp16psttmmultf32psttransposedSynchronization and fencing
lfencemfenceserializesfenceAMD Lightweight Profiling (LWP) instructions
llwpcblwpinslwpvalslwpcbWillamette SSE2 Cacheability Instructions
maskmovdqumovntdqmovntimovntpdNew MMX instructions introduced in Katmai
maskmovqmovntqpavgbpavgwpmaxswpmaxubpminswpminubpmovmskbpmulhuwpsadbwpshufwVIA (Centaur) security instructions
montmulxcryptcbcxcryptcfbxcryptctrxcryptecbxcryptofbxsha1xsha256xstoreWillamette MMX instructions (SSE2 SIMD Integer Instructions)
movdq2qmovdqamovdqumovqmovq2dqpaddqpinsrwpmuludqpshufdpshufhwpshuflwpslldqpsrldqpsubqpunpckhqdqpunpcklqdqTejas New Instructions (SSSE3)
pabsbpabsdpabswpalignrphadddphaddswphaddwphsubdphsubswphsubwpmaddubswpmulhrswpshufbpsignbpsigndpsignwdoc 319433-058 June 2025
pbndkbprefetchrst2Intel Carry-Less Multiplication instructions (CLMUL)
pclmulhqhqdqpclmulhqlqdqpclmullqhqdqpclmullqlqdqpclmulqdqAMD Enhanced 3DNow! (Athlon) instructions
pf2iwpfnaccpfpnaccpi2fwpswapdGeode (Cyrix) 3DNow! additions
pfrcpvpfrsqrtvGeneric memory operations
prefetchit0prefetchit1prefetchntaprefetcht0prefetcht1prefetcht2Intel Transactional Synchronization Extensions (TSX)
prefetchwt1xabortxbeginxendxtestProcessor trace write
ptwriteSEV-SNP AMD instructions
pvalidatermpadjustvmgexitMMX instructions
pxorskinitSpecial reads: timestamp, CPU number, performance counters, randomness
rdpidrdpmcrdrandrdseedrdtscrdtscpIntel memory protection keys for userspace (PKU aka PKEYs)
rdpkruwrpkruSystem management mode
rdshrrsdcrsldtrsmrstssvdcsvldtsvtswrshrIntel SHA acceleration instructions
sha1msg1sha1msg2sha1nextesha1rnds4sha256msg1sha256msg2sha256rnds2vsha512msg1vsha512msg2vsha512rnds2AVX512 4-iteration Dot Product
v4dpwssdv4dpwssdsAVX512 4-iteration Multiply-Add
v4fmaddpsv4fmaddssv4fnmaddpsv4fnmaddssAVX10.2 BF16 instructions
vaddbf16vcmpbf16vcomisbf16vdivbf16vfmadd132bf16vfmadd213bf16vfmadd231bf16vfmsub132bf16vfmsub213bf16vfmsub231bf16vfnmadd132bf16vfnmadd213bf16vfnmadd231bf16vfnmsub132bf16vfnmsub213bf16vfnmsub231bf16vfpclassbf16vgetexpbf16vgetmantbf16vmaxbf16vminbf16vmulbf16vrcpbf16vreducebf16vrndscalebf16vrsqrtbf16vscalefbf16vsqrtbf16vsubbf16AVX-512 instructions
vaddpdvaddpsvaligndvalignqvandnpdvandnpsvandpdvandpsvblendmpdvblendmpsvbroadcastf32x2vbroadcastf32x4vbroadcastf32x8vbroadcastf64x2vbroadcastf64x4vbroadcasti32x2vbroadcasti32x4vbroadcasti32x8vbroadcasti64x2vbroadcasti64x4vbroadcastsdvbroadcastssvcmpeq_oqpdvcmpeq_oqpsvcmpeq_oqsdvcmpeq_oqssvcmpeq_uqpdvcmpeq_uqpsvcmpeq_uspdvcmpeq_uspsvcmpeqpdvcmpeqpsvcmpfalse_oqpdvcmpfalse_oqpsvcmpfalse_ospdvcmpfalse_ospsvcmpfalsepdvcmpfalsepsvcmpge_oqpdvcmpge_oqpsvcmpge_ospdvcmpge_ospsvcmpgepdvcmpgepsvcmpgt_oqpdvcmpgt_oqpsvcmpgt_ospdvcmpgt_ospsvcmpgtpdvcmpgtpsvcmple_oqpdvcmple_oqpsvcmple_ospdvcmple_ospsvcmplepdvcmplepsvcmplt_oqpdvcmplt_oqpsvcmplt_ospdvcmplt_ospsvcmpltpdvcmpltpsvcmpneq_oqpdvcmpneq_oqpsvcmpneq_ospdvcmpneq_ospsvcmpneq_uqpdvcmpneq_uqpsvcmpneq_uspdvcmpneq_uspsvcmpneqpdvcmpneqpsvcmpnge_uqpdvcmpnge_uqpsvcmpnge_uspdvcmpnge_uspsvcmpngepdvcmpngepsvcmpngt_uqpdvcmpngt_uqpsvcmpngt_uspdvcmpngt_uspsvcmpngtpdvcmpngtpsvcmpnle_uqpdvcmpnle_uqpsvcmpnle_uspdvcmpnle_uspsvcmpnlepdvcmpnlepsvcmpnlt_uqpdvcmpnlt_uqpsvcmpnlt_uspdvcmpnlt_uspsvcmpnltpdvcmpnltpsvcmpord_qpdvcmpord_qpsvcmpord_spdvcmpord_spsvcmpordpdvcmpordpsvcmppdvcmppsvcmptrue_uqpdvcmptrue_uqpsvcmptrue_uspdvcmptrue_uspsvcmptruepdvcmptruepsvcmpunord_qpdvcmpunord_qpsvcmpunord_spdvcmpunord_spsvcmpunordpdvcmpunordpsvcompresspdvcompresspsvcvtdq2pdvcvtdq2psvcvtpd2qqvcvtpd2udqvcvtpd2uqqvcvtps2dqvcvtps2pdvcvtps2qqvcvtps2udqvcvtps2uqqvcvtqq2pdvcvtqq2psvcvtsd2usivcvtss2usivcvttpd2qqvcvttpd2udqvcvttpd2uqqvcvttps2dqvcvttps2qqvcvttps2udqvcvttps2uqqvcvttsd2usivcvttss2usivcvtudq2pdvcvtudq2psvcvtuqq2pdvcvtuqq2psvcvtusi2sdvcvtusi2ssvdbpsadbwvdivpdvdivpsvexp2pdvexp2psvexpandpdvexpandpsvextractf32x4vextractf32x8vextractf64x2vextractf64x4vextracti32x4vextracti32x8vextracti64x2vextracti64x4vextractpsvfixupimmpdvfixupimmpsvfixupimmsdvfixupimmssvfmadd132pdvfmadd132psvfmadd213pdvfmadd213psvfmadd231pdvfmadd231psvfmaddsub132pdvfmaddsub132psvfmaddsub213pdvfmaddsub213psvfmaddsub231pdvfmaddsub231psvfmsub132pdvfmsub132psvfmsub213pdvfmsub213psvfmsub231pdvfmsub231psvfmsubadd132pdvfmsubadd132psvfmsubadd213pdvfmsubadd213psvfmsubadd231pdvfmsubadd231psvfnmadd132pdvfnmadd132psvfnmadd213pdvfnmadd213psvfnmadd231pdvfnmadd231psvfnmsub132pdvfnmsub132psvfnmsub213pdvfnmsub213psvfnmsub231pdvfnmsub231psvfpclasspdvfpclasspsvfpclasssdvfpclassssvgatherdpdvgatherdpsvgatherpf0dpdvgatherpf0dpsvgatherpf0qpdvgatherpf0qpsvgatherpf1dpdvgatherpf1dpsvgatherpf1qpdvgatherpf1qpsvgatherqpdvgatherqpsvgetexppdvgetexppsvgetexpsdvgetexpssvgetmantpdvgetmantpsvgetmantsdvgetmantssvinsertf32x4vinsertf32x8vinsertf64x2vinsertf64x4vinserti32x4vinserti32x8vinserti64x2vinserti64x4vmaxpdvmaxphvmaxpsvminpdvminphvminpsvmovapdvmovapsvmovddupvmovdqa32vmovdqa64vmovdqu16vmovdqu32vmovdqu64vmovdqu8vmovntdqvmovntdqavmovntpdvmovntpsvmovshdupvmovsldupvmovupdvmovupsvmulpdvmulpsvorpdvorpsvpabsbvpabsdvpabsqvpabswvpackssdwvpacksswbvpackusdwvpackuswbvpaddbvpadddvpaddqvpaddsbvpaddswvpaddusbvpadduswvpaddwvpalignrvpanddvpandndvpandnqvpandqvpavgbvpavgwvpblendmbvpblendmdvpblendmqvpblendmwvpbroadcastbvpbroadcastdvpbroadcastmb2qvpbroadcastmw2dvpbroadcastqvpbroadcastwvpcmpbvpcmpdvpcmpeqbvpcmpeqdvpcmpeqqvpcmpequbvpcmpequdvpcmpequqvpcmpequwvpcmpeqwvpcmpgebvpcmpgedvpcmpgeqvpcmpgeubvpcmpgeudvpcmpgeuqvpcmpgeuwvpcmpgewvpcmpgtbvpcmpgtdvpcmpgtqvpcmpgtubvpcmpgtudvpcmpgtuqvpcmpgtuwvpcmpgtwvpcmplebvpcmpledvpcmpleqvpcmpleubvpcmpleudvpcmpleuqvpcmpleuwvpcmplewvpcmpltbvpcmpltdvpcmpltqvpcmpltubvpcmpltudvpcmpltuqvpcmpltuwvpcmpltwvpcmpneqbvpcmpneqdvpcmpneqqvpcmpnequbvpcmpnequdvpcmpnequqvpcmpnequwvpcmpneqwvpcmpngtbvpcmpngtdvpcmpngtqvpcmpngtubvpcmpngtudvpcmpngtuqvpcmpngtuwvpcmpngtwvpcmpnlebvpcmpnledvpcmpnleqvpcmpnleubvpcmpnleudvpcmpnleuqvpcmpnleuwvpcmpnlewvpcmpnltbvpcmpnltdvpcmpnltqvpcmpnltubvpcmpnltudvpcmpnltuqvpcmpnltuwvpcmpnltwvpcmpqvpcmpubvpcmpudvpcmpuqvpcmpuwvpcmpwvpcompressdvpcompressqvpconflictdvpconflictqvpermbvpermdvpermi2bvpermi2dvpermi2pdvpermi2psvpermi2qvpermi2wvpermilpdvpermilpsvpermpdvpermpsvpermqvpermt2bvpermt2dvpermt2pdvpermt2psvpermt2qvpermt2wvpermwvpexpanddvpexpandqvpextrbvpextrwvpgatherddvpgatherdqvpgatherqdvpgatherqqvplzcntdvplzcntqvpmadd52huqvpmadd52luqvpmaddubswvpmaddwdvpmaxsbvpmaxsdvpmaxsqvpmaxswvpmaxubvpmaxudvpmaxuqvpmaxuwvpminsbvpminsdvpminsqvpminswvpminubvpminudvpminuqvpminuwvpmovb2mvpmovd2mvpmovdbvpmovdwvpmovm2bvpmovm2dvpmovm2qvpmovm2wvpmovq2mvpmovqbvpmovqdvpmovqwvpmovsdbvpmovsdwvpmovsqbvpmovsqdvpmovsqwvpmovswbvpmovsxbdvpmovsxbqvpmovsxbwvpmovsxdqvpmovsxwdvpmovsxwqvpmovusdbvpmovusdwvpmovusqbvpmovusqdvpmovusqwvpmovuswbvpmovw2mvpmovwbvpmovzxbdvpmovzxbqvpmovzxbwvpmovzxdqvpmovzxwdvpmovzxwqvpmuldqvpmulhrswvpmulhuwvpmulhwvpmulldvpmullqvpmullwvpmultishiftqbvpmuludqvpordvporqvproldvprolqvprolvdvprolvqvprordvprorqvprorvdvprorvqvpsadbwvpscatterddvpscatterdqvpscatterqdvpscatterqqvpshufbvpshufdvpshufhwvpshuflwvpslldvpslldqvpsllqvpsllvdvpsllvqvpsllvwvpsllwvpsradvpsraqvpsravdvpsravqvpsravwvpsrawvpsrldvpsrldqvpsrlqvpsrlvdvpsrlvqvpsrlvwvpsrlwvpsubbvpsubdvpsubqvpsubsbvpsubswvpsubusbvpsubuswvpsubwvpternlogdvpternlogqvptestmbvptestmdvptestmqvptestmwvptestnmbvptestnmdvptestnmqvptestnmwvpunpckhbwvpunpckhdqvpunpckhqdqvpunpckhwdvpunpcklbwvpunpckldqvpunpcklqdqvpunpcklwdvpxordvpxorqvrangepdvrangepsvrangesdvrangessvrcp14pdvrcp14psvrcp14sdvrcp14ssvrcp28pdvrcp28psvrcp28sdvrcp28ssvreducepdvreducepsvreducesdvreducessvrndscalepdvrndscalephvrndscalepsvrndscalesdvrndscaleshvrndscalessvrsqrt14pdvrsqrt14psvrsqrt14sdvrsqrt14ssvrsqrt28pdvrsqrt28psvrsqrt28sdvrsqrt28ssvscalefpdvscalefpsvscalefsdvscalefssvscatterdpdvscatterdpsvscatterpf0dpdvscatterpf0dpsvscatterpf0qpdvscatterpf0qpsvscatterpf1dpdvscatterpf1dpsvscatterpf1qpdvscatterpf1qpsvscatterqpdvscatterqpsvshuff32x4vshuff64x2vshufi32x4vshufi64x2vshufpdvshufpsvsqrtpdvsqrtpsvsubpdvsubpsvunpckhpdvunpckhpsvunpcklpdvunpcklpsvxorpdvxorpsIntel AVX512-FP16 instructions
vaddphvaddshvcmpphvcmpshvcomishvcvtdq2phvcvtpd2phvcvtph2dqvcvtph2pdvcvtph2psvcvtph2psxvcvtph2qqvcvtph2udqvcvtph2uqqvcvtph2uwvcvtph2wvcvtps2phvcvtps2phxvcvtqq2phvcvtsd2shvcvtsh2sdvcvtsh2sivcvtsh2ssvcvtsh2usivcvtsi2shvcvtss2shvcvttph2dqvcvttph2qqvcvttph2udqvcvttph2uqqvcvttph2uwvcvttph2wvcvttsh2sivcvttsh2usivcvtudq2phvcvtuqq2phvcvtusi2shvcvtuw2phvcvtw2phvdivphvdivshvendscalephvendscaleshvfcmaddcphvfcmaddcshvfcmulcpchvfcmulcshvfmadd132phvfmadd213phvfmadd231phvfmaddcphvfmaddcshvfmaddsub132phvfmaddsub213phvfmaddsub231phvfmsub132phvfmsub213phvfmsub231phvfmsubadd132phvfmsubadd213phvfmsubadd231phvfmulcpchvfmulcshvfnmadd132phvfnmadd213phvfnmadd231phvfnmsub132phvfnmsub213phvfnmsub231phvfpclassphvfpclassshvgetexpphvgetexpshvgetmantphvgetmantshvgetmaxphvgetmaxshvgetminphvgetminshvmovshvmovwvmulphvmulshvpmadd132phvpmadd132shvpmadd213phvpmadd213shvpmadd231phvpmadd231shvpmsub132phvpmsub132shvpmsub213phvpmsub213shvpmsub231phvpmsub231shvpnmadd132shvpnmadd213shvpnmadd231shvpnmsub132shvpnmsub213shvpnmsub231shvrcpphvrcpshvreducephvreduceshvrsqrtphvrsqrtshvscalefphvscalefshvsqrtphvsqrtshvsubphvsubshvucomishIntel AVX instructions
vaddsdvaddssvaddsubpdvaddsubpsvblendpdvblendpsvblendvpdvblendvpsvbroadcastf128vcmpeq_ospdvcmpeq_ospsvcmpeq_ossdvcmpeq_osssvcmpeq_uqsdvcmpeq_uqssvcmpeq_ussdvcmpeq_usssvcmpeqsdvcmpeqssvcmpfalse_oqsdvcmpfalse_oqssvcmpfalse_ossdvcmpfalse_osssvcmpfalsesdvcmpfalsessvcmpge_oqsdvcmpge_oqssvcmpge_ossdvcmpge_osssvcmpgesdvcmpgessvcmpgt_oqsdvcmpgt_oqssvcmpgt_ossdvcmpgt_osssvcmpgtsdvcmpgtssvcmple_oqsdvcmple_oqssvcmple_ossdvcmple_osssvcmplesdvcmplessvcmplt_oqsdvcmplt_oqssvcmplt_ossdvcmplt_osssvcmpltsdvcmpltssvcmpneq_oqsdvcmpneq_oqssvcmpneq_ossdvcmpneq_osssvcmpneq_uqsdvcmpneq_uqssvcmpneq_ussdvcmpneq_usssvcmpneqsdvcmpneqssvcmpnge_uqsdvcmpnge_uqssvcmpnge_ussdvcmpnge_usssvcmpngesdvcmpngessvcmpngt_uqsdvcmpngt_uqssvcmpngt_ussdvcmpngt_usssvcmpngtsdvcmpngtssvcmpnle_uqsdvcmpnle_uqssvcmpnle_ussdvcmpnle_usssvcmpnlesdvcmpnlessvcmpnlt_uqsdvcmpnlt_uqssvcmpnlt_ussdvcmpnlt_usssvcmpnltsdvcmpnltssvcmpord_qsdvcmpord_qssvcmpord_ssdvcmpord_sssvcmpordsdvcmpordssvcmpsdvcmpssvcmptrue_uqsdvcmptrue_uqssvcmptrue_ussdvcmptrue_usssvcmptruesdvcmptruessvcmpunord_qsdvcmpunord_qssvcmpunord_ssdvcmpunord_sssvcmpunordsdvcmpunordssvcomisdvcomissvcvtpd2dqvcvtpd2psvcvtsd2sivcvtsd2ssvcvtsi2sdvcvtsi2ssvcvtss2sdvcvtss2sivcvttpd2dqvcvttsd2sivcvttss2sivdivsdvdivssvdppdvdppsvextractf128vhaddpdvhaddpsvhsubpdvhsubpsvinsertf128vinsertpsvlddquvldmxcsrvldqquvmaskmovdquvmaskmovpdvmaskmovpsvmaxsdvmaxssvminsdvminssvmovdvmovdqavmovdquvmovhlpsvmovhpdvmovhpsvmovlhpsvmovlpdvmovlpsvmovmskpdvmovmskpsvmovntqqvmovqvmovqqavmovqquvmovsdvmovssvmulsdvmulssvpandvpandnvpblendvbvpblendwvpcmpestrivpcmpestrmvpcmpistrivpcmpistrmvperm2f128vpextrdvpextrqvphadddvphaddswvphaddwvphminposuwvphsubdvphsubswvphsubwvpinsrbvpinsrdvpinsrqvpinsrwvpmovmskbvporvpsignbvpsigndvpsignwvptestvpxorvrcppsvrcpssvroundpdvroundpsvroundsdvroundssvrsqrtpsvrsqrtssvsqrtsdvsqrtssvstmxcsrvsubsdvsubssvtestpdvtestpsvucomisdvucomissvzeroallvzeroupperIntel instruction extension based on pub number 319433-030 dated October 2017
vaesdecvaesdeclastvaesencvaesenclastIntel AVX AES instructions
vaesimcvaeskeygenassistAVX no exception conversions
vbcstnebf162psvbcstnebf16psvbcstnesh2psvcvtneebf162psvcvtneeph2psvcvtneobf162psvcvtneoph2psIntel AVX2 instructions
vbroadcasti128vextracti128vinserti128vpblenddvperm2i128vpmaskmovdvpmaskmovqAVX10.2 Compare scalar fp with enhanced eflags instructions
vcomxsdvcomxshvcomxssvucomxsdvucomxshvucomxssAVX10.2 Convert instructions
vcvt2ph2bf8vcvt2ph2bf8svcvt2ph2hf8vcvt2ph2hf8svcvt2ps2phxvcvtbiasph2bf8vcvtbiasph2bf8svcvtbiasph2hf8vcvtbiasph2hf8svcvthf82phvcvtph2bf8vcvtph2bf8svcvtph2hf8vcvtph2hf8sAVX10.2 Saturating convert instructions
vcvtbf162ibsvcvtbf162iubsvcvtph2ibsvcvtph2iubsvcvtps2ibsvcvtps2iubsvcvttbf162ibsvcvttbf162iubsvcvttpd2dqsvcvttpd2qqsvcvttpd2udqsvcvttpd2uqqsvcvttph2ibsvcvttph2iubsvcvttps2dqsvcvttps2ibsvcvttps2iubsvcvttps2qqsvcvttps2udqsvcvttps2uqqsvcvttsd2sisvcvttsd2usisvcvttss2sisvcvttss2usisAVX512 Bfloat16 instructions
vcvtne2ps2bf16vcvtneps2bf16vdpbf16psAVX10.2 Integer and FP16 VNNI, media new instructions
vdpphpsvmpsadbwvpdpbssdvpdpbssdsvpdpbsudvpdpbsudsvpdpbuudvpdpbuudsvpdpwsudvpdpwsudsvpdpwusdvpdpwusdsvpdpwuudvpdpwuudsIntel AVX Carry-Less Multiplication instructions (CLMUL)
vfcmulcphvfmadd132shvfmadd213shvfmadd231shvfmsub132shvfmsub213shvfmsub231shvfmulcphvfnmadd132shvfnmadd213shvfnmadd231shvfnmsub132shvfnmsub213shvfnmsub231shvmaxshvminshvpclmulhqhqdqvpclmulhqlqdqvpclmullqhqdqvpclmullqlqdqvpclmulqdqIntel Fused Multiply-Add instructions (FMA)
vfmadd123pdvfmadd123psvfmadd123sdvfmadd123ssvfmadd132sdvfmadd132ssvfmadd213sdvfmadd213ssvfmadd231sdvfmadd231ssvfmadd312pdvfmadd312psvfmadd312sdvfmadd312ssvfmadd321pdvfmadd321psvfmadd321sdvfmadd321ssvfmaddsub123pdvfmaddsub123psvfmaddsub312pdvfmaddsub312psvfmaddsub321pdvfmaddsub321psvfmsub123pdvfmsub123psvfmsub123sdvfmsub123ssvfmsub132sdvfmsub132ssvfmsub213sdvfmsub213ssvfmsub231sdvfmsub231ssvfmsub312pdvfmsub312psvfmsub312sdvfmsub312ssvfmsub321pdvfmsub321psvfmsub321sdvfmsub321ssvfmsubadd123pdvfmsubadd123psvfmsubadd312pdvfmsubadd312psvfmsubadd321pdvfmsubadd321psvfnmadd123pdvfnmadd123psvfnmadd123sdvfnmadd123ssvfnmadd132sdvfnmadd132ssvfnmadd213sdvfnmadd213ssvfnmadd231sdvfnmadd231ssvfnmadd312pdvfnmadd312psvfnmadd312sdvfnmadd312ssvfnmadd321pdvfnmadd321psvfnmadd321sdvfnmadd321ssvfnmsub123pdvfnmsub123psvfnmsub123sdvfnmsub123ssvfnmsub132sdvfnmsub132ssvfnmsub213sdvfnmsub213ssvfnmsub231sdvfnmsub231ssvfnmsub312pdvfnmsub312psvfnmsub312sdvfnmsub312ssvfnmsub321pdvfnmsub321psvfnmsub321sdvfnmsub321ssAMD XOP and FMA4 instructions (SSE5)
vfmaddpdvfmaddpsvfmaddsdvfmaddssvfmaddsubpdvfmaddsubpsvfmsubaddpdvfmsubaddpsvfmsubpdvfmsubpsvfmsubsdvfmsubssvfnmaddpdvfnmaddpsvfnmaddsdvfnmaddssvfnmsubpdvfnmsubpsvfnmsubsdvfnmsubssvfrczpdvfrczpsvfrczsdvfrczssvpcmovvpcombvpcomdvpcomqvpcomubvpcomudvpcomuqvpcomuwvpcomwvphaddbdvphaddbqvphaddbwvphadddqvphaddubdvphaddubqvphaddubwvphaddudqvphadduwdvphadduwqvphaddwdvphaddwqvphsubbwvphsubdqvphsubwdvpmacsddvpmacsdqhvpmacsdqlvpmacssddvpmacssdqhvpmacssdqlvpmacsswdvpmacsswwvpmacswdvpmacswwvpmadcsswdvpmadcswdvppermvprotbvprotdvprotqvprotwvpshabvpshadvpshaqvpshawvpshlbvpshldvpshlqvpshlwAVX10.2 MINMAX instructions
vminmaxbf16vminmaxpdvminmaxphvminmaxpsvminmaxsdvminmaxshvminmaxssAVX512 mask intersect instructions
vp2intersectdvp2intersectqAVX512 Vector Bit Manipulation Instructions 2
vpcompressbvpcompresswvpexpandbvpexpandwvpshlddvpshldqvpshldvdvpshldvqvpshldvwvpshldwvpshrddvpshrdqvpshrdvdvpshrdvqvpshrdvwvpshrdwAVX512 VNNI
vpdpbusdvpdpbusdsvpdpwssdvpdpwssdsAVX512 Bit Algorithms
vpopcntbvpopcntdvpopcntqvpopcntwvpshufbitqmbS3M hash instructions
vsm3msg1vsm3msg2vsm3rnds2SM4 hash instructions
vsm4key4vsm4rnds4XSAVE group (AVX and extended state)
xgetbvxrstorxrstor64xrstorsxrstors64xsavexsave64xsavecxsavec64xsaveoptxsaveopt64xsavesxsaves64xsetbvDirectives
Directives
Directives tell the assembler what to do. They are not instructions and the processor never sees them.
section
Opens a section: .text for code, .data for initialised data, .bss for space that starts as zeroes, .rodata for constants. Everything after the line belongs to that section until the next one. segment is the same directive under its other name.
global
Makes a label visible outside the file. The program has to declare _start, because that is the label the linker makes the entry point.
extern
Declares that a name is defined in another file, so this one may refer to it.
bits
Assembles for 16, 32 or 64 bit mode. Programs here are 64 bit and the object format already says so, so a program needs this only to say something unusual.
default
Chooses whether a bare memory reference is rel (an offset from rip) or abs (an absolute address). Long mode code is usually written default rel.
cpu
Refuses to assemble instructions newer than the processor named, which is a way to keep a program inside the instruction set a course is teaching.
absolute
Starts a block of labels that describe a layout without emitting anything, the way a structure declaration does.
Data and space
These live in the instruction table and behave like directives: they put bytes in the output, or reserve room for them.
db, dw, dd, dq
Emit bytes, words (2 bytes), doublewords (4) and quadwords (8), in order, where the line is. They take numbers, characters, strings and label addresses: msg: db "hi", 10.
dt, do, dy, dz
Emit 10, 16, 32 and 64 byte values, for the x87 and vector types.
resb, resw, resd, resq
Reserve room without writing anything: buffer: resb 64. They belong in .bss, which costs nothing in the file because it is all zeroes.
equ
Gives a name to a value, evaluated once where it is written: LEN equ 64. Nothing is emitted and nothing can change it later.
incbin
Copies a file into the output at this point, byte for byte.
times
Repeats the rest of the line: times 64 db 0 emits 64 zero bytes, and times 8 - ($ - start) db 0 pads to a fixed size.
The preprocessor
The preprocessor runs over the text before the assembler reads it, so it can define names, repeat blocks and include files, and knows nothing about registers or instructions.
%define
A macro expanded wherever its name appears, with arguments if it was given any. Expanded late, so it sees the value a name has when it is used.
%assign
A single line macro whose value is evaluated at once, and may be reassigned.
%macro
A multi line macro, ended by %endmacro. The number after the name says how many arguments it takes, and %1, %2 stand for them.
%include
Assembles another file here, the way a header is included.
%ifdef, %ifndef, %if
Assemble a block only under a condition, ending at %endif, with %else and %elif in between.
%rep
Repeats a block a fixed number of times, ending at %endrep.
Prefixes and operand sizes
Words that go in front of an instruction or an operand rather than standing on their own.
lock
Makes a read-modify-write instruction atomic against other processors. Only a handful of instructions accept it, and only when the destination is memory.
rep
Repeats a string instruction rcx times, counting down. On movs and stos this is the whole loop, written in one instruction.
repe, repz, repne, repnz
Repeat while the comparison keeps saying equal, or keeps saying not equal, and stop early when it changes. They are for cmps and scas, which set the flags on every step.
o16, o32, o64, a16, a32, a64
Force the operand or address size of one instruction, overriding what the mode implies. NASM chooses these on its own; writing one by hand is for the rare case where the choice matters.
byte, word, dword, qword
Say how wide a memory operand is, which the instruction cannot always work out on its own: mov qword [rsp], 0 writes eight bytes, mov byte [rsp], 0 writes one.
near, short, far
Choose the reach of a jump or call. NASM picks the shortest form that works, so these are for forcing a longer one.
rel, abs
Say whether a memory reference is an offset from rip or an absolute address, for one operand rather than for the file the way default does.
Everything else
The rest of what NASM accepts, from its own tables. These are here so the list is complete; the NASM manual documents them.
absolutebitscommoncpudebugdefaultdollarhexexternfloatglobalstaticlistsectionsegmentwarningsectalignpragmarequired %aliases%arg%assign%clear%defalias%define%defstr%deftok%depend%elif%elifctx%elifdef%elifdefalias%elifdifi%elifdirective%elifempty%elifenv%eliffile%elifid%elifidn%elifidni%elifmacro%elifn%elifnctx%elifndef%elifndefalias%elifndifi%elifndirective%elifnempty%elifnenv%elifnfile%elifnid%elifnidn%elifnidni%elifnmacro%elifnnum%elifnstr%elifntoken%elifnum%elifnusable%elifnusing%elifstr%eliftoken%elifusable%elifusing%else%endif%endm%endmacro%endrep%error%exitmacro%exitrep%fatal%if%ifctx%ifdef%ifdefalias%ifdifi%ifdirective%ifempty%ifenv%iffile%ifid%ifidn%ifidni%ifmacro%ifn%ifnctx%ifndef%ifndefalias%ifndifi%ifndirective%ifnempty%ifnenv%ifnfile%ifnid%ifnidn%ifnidni%ifnmacro%ifnnum%ifnstr%ifntoken%ifnum%ifnusable%ifnusing%ifstr%iftoken%ifusable%ifusing%include%line%local%macro%note%null%pathsearch%pop%pragma%push%rep%repl%require%rmacro%rotate%stacksize%strcat%strlen%substr%undef%undefalias%unmacro%use%warning%xdefineRegisters & Flags
Registers
Sixteen 64 bit general purpose registers. Each one can be used at four widths: rax is the whole register, eax its low 32 bits, ax its low 16 and al its low 8. Writing a 32 bit name clears the top half of the 64 bit register; writing a 16 or 8
bit name leaves the rest alone.
rax eaxaxahal
The accumulator. mul, div and the string instructions use it without being told to, a syscall number goes in it, and a syscall result comes back in it.
rbx ebxbxbhbl
A general register. Called on to survive a function call: a function that writes to it has to put it back before returning.
rcx ecxcxchcl
The counter. loop and the repeated string instructions count down with it, the shift instructions read a variable shift amount from cl, and it carries the fourth argument of a function call. syscall destroys it.
rdx edxdxdhdl
The high half of the product mul writes and of the dividend div reads, and the third argument of a function call or a syscall.
rsi esisisil
The source pointer of the string instructions, and the second argument of a function call or a syscall.
rdi edididil
The destination pointer of the string instructions, and the first argument of a function call or a syscall.
rbp ebpbpbpl
The frame pointer by convention, pointing at the base of the current function's stack frame. Nothing in the hardware requires it, and compilers routinely use it as one more general register.
rsp espspspl
The stack pointer. push, pop, call and ret move it without being told to, and it must point at usable memory whenever any of them runs.
r8 to r15 r8d to r15dr8w to r15wr8b to r15b
The eight registers x86-64 added. r8 and r9 carry the fifth and sixth arguments of a function call; r10 replaces rcx as the fourth argument of a syscall, because syscall destroys rcx. r11 is destroyed too.
rip
The instruction pointer. It cannot be read or written directly, but it can be addressed: [rel label] assembles to an offset from rip, which is how position independent code reaches its own data.
rflags eflagsflags
The flags, listed below. Arithmetic and logic instructions write them, the conditional jumps and setcc read them, and pushfq and popfq move the whole register to and from the stack.
Flags
The flags live in rflags. Arithmetic and logic instructions write them, cmp and test exist to write them without keeping a result, and the conditional instructions
read them.
CF bit 0
Carry. Set when an unsigned addition overflowed or an unsigned subtraction borrowed, and by the shift and rotate instructions, which shift the last bit out through it.
PF bit 2
Parity. Set when the low byte of the result has an even number of set bits.
AF bit 4
Adjust. The carry out of bit 3, which only the decimal adjust instructions read.
ZF bit 6
Zero. Set when the result was zero, which is what je and jne read after a cmp.
SF bit 7
Sign. A copy of the top bit of the result, so it is set when the result is negative read as signed.
DF bit 10
Direction. Clear means the string instructions count upwards, set means downwards. cld and std write it, and it is expected to be clear everywhere else.
OF bit 11
Overflow. Set when a signed operation produced a result too large for its destination, which is a different question from the one the carry flag answers.
SSE registers
Floating point arithmetic in a 64 bit program is SSE arithmetic. The xmm registers are wide enough to hold several numbers at once, and each instruction says how much of a register it means: the scalar forms work on the lowest lane alone, so addsd xmm0, xmm1 adds one pair of doubles and cvtsi2sd xmm0, rax turns an integer into a double and writes it into that same lowest lane, both of them leaving the upper lane of the destination as they found it. The moves are the exception: movsd xmm0, [x] loads one double from memory and clears bits 127 to 64, while movsd xmm0, xmm1 copies the low double and leaves the upper lane alone, so where the value came from decides what the rest of the register holds. The packed forms, addpd and mulps among them, apply the same operation to every lane of the register at once, which is the reason the registers are this wide.
The single precision instructions are spelled with ss and ps where the double precision ones use sd and pd, and the calling convention passes floating point arguments in xmm0 to xmm7 and returns them in xmm0.
xmm0 to xmm15 128 bit
Sixteen 128 bit registers. Read as doubles they are two lanes, read as singles four, and read as raw bits sixteen bytes; the registers panel shows all three, because nothing in the register itself records which one the program meant.
mxcsr 32 bit
The control and status register of the unit. It holds the rounding mode, the masks that decide whether an invalid operation raises an exception or quietly produces a NaN, and the flags that record which of those conditions has happened since the flags were last cleared. ldmxcsr and stmxcsr move it to and from memory.
x87 registers
The x87 unit is the floating point hardware x86 had before SSE, and it is still what the f instructions use. Its eight registers are a stack rather than a numbered file: st0 is always the top, fld and fld1 push a value onto it and rename everything below, and faddp adds the top two and pops, so the same register name means a different value after every push. Programs written today use SSE for arithmetic and reach for x87 mainly for the operations SSE has no instruction for, such as fsin, fcos or fpatan.
This emulator keeps the stack as ordinary 64 bit doubles rather than the 80 bit extended values real hardware computes with, so a long chain of x87 arithmetic can differ from a physical processor in the last bits of the result.
A slot the stack has not filled, or has popped, keeps whatever bits it last held. The panel shows those rows blank rather than the stale value, the way info float prints Empty in gdb, and the bits are still a hover away; ftag is the register that says which slots are live.
st0 to st7 64 bit
The stack registers, listed top first: what the panel calls st0 is whatever the last push left on top, and one more push moves that value to st1. An instruction that pops past the bottom of the stack, or pushes onto a full one, raises the stack fault the status word reports.
fctrl 16 bit
The control word: the rounding mode, the precision the unit rounds results to, and the masks that say which exceptions the program wants to be told about. fldcw writes it, which is how code that needs truncation rather than the default round to nearest gets it. The precision field has nothing to decide here, because the stack already holds doubles.
fstat 16 bit
The status word: the exception flags, the condition codes a comparison such as fcom writes, and the three bits that say which register is currently the top of the stack. fstsw ax copies it into ax, which is how an x87 comparison used to reach a conditional jump.
ftag 16 bit
Two bits per register saying whether it holds a number, a zero, a special value such as an infinity, or nothing at all. It is what makes an empty stack slot distinguishable from one holding zero, and what the panel reads to decide which rows to leave blank.
Condition codes
The same sixteen conditions end jcc, setcc and cmovcc: jne jumps, setne writes 1 or 0 to a byte, and cmovne copies a register, all on the same test. The unsigned conditions read the carry flag and the signed
ones read the sign and overflow flags, which is why comparing two numbers the wrong way round
silently gives the wrong answer.
| Condition | Also written | Meaning | Test |
|---|---|---|---|
| e | z | equal, zero | ZF = 1 |
| ne | nz | not equal, not zero | ZF = 0 |
| a | nbe | above (unsigned) | CF = 0 and ZF = 0 |
| ae | nb, nc | above or equal (unsigned) | CF = 0 |
| b | nae, c | below (unsigned) | CF = 1 |
| be | na | below or equal (unsigned) | CF = 1 or ZF = 1 |
| g | nle | greater (signed) | ZF = 0 and SF = OF |
| ge | nl | greater or equal (signed) | SF = OF |
| l | nge | less (signed) | SF is not OF |
| le | ng | less or equal (signed) | ZF = 1 or SF is not OF |
| s | sign set, negative | SF = 1 | |
| ns | sign clear, not negative | SF = 0 | |
| o | overflow | OF = 1 | |
| no | no overflow | OF = 0 | |
| p | pe | parity even | PF = 1 |
| np | po | parity odd | PF = 0 |
Syscalls
A program here runs as a Linux program, so everything outside its own memory happens through syscall. Put the call number in rax, the arguments in rdi, rsi, rdx, r10, r8 and r9, and read the result from rax. A result between -1 and -4095 is
an error code. rcx and r11 do not survive the call.
The ones to start with
1 - write waits
Writes rdx bytes from the buffer at rsi to the file descriptor in rdi, and returns how many it wrote. Descriptor 1 is standard output and 2 is standard error, so this is how a program prints.
0 - read waits
Reads up to rdx bytes from the file descriptor in rdi into the buffer at rsi, and returns how many it read. Descriptor 0 is standard input, so this is how a program reads what was typed. A return of 0 means end of input.
60 - exit
Ends the program with the status in rdi. It never returns, and a program that reaches the end of its code without calling it runs into whatever bytes follow.
231 - exit_group
Ends every thread of the program with the status in rdi. For a program with one thread it is exit.
2 - open waits
Opens the path at rdi with the flags in rsi and, when creating, the mode in rdx. Returns a file descriptor.
3 - close waits
Closes the file descriptor in rdi.
8 - lseek
Moves the read and write position of the descriptor in rdi to the offset in rsi, interpreted according to rdx, and returns the new position.
5 - fstat
Fills the structure at rsi with what is known about the descriptor in rdi, including its size.
12 - brk
Moves the end of the data segment to the address in rdi, which is the oldest way to ask for more memory. Called with 0 it returns where the segment currently ends.
9 - mmap
Maps memory: the length in rsi, the protection in rdx, the flags in r10. An anonymous private mapping is how a program asks for a block of memory it can write to.
11 - munmap
Unmaps the mapping of rsi bytes at the address in rdi.
35 - nanosleep waits
Sleeps for the interval at rdi, a pair of seconds and nanoseconds.
228 - clock_gettime
Writes the time of the clock named in rdi into the structure at rsi.
39 - getpid
Returns the process id.
Everything this emulator implements
Those syscalls are what the emulator implements, anything missing returns -ENOSYS.
| rax | Call | Arguments |
|---|---|---|
| 4 | stat | rdi pathrsi o_stat |
| 6 | lstat | rdi pathrsi o_stat |
| 7 | poll | rdi valuersi valuerdx value |
| 10 | mprotect | rdi pointerrsi sizerdx protection flags |
| 13 | rt_sigaction | rdi signalrsi i_handrdx o_handr10 byte count |
| 14 | rt_sigprocmask | rdi sighowrsi i_sigsetrdx o_sigsetr10 byte count |
| 16 | ioctl | rdi valuersi valuerdx value |
| 17 | pread | rdi file descriptorrsi buffer (written by the kernel)rdx byte countr10 offset |
| 18 | pwrite | rdi file descriptorrsi buffer (read by the kernel)rdx byte countr10 offset |
| 19 | readv | rdi file descriptorrsi iovec array (written)rdx byte count |
| 20 | writev | rdi file descriptorrsi iovec array (read)rdx byte count |
| 21 | access | rdi pathrsi accmode |
| 22 | pipe | rdi o_pfds |
| 23 | select | rdi intrsi io_fdsetrdx io_fdsetr10 io_fdsetr8 io_timev |
| 24 | sched_yield | |
| 25 | mremap | rdi valuersi valuerdx valuer10 valuer8 value |
| 26 | msync | rdi valuersi valuerdx value |
| 28 | madvise | rdi valuersi valuerdx value |
| 32 | dup | rdi file descriptor |
| 33 | dup2 | rdi file descriptorrsi int |
| 34 | pause | |
| 36 | getitimer | rdi valuersi value |
| 37 | alarm | rdi int |
| 38 | setitimer | rdi valuersi valuerdx value |
| 40 | sendfile | rdi valuersi valuerdx valuer10 value |
| 41 | socket | rdi familyrsi socktyperdx int |
| 42 | connect | rdi file descriptorrsi i_addrrdx addrlen |
| 43 | accept | rdi file descriptorrsi o_addrrdx long |
| 44 | sendto | rdi file descriptorrsi buffer (read by the kernel)rdx sizer10 intr8 i_addrr9 addrlen |
| 45 | recvfrom | rdi file descriptorrsi buffer (written by the kernel)rdx sizer10 intr8 o_addrr9 long |
| 46 | sendmsg | rdi valuersi valuerdx value |
| 47 | recvmsg | rdi valuersi valuerdx value |
| 48 | shutdown | rdi valuersi value |
| 49 | bind | rdi file descriptorrsi i_addrrdx addrlen |
| 50 | listen | rdi file descriptorrsi un |
| 51 | getsockname | rdi file descriptorrsi o_addrrdx long |
| 52 | getpeername | rdi file descriptorrsi o_addrrdx long |
| 53 | socketpair | rdi familyrsi socktyperdx intr10 o_pfds |
| 54 | setsockopt | rdi valuersi valuerdx valuer10 valuer8 value |
| 55 | getsockopt | rdi valuersi valuerdx valuer10 valuer8 value |
| 56 | clone | rdi cloneflagsrsi pointerrdx pointerr10 pointerr8 pointerr9 pointer |
| 57 | fork | |
| 58 | vfork | |
| 59 | execve | rdi valuersi valuerdx value |
| 61 | wait4 | rdi process idrsi o_wstatusrdx waitflagsr10 o_rusage |
| 62 | kill | rdi process idrsi signal |
| 63 | uname | rdi value |
| 72 | fcntl | rdi file descriptorrsi wat_fcntlrdx un |
| 73 | flock | rdi valuersi value |
| 74 | fsync | rdi file descriptor |
| 75 | fdatasync | rdi file descriptor |
| 76 | truncate | rdi stringrsi offset |
| 77 | ftruncate | rdi file descriptorrsi offset |
| 79 | getcwd | rdi buffer (written by the kernel)rsi byte count |
| 80 | chdir | rdi path |
| 81 | fchdir | rdi file descriptor |
| 82 | rename | rdi pathrsi path |
| 83 | mkdir | rdi pathrsi mode |
| 84 | rmdir | rdi path |
| 85 | creat | rdi pathrsi mode |
| 86 | link | rdi pathrsi path |
| 87 | unlink | rdi path |
| 88 | symlink | rdi pathrsi path |
| 89 | readlink | rdi pathrsi buffer (written by the kernel)rdx byte count |
| 90 | chmod | rdi pathrsi mode |
| 91 | fchmod | rdi file descriptorrsi uid |
| 92 | chown | rdi pathrsi uidrdx gid |
| 93 | fchown | rdi file descriptorrsi uidrdx gid |
| 94 | lchown | rdi pathrsi uidrdx gid |
| 95 | umask | rdi mode |
| 96 | gettimeofday | rdi valuersi value |
| 97 | getrlimit | rdi resourcersi o_rlimit |
| 98 | getrusage | rdi valuersi value |
| 99 | sysinfo | rdi value |
| 100 | times | rdi value |
| 102 | getuid | |
| 104 | getgid | |
| 105 | setuid | rdi uid |
| 106 | setgid | rdi gid |
| 107 | geteuid | |
| 108 | getegid | |
| 109 | setpgid | rdi valuersi value |
| 110 | getppid | |
| 111 | getpgrp | |
| 112 | setsid | |
| 113 | setreuid | rdi uidrsi uid |
| 114 | setregid | rdi gidrsi gid |
| 115 | getgroups | rdi valuersi value |
| 116 | setgroups | rdi valuersi value |
| 117 | setresuid | rdi uidrsi uidrdx uid |
| 118 | getresuid | rdi valuersi valuerdx value |
| 119 | setresgid | rdi gidrsi gidrdx gid |
| 120 | getresgid | rdi valuersi valuerdx value |
| 121 | getpgid | rdi process id |
| 124 | getsid | rdi value |
| 127 | rt_sigpending | rdi value |
| 130 | rt_sigsuspend | rdi i_sigsetrsi byte count |
| 131 | sigaltstack | rdi valuersi value |
| 132 | utime | rdi valuersi value |
| 133 | mknod | rdi valuersi valuerdx value |
| 137 | statfs | rdi valuersi value |
| 138 | fstatfs | rdi valuersi value |
| 140 | getpriority | rdi valuersi value |
| 141 | setpriority | rdi valuersi valuerdx value |
| 142 | sched_set_param | rdi valuersi value |
| 143 | sched_get_param | rdi valuersi value |
| 144 | sched_set_scheduler | rdi valuersi valuerdx value |
| 145 | sched_get_scheduler | rdi value |
| 146 | sched_get_priority_max | rdi value |
| 147 | sched_get_priority_min | rdi value |
| 157 | prctl | rdi valuersi valuerdx valuer10 valuer8 value |
| 158 | arch_prctl | rdi valuersi value |
| 160 | setrlimit | rdi resourcersi i_rlimit |
| 161 | chroot | rdi path |
| 162 | sync | |
| 165 | mount | rdi stringrsi stringrdx msflagsr10 pointerr8 un |
| 186 | gettid | |
| 200 | tkill | rdi process idrsi signal |
| 202 | futex | rdi valuersi valuerdx valuer10 valuer8 valuer9 value |
| 203 | sched_set_affinity | rdi valuersi valuerdx value |
| 204 | sched_get_affinity | rdi valuersi valuerdx value |
| 213 | epoll_create | rdi value |
| 217 | getdents | rdi valuersi valuerdx value |
| 218 | set_tid_address | rdi value |
| 221 | fadvise | rdi valuersi valuerdx valuer10 value |
| 227 | clock_settime | rdi valuersi value |
| 229 | clock_getres | rdi valuersi value |
| 230 | clock_nanosleep | rdi clockrsi intrdx i_timer10 o_time |
| 232 | epoll_wait | rdi valuersi valuerdx valuer10 value |
| 233 | epoll_ctl | rdi valuersi valuerdx valuer10 value |
| 234 | tgkill | rdi valuersi valuerdx value |
| 235 | utimes | rdi valuersi value |
| 257 | openat | rdi directory descriptorrsi stringrdx open flagsr10 mode |
| 258 | mkdirat | rdi directory descriptorrsi pathrdx mode |
| 259 | mknodat | rdi valuersi valuerdx valuer10 value |
| 260 | fchownat | rdi directory descriptorrsi pathrdx uidr10 gidr8 atflags |
| 261 | futimesat | rdi valuersi valuerdx value |
| 262 | fstatat | rdi directory descriptorrsi pathrdx o_statr10 atflags |
| 263 | unlinkat | rdi directory descriptorrsi pathrdx atflags |
| 264 | renameat | rdi directory descriptorrsi pathrdx directory descriptorr10 path |
| 265 | linkat | rdi directory descriptorrsi pathrdx directory descriptorr10 pathr8 atflags |
| 266 | symlinkat | rdi pathrsi directory descriptorrdx path |
| 267 | readlinkat | rdi directory descriptorrsi stringrdx buffer (written by the kernel)r10 byte count |
| 268 | fchmodat | rdi directory descriptorrsi pathrdx mode |
| 269 | faccessat | rdi directory descriptorrsi pathrdx accmode |
| 270 | pselect6 | rdi valuersi valuerdx valuer10 valuer8 valuer9 value |
| 271 | ppoll | rdi valuersi valuerdx valuer10 valuer8 value |
| 273 | set_robust_list | rdi valuersi value |
| 274 | get_robust_list | rdi valuersi valuerdx value |
| 280 | utimensat | rdi directory descriptorrsi pathrdx o_time2r10 atflags |
| 281 | epoll_pwait | rdi valuersi valuerdx valuer10 valuer8 valuer9 value |
| 288 | accept4 | rdi file descriptorrsi o_addrrdx longr10 sockflags |
| 291 | epoll_create1 | rdi value |
| 292 | dup3 | rdi file descriptorrsi intrdx open flags |
| 293 | pipe2 | rdi o_pfdsrsi open flags |
| 295 | preadv | rdi file descriptorrsi iovec array (written)rdx byte countr10 offset |
| 296 | pwritev | rdi file descriptorrsi iovec array (read)rdx byte countr10 offset |
| 299 | recvmmsg | rdi valuersi valuerdx valuer10 valuer8 value |
| 302 | prlimit | rdi process idrsi resourcerdx i_rlimitr10 o_rlimit |
| 307 | sendmmsg | rdi valuersi valuerdx valuer10 value |
| 316 | renameat2 | rdi directory descriptorrsi pathrdx directory descriptorr10 pathr8 atflags |
| 318 | getrandom | rdi buffer (written by the kernel)rsi byte countrdx int |
| 327 | preadv2 | rdi file descriptorrsi iovec array (written)rdx byte countr10 offsetr8 int |
| 328 | pwritev2 | rdi file descriptorrsi iovec array (read)rdx byte countr10 offsetr8 int |
| 436 | close_range | rdi valuersi valuerdx value |
| 439 | faccessat2 | rdi directory descriptorrsi pathrdx accmoder10 atflags |
| 441 | epoll_pwait2 | rdi valuersi valuerdx valuer10 valuer8 valuer9 value |