pre-Release 6
SPECIAL2 011100 |
rs |
rt |
rd |
0 00000 |
CLZ 100000 |
6 |
5 |
5 |
5 |
5 |
6 |
Release 6
SPECIAL 000000 |
rs |
00000 |
rd |
00001 |
CLZ 010000 |
6 |
5 |
5 |
5 |
5 |
6 |
CLZ rd, rs |
MIPS32 |
Count Leading Zeros in Word |
Count Leading Zeros in Word
Count the number of leading zeros in a word.
GPR[rd] = count_leading_zeros GPR[rs]
Bits 31..0 of GPR rs are scanned from most significant to least significant bit. The number of leading zeros is counted and the result is written to GPR rd. If no bits were set in GPR rs, the result written to GPR rdis 32.
Pre-Release 6: To be compliant with the MIPS32 and MIPS64 Architecture, software must place the same GPR number in both the rt and rd fields of the instruction. The operation of the instruction is UNPREDICTABLE if the rt and
rd fields of the instruction contain different values. Release 6's new instruction encoding does not contain an rt field.
If GPR rs does not contain a sign-extended 32-bit value (bits 63..31 equal), then the results of the operation are
UNPREDICTABLE.
This instruction has been recoded for Release 6.
if NotWordValue(GPR[rs]) then UNPREDICTABLE endif temp = 32 for i in 31 .. 0 if GPR[rs]i = 1 then temp = 31 - i break endif endfor GPR[rd] = temp
None
Release 6 sets the 'rt' field to a value of 00000.