03.03.2013 Views

Intel® Architecture Instruction Set Extensions Programming Reference

Intel® Architecture Instruction Set Extensions Programming Reference

Intel® Architecture Instruction Set Extensions Programming Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INSTRUCTION SET REFERENCE - VEX-ENCODED GPR INSTRUCTIONS<br />

LZCNT— Count the Number of Leading Zero Bits<br />

Opcode/<strong>Instruction</strong> Op/<br />

En<br />

Description<br />

<strong>Instruction</strong> Operand Encoding<br />

Counts the number of leading most significant zero bits in a source operand (second operand) returning the result<br />

into a destination (first operand).<br />

LZCNT differs from BSR. For example, LZCNT will produce the operand size when the input operand is zero. It<br />

should be noted that on processors that do not support LZCNT, the instruction byte encoding is executed as BSR.<br />

In 64-bit mode 64-bit operand size requires REX.W=1.<br />

Operation<br />

temp ← OperandSize - 1<br />

DEST ← 0<br />

WHILE (temp >= 0) AND (Bit(SRC, temp) = 0)<br />

DO<br />

temp ← temp - 1<br />

DEST ← DEST+ 1<br />

OD<br />

IF DEST = OperandSize<br />

CF ← 1<br />

ELSE<br />

CF ← 0<br />

FI<br />

IF DEST = 0<br />

ZF ← 1<br />

ELSE<br />

ZF ← 0<br />

FI<br />

64/32<br />

-bit<br />

Mode<br />

CPUID<br />

Feature<br />

Flag<br />

Description<br />

F3 0F BD /r A V/V LZCNT Count the number of leading zero bits in r/m16, return result in r16.<br />

LZCNT r16, r/m16<br />

F3 0F BD /r A V/V LZCNT Count the number of leading zero bits in r/m32, return result in r32.<br />

LZCNT r32, r/m32<br />

REX.W + F3 0F BD /r A V/N.E. LZCNT Count the number of leading zero bits in r/m64, return result in r64.<br />

LZCNT r64, r/m64<br />

Op/En Operand 1 Operand 2 Operand 3 Operand 4<br />

A ModRM:reg (w) ModRM:r/m (r) NA NA<br />

Flags Affected<br />

ZF flag is set to 1 in case of zero output (most significant bit of the source is set), and to 0 otherwise, CF flag is set<br />

to 1 if input was zero and cleared otherwise. OF, SF, PF and AF flags are undefined.<br />

7-10 Ref. # 319433-014

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!