and
Bitwise AND
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 bitsMIPS assembly
Forms
and , ,
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.
-
Set $t1 to ($t2 bitwise-AND 16-bit unsigned immediate)
-
Set $t1 to ($t1 bitwise-AND 16-bit unsigned immediate)
Operands
$t1- Any general-purpose register,
$0to$31, using its numeric or named spelling, such as$8or$t0($zerois$0;$rais$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,
0to65535.
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.
# Initialize both inputs, then execute and with initialized inputs. Inspect $t2: 3.
li $t0, 7
li $t1, 3
and $t2, $t0, $t1