pre-Release 6
SPECIAL2 011100 |
rs |
rt |
rd |
0 00000 |
CLO 100001 |
6 |
5 |
5 |
5 |
5 |
6 |
Release 6
SPECIAL 000000 |
rs |
00000 |
rd |
00001 |
CLO 010001 |
6 |
5 |
5 |
5 |
5 |
6 |
CLO rd, rs |
MIPS32 |
Count Leading Ones in Word |
Count Leading Ones in Word
To count the number of leading ones in a word.
GPR[rd] = count_leading_ones GPR[rs]
Bits 31..0 of GPR rs are scanned from most significant to least significant bit. The number of leading ones is counted and the result is written to GPR rd. If all of bits 31..0 were set in GPR rs, the result written to GPR rd is 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 = 0 then temp = 31 - i break endif endfor GPR[rd] = temp
None
As shown in the instruction drawing above, the Release 6 architecture sets the 'rt' field to a value of 00000.