
Chapter 6
6.4 Logic and Arithmetic Operation
The EM60000 series provide a complete set of logic and arithmetic operations,
as shown in section on
Arithmetic Logic Unit
(Section 2.2 of Chapter 2). The
operations include AND, COM, COMA, OR, XOR, CLR, RLC, RLCA, RRC,
RRCA, BC, BS, ADD, DAA, DEC, DECA, INC, MPY, SUB, and INCA.
Through these instructions, you can perform logic and arithmetic functions.
The following examples demonstrate some of the logic & arithmetic operations.
From these examples, you can easily grasp the aspects of instruction syntax.
Each time a logic & arithmetic operation occurs, a number of status flags are
changed by the ALU. You should check the resulting status flag register at the
end of each operation. The following shows which status flags are affected by
which instructions.
Status Flag
Instructions that Affect Status Flag
Z (Zero flag)
CLR, MOV, OR, AND, XOR, COM, SUB, DECA, DEC, ADD,
INC, INCA
C (Carry flag)
RRCA, RRC, RLCA, RLCDAA, SUB, ADD
DC (Auxiliary carry flag)
ADD, SUB
6.4.1 Example - Applying the AND and COMA Instructions
;--------------------------------------------------------------
; The routine demonstrates the AND and COMA instructions.
;--------------------------------------------------------------
ORG
0x0000
JMP POWERON
; go to power-on procedure
ORG 0x0010
; power-on reset procedure
POWERON:
MOV A, @0b00111100
MOV 0x15, A
; R15=0x3C
MOV A, @0b11101110
MOV 0x16, A
; R16=0xEE
AND A, 0x15
; A=A&R15=0x2C
;--------------------------------------------------------------
MOV A, @0x78
; A=0x78
AND 0x16, A
; A=A&R16=0x68
;--------------------------------------------------------------
COMA 0x16
; A=0x97
AND A, @0x3C
; A=A&0x3C=0x14
OVER: JMP
OVER
EM60000 Series User’s Manual
Software Application
•
77