# `wsbh`

[MIPS Documentation](https://asm-editor.specy.app/documentation/mips.md) › [Instructions](https://asm-editor.specy.app/documentation/mips/instruction.md)

Web page: https://asm-editor.specy.app/documentation/mips/instruction/wsbh

**Word swap bytes within halfwords**

Category: Logic

Copies the second register into the first with the two bytes of each halfword exchanged, so 0xAABBCCDD becomes 0xBBAADDCC.

## Forms

- `wsbh $t1, $t2`

## Operands

- `$t1`: Any general-purpose register, `$0` to `$31`, using its numeric or named spelling, such as `$8` or `$t0` (`$zero` is `$0`; `$ra` is `$31`).
- `$t2`: A general-purpose register. It may be the same register as `$t1`.

## Description

Combined with 'rotr $t1,$t1,16' this reverses all four bytes, converting between little and big endian.

## Example

```mips
# Apply wsbh to initialized pattern 0x80FF. Inspect $t2: 0x0000FF80.
li $t0, 0x80FF
wsbh $t2, $t0
```
