CHAPTER 11 INSTRUCTION SET
236 User’s Manual U10676EJ3V0UM
11.1.4 Base number adjustment instruction
Some applications require that the result of addition or subtraction of 4-bit data (which is carried out in binary) be
converted into a decimal number or into a number with a base of 6, such as time.
Therefore, the
µ
PD754244 is provided with base number adjustment instructions that adjust the result of addition
or subtraction of 4-bit data into a number with any base.
(1) Base adjustment of result of addition
Where the base number to which the result of addition executed is to be adjusted is m, the contents of
the accumulator and memory are added in the following combination, and the result is adjusted to a number
with a base of m.
ADDS A, #16 – m
ADDC A, @HL ; A, CY A + (HL) + CY
ADDS A, #m
Occurrence of an overflow is indicated by the carry flag.
If a carry occurs as a result of executing the ADDC A, @HL instruction, the ADDS A, #n4 instruction is
skipped. If a carry does not occur, the ADDS A, #n4 instruction is executed. At this time, however, the
skip function of the instruction is disabled, and the following instruction is not skipped even if a carry occurs
as a result of addition. Therefore, a program can be written after the ADDS A, #n4 instruction.
Example To add accumulator and memory in decimal
ADDS A, #6
ADDC A, @HL ; A, CY A + (HL) + CY
ADDS A, #10
(2) Base adjustment of result of subtraction
Where the base number into which the result of subtraction executed is to be adjusted is m, the contents
of memory (HL) are subtracted from those of the accumulator in the following combination, and the result
of subtraction is adjusted to a number with a base of m.
SUBC A, @HL
ADDS A, #m
Occurrence of an underflow is indicated by the carry flag.
If a borrow does not occur as a result of executing the SUBC A, @HL instruction, the following ADDS
A, #n4 instruction is skipped. If a borrow occurs, the ADDS A, #n4 instruction is executed. At this time,
the skip function of this instruction is disabled, and the following instruction is not skipped even if a carry
occurs as a result of addition. Therefore, a program can be written after the ADDS A, #n4 instruction.