CTZ
Count Trailing Zeros
CTZ rd, rs1
Counts the number of 0 bits at the LSB end of the register.
Details
CTZ counts the number of trailing (least-significant) zero bits in rs1, writing the count to rd. Returns XLEN if rs1 is zero.
Pseudocode Operation
int count = 0; while(rs1[count] == 0) count++; R[rd] = count;
Example
CTZ x10, x11
Encoding
Binary Layout
0110000
31:25
00001
24:20
rs1
19:15
001
14:12
rd
11:7
0010011
6:0
Operands
-
rd
Destination register (integer) -
rs1
Source