andi


Logical product (immediate).

[Syntax]

-

andi imm, reg1, reg2

 

The following can be specified for imm:

-

Absolute expression having a value of up to 32 bits

-

Relative expression

-

Either of the above expressions with HIGHW, LOWW, or HIGHW1 applied

[Function]

ANDs the value of the absolute expression, relative expression, or expression with HIGHW, LOWW, or HIGHW1 applied specified by the first operand with the value of the register specified by the second operand, and stores the result into the register specified by the third operand.

[Description]

-

If the following is specified as imm, the assembler generates one andi machine instructionNote 1.

(a)

Absolute expression having a value in the range of 0 to 65,535

andi    imm16, reg1, reg2
andi    imm16, reg1, reg2

(b)

Relative expression having !label or %labelNote 2

andi    !label, reg1, reg2
andi    !label, reg1, reg2
andi    %label, reg1, reg2
andi    %label, reg1, reg2

(c)

Expression with HIGHW, LOWW, or HIGHW1

andi    imm16, reg1, reg2
andi    imm16, reg1, reg2

Note 1.

The andi machine instruction takes an immediate value of 0 to 65,535 (0 to 0xFFFF) as the first operand.

Note 2.

!label and %label are treated as 16-bit value (zero-extended).

 

-

If the following is specified for imm, the assembler executes instruction expansion to generate multiple machine instructions.

(a)

Absolute expression having a value in the range of -16 to -1

If reg2 is r0

andi    imm5, reg1, r0
mov     imm5, r1
and     reg1, r1

Else if reg2 is the same as reg1

andi    imm5, reg1, reg2
mov     imm5, r1
and     r1, reg2

Else

andi    imm5, reg1, reg2
mov     imm5, reg2
and     reg1, reg2

(b)

Absolute expression having a value in the range of -32,768 to -17

If reg2 is r0

andi    imm16, reg1, r0
movea   imm16, r0, r1
and     reg1, r1

Else if reg2 is the same as reg1

andi    imm16, reg1, reg2
movea   imm16, r0, r1
and     r1, reg2

Else

andi    imm16, reg1, reg2
movea   imm16, r0, reg2
and     reg1, reg2

(c)

Absolute expression exceeding the above ranges

<1>

If all the lower 16 bits of the value of imm are 0

If reg2 is r0

andi    imm, reg1, r0
movhi   HIGHW(imm), r0, r1
and     reg1, r1

Else if reg2 is the same as reg1

andi    imm, reg1, reg2
movhi   HIGHW(imm), r0, r1
and     r1, reg2

Else

andi    imm, reg1, reg2
movhi   HIGHW(imm), r0, reg2
and     reg1, reg2

<2>

Else

If reg2 is r0

andi    imm, reg1, r0
mov     imm, r1
and     reg1, r1

Else if reg2 is the same as reg1

andi    imm, reg1, reg2
mov     imm, r1
and     r1, reg2

Else

andi    imm, reg1, reg2
mov     imm, reg2
and     reg1, reg2

(d)

Relative expression having $label for a label having a definition in the sdata/sbss-attribute section

If reg2 is r0

andi    $label, reg1, r0
movea   $label, r0, r1
and     reg1, r1

Else if reg2 is the same as reg1

andi    $label, reg1, reg2
movea   $label, r0, r1
and     r1, reg2

Else

andi    $label, reg1, reg2
movea   $label, r0, reg2
and     reg1, reg2

(e)

Relative expression having #label or label, or that having $label for a label having no definition in the sdata/sbss-attribute section

If reg2 is r0

andi    #label, reg1, r0
mov     #label, r1
and     reg1, r1
andi    label, reg1, r0
mov     label, r1
and     reg1, r1
andi    $label, reg1, r0
mov     $label, r1
and     reg1, r1

Else if reg2 is the same as reg1

andi    #label, reg1, reg2
mov     #label, r1
and     r1, reg2
andi    label, reg1, reg2
mov     label, r1
and     r1, reg2
andi    $label, reg1, reg2
mov     $label, r1
and     r1, reg2

Else

andi    #label, reg1, reg2
mov     #label, reg2
and     reg1, reg2
andi    label, reg1, reg2
mov     label, reg2
and     reg1, reg2
andi    $label, reg1, reg2
mov     $label, reg2
and     reg1, reg2

[Flag]

CY

---

OV

0

S

1 if the word data MSB of the result is 1, 0 if not

Z

1 if the result is 0, 0 if not

SAT

---