# `and`

[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/and

**Bitwise AND**

Category: Logic

Sets the first register to the bitwise AND of the second and the third, or an immediate, so each result bit is 1 only where both inputs are 1.

Used in: [Arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/mips/think-in-assembly/arithmetic-logic-and-bits.md) (MIPS assembly)

## Forms

- `and $t1, $t2, $t3`

## Pseudo-instructions

The processor does not have these forms. The assembler replaces each of them with one or more real instructions. Open a row to see them.

- `and $t1, $t2, uimm16` · Set $t1 to ($t2 bitwise-AND 16-bit unsigned immediate)
  - `and $t1,$t2,100` → `andi $t1, $t2, uimm16`

- `and $t1, uimm16` · Set $t1 to ($t1 bitwise-AND 16-bit unsigned immediate)
  - `and $t1,100` → `andi $t1, $t1, uimm16`

## 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`.
- `$t3`: A general-purpose register. It may be the same register as `$t1`.
- `uimm16`: An unsigned 16-bit immediate, `0` to `65535`.

## Description

Each bit of $t1 is 1 only if the corresponding bit is 1 in both $t2 and $t3. Commonly used to mask (isolate) specific bits in a value.

## Example

```mips
# Initialize both inputs, then execute and with initialized inputs. Inspect $t2: 3.
li $t0, 7
li $t1, 3
and $t2, $t0, $t1
```
