
2–7
7700 FAMILY SOFTWARE MANUAL
2.1 Central processing unit (CPU)
CENTRAL PROCESSING UNIT (CPU)
2.1.9 Processor status register (PS)
Processor status register is an 11-bit register. It consists of the flags to indicate the result of operation and
the processor interrupt priority level. The flags C, Z, V, and N are tested by branch instructions.
Figure 2.1.5 shows the structure of the processor status register.
The details of the processor status register flags are described below.
Fig. 2.1.5 Processor status register structure
(1) Carry flag (C)
The carry flag is assigned to bit 0 of the processor status register. It contains the carry or borrow bit
from the arithmetic and logic unit (ALU) after an arithmetic operation. This flag is also affected by shift
and rotate instructions. This flag can be set with the
SEC
or
SEP
instruction and cleared with the
CLC
or
CLP
instruction.
(2) Zero flag (Z)
The zero flag is assigned to bit 1 of the processor status register. It is set to “1” when the result of
an arithmetic operation or data transfer is zero, and cleared to “0” when otherwise. This flag can be
set with the
SEP
instruction and cleared with the
CLP
instruction.
Note:
This flag has no meaning in decimal mode addition (the
ADC
instruction).
(3) Interrupt disable flag (I)
The interrupt disable flag is assigned to bit 2 of the processor status register. It disables all maskable
interrupts (interrupts other than watchdog timer, the
BRK
instruction, and zero division). Interrupts are
disabled when this flag is “1”. When an interrupt request is accepted, this flag is automatically set to
“1” to avoid multiple interrupts. This flag can be set with the
SEI
or
SEP
instruction and cleared with
the
CLI
or
CLP
instruction. This flag is set to “1” at reset.
(4) Decimal mode flag (D)
The decimal mode flag is assigned to bit 3 of the processor status register. It determines whether
addition and subtraction are performed in binary or decimal. Binary arithmetic is performed when this
flag is “0”. When it is “1”, decimal arithmetic is performed with each word treated as two or four digits
decimal (determined by the data length flag m). Decimal adjust is performed automatically. Decimal
operation is possible only with the
ADC
and
SBC
instructions. This flag can be set with the
SEP
instruction and cleared with the
CLP
instruction. This flag is cleared to “0” at reset.
(5) Index register length flag (x)
The index register length flag is assigned to bit 4 of the processor status register. It determines
whether the index register X and index register Y are used as a 16-bit register or an 8-bit register.
The register is used as a 16-bit register when this flag x is “0”, and as an 8-bit register when it is “1”.
This flag can be set with the
SEP
instruction and cleared with the
CLP
instruction. This flag is cleared
to “0” at reset.
C
When transferring between different bit lengths, the data is transferred with the length of the
destination register, but except for the
TXA
,
TYA
,
TXB
, and
TYB
instructions.
Note
: Bits 11 to 15 are always “0” when the contents of the processor status register are read.
b15
b8
b7
b0
b1
b2
b3
b4
b5
b6
b14
b9
b10
b11
b12
b13
0
N
C
Z
I
D
x
m
V
0
IPL
0
0
0