40
ImageCraft Assembly Language Guide, Document # 001-44475 Rev. *B
M8C Instruction Set
4.3
Bitwise AND
AND
Computes the logical AND for each bit position using both arguments. The result of the logical AND
is placed in the corresponding bit position for the first argument.
The Carry Flag is only changed when the
AND F, expr
instruction is used. The CF will be set to the
result of the logical AND of the CF at the beginning of instruction execution and the second argu-
ment’s value at bit position 2 (i.e., F[2] and expr[2]).
For the
AND F, expr
instruction the ZF is handled the same as the CF in that it is changed as a
result of the logical AND of the ZF’s value at the beginning of instruction execution and the value of
the second argument’s value at bit position 1 (i.e., F[1] and expr[1]). However, for all other
AND
instructions the Zero Flag will be set or cleared based on the result of the logical AND operation. If
the result of the AND is that all bits are zero, the Zero Flag will be set; otherwise, the Zero Flag Is
cleared.
Note that AND (or OR or XOR, as appropriate) is a read-modify write instruction. When operating on
a register, that register must be of the read-write type. Bitwise AND to a write only register will gener-
ate nonsense.
Instructions
Operation
Opcode
Cycles Bytes
Mnemonic
Argument
AND
A, expr
0x21
4
2
AND
A, [expr]
0x22
6
2
AND
A, [X+expr]
0x23
7
2
AND
[expr], A
0x24
7
2
AND
[X+expr], A
0x25
8
2
AND
[expr], expr
0x26
9
3
AND
[X+expr], expr
0x27
10
3
AND
REG[expr], expr
0x41
9
3
AND
REG[X+expr],
expr
0x42
10
3
AND
F, expr
0x70
4
2
Conditional
Flags:
CF
ZF
Affected only by the
AND F, expr
instruction.
Set if the result is zero; cleared otherwise.
AND F
,
expr
will set this flag as a result of the AND operation.
Example 1:
and
A, 0x00
;A=0, CF=unchanged, ZF=1
Example 2:
and
F, 0x00
;F=0 therefore CF=0, ZF=0
A
A & k
A
A & ram[k]
A
A & ram[X+k]
ram k
ram k
& A
ram X k
+
ram X k
+
& A
ram k
1
ram k
1
& k
2
ram X k
1
+
ram X k
1
+
& k
2
reg k
1
reg k
1
& k
2
reg X k
1
+
reg X k
1
+
& k
2
F
F & k
Summary of Contents for PSoC DESIGNER ImageCraft M8C
Page 6: ...6 ImageCraft Assembly Language Guide Document 001 44475 Rev B Contents Feedback ...
Page 10: ...10 ImageCraft Assembly Language Guide Document 001 44475 Rev B Introduction Feedback ...
Page 24: ...24 ImageCraft Assembly Language Guide Document 001 44475 Rev B M8C Microprocessor Feedback ...
Page 95: ...ImageCraft Assembly Language Guide Document 001 44475 Rev B 95 Assembler Directives Feedback ...
Page 96: ...96 ImageCraft Assembly Language Guide Document 001 44475 Rev B Assembler Directives Feedback ...
Page 104: ...104 ImageCraft Assembly Language Guide Document 001 44475 Rev B Feedback ...
Page 108: ...108 ImageCraft Assembly Language Guide Document 001 44475 Rev B Index Feedback ...