
ML66517 Family User’s Manual
Chapter 2
CPU Architecture
2 – 16
The upper 8 bits of the PSW (PSWH) contain:
a flag (DD) that is referenced when executing instructions and
flags (CY, ZF, HC, S, OV) that are set to “1” or reset to “0” depending upon instruction execution results.
Therefore, if the following instructions are performed on PSW or PSWH, flag operation may change from
its original function.
(i)
Instructions that load the contents of PSW or PSWH into ACC
(contents of ZF become undefined)
(ii) Bit operation instructions on ZF
(ZF changes depending on its value immediately before execution of the bit operation instruction.)
(iii) Increment, decrement, arithmetic, logic and compare instructions on PSW or PSWH
(The contents of PSW or PSWH immediately after instruction execution are undefined.)
If an interrupt occurs, PSW is automatically saved during interrupt processing and automatically restored by
execution of a RTI instruction.
PSW is assigned to the SFR area. At reset (due to a
RES input, BRK instruction execution, watchdog timer
overflow, or opcode trap), the contents of PSW become 0000H.
Each bit in the PSW is described below.
Bit 15: Carry flag (CY)
The carry flag is set to “1” if:
carry from bit 7 occurs in a byte operation,
borrow to bit 7 occurs in a byte operation,
carry from bit 15 occurs in a word operation, or
borrow to bit 15 occurs in a word operation
as the result of executing an arithmetic or comparison instruction. Otherwise it is reset to “0”. The carry flag
can be set or reset directly by instructions and can be used to transmit or receive data for bits specified by
registers. In addition, the carry flag can be tested by conditional branch instructions.
Bit 14: Zero flag (ZF)
The zero flag is set to “1” when:
the result of an arithmetic instruction is zero,
an instruction to load the ACC is executed and the load contents are zero, or
a bit operation instruction is executed and the target bit is zero.
Otherwise, it is reset to “0”. The zero flag can be tested by conditional branch instructions.
Bit 13: Half carry flag (HC)
The half carry flag is set to “1” if a carry or borrow from bit 3 occurs as a result of executing an
arithmetic or comparison instruction (either a byte and word instruction).
Otherwise, it is reset to “0”.
Bit 12: Data descriptor (DD)
This flag indicates the attributes of data stored in ACC.
When DD is “1”, the 16 bits of data in ACC are determined to be valid.
When DD is “0”, the lower 8 bits of data in ACC are determined to be valid.
Instructions that reference DD when performing arithmetic or data transfer instructions with ACC are
executed as follows.
When DD is “1”, the arithmetic or transfer operation is performed in word units.
When DD is “0”, the arithmetic or transfer operation is performed in byte units.
DD is set to “1” or reset to “0” when a data transfer instruction to ACC is executed and when dedicated set
and reset instructions are executed.