|
SPECIAL3 011111 |
00000 |
rt |
rd |
BITSWAP 00000 |
BSHFL 100000 |
|
SPECIAL3 011111 |
00000 |
rt |
rd |
DBITSWAP 00000 |
DBSHFL 100100 |
|
6 |
5 |
5 |
5 |
5 |
6 |
BITSWAP DBITSWAP |
Swaps (reverses) bits in each byte | |
BITSWAP rd,rt |
MIPS32 Release 6 |
Swaps (reverses) bits in each byte |
DBITSWAP rd,rt |
MIPS64 Release 6 |
Swaps (reverses) bits in each byte |
Swaps (reverses) bits in each byte
GPR[rd].byte(i) =reverse_bits_in_byte(GPR[rt].byte(i)), for all bytes i
Each byte in input GPR rt is moved to the same byte position in output GPR rd, with bits in each byte reversed.
BITSWAP is a 32-bit instruction. BITSWAP operates on all 4 bytes of a 32-bit GPR on a 32-bit CPU. On a 64-bit
CPU, BITSWAP operates on the low 4 bytes, sign extending to 64-bits.
DBITSWAP operates on all 8 bytes of a 64-bit GPR on a 64-bit CPU.
BITSWAP: None.
The BITSWAP instruction is introduced by and required as of Release 6.
The DBITSWAP instruction is introduced by and required as of Release 6.
BITSWAP:
for i in 0 to 3 do /* for all bytes in 32-bit GPR width */
tmp.byte(i) = reverse_bits_in_byte( GPR[rt].byte(i) )
endfor
GPR[rd] = sign_extend.32( tmp )
DBITSWAP:
for i in 0 to 7 do /* for all bytes in 64-bit GPR width */
tmp.byte(i) = reverse_bits_in_byte( GPR[rt].byte(i) )
endfor
GPR[rd] = tmp
where
function reverse_bits_in_byte(inbyte)
outbyte7 = inbyte0
outbyte6 = inbyte1
outbyte5 = inbyte2
outbyte4 = inbyte3
outbyte3 = inbyte4
outbyte2 = inbyte5
outbyte1 = inbyte6
outbyte0 = inbyte7
return outbyte
end function
BITSWAP: None
DBITSWAP: Reserved Instruction.
The Release 6 BITSWAP instruction corresponds to the DSP Module BITREV instruction, except that the latter bitreverses the least-significant 16-bit halfword of the input register, zero extending the rest, while BITSWAP operates on 32-bits.