
Application Note
Four New Signed Branch Instructions, Detail
AN1218 Rev. 2
27
register X. The quotient is placed in the
accumulator A, and the remainder is placed
in the high order index register H. The
divisor is left unchanged.
New DAA and the
NSA instruction
The decimal adjust accumulator, DAA, and the nibble swap
accumulator, NSA, are new instructions to help with binary coded
decimal(BCD)operations. TheDAAinstructionallowstheusertoadjust
the accumulator so that the number represents a BCD number.
Swapping nibbles is needed for packing BCD numbers into memory.
One use of BCD is data instrumentation. It is easier to store and
manipulate these numbers in BCD rather than convert or decode
numbers from hexadecimal. Packing is used to store decimal numbers
into memory. Instead of one byte storing one decimal, the NSA
instruction easily swaps nibbles in the accumulator so that two decimal
numberscanbestoredinonebyte.
AppendixJ—FiveMiscellaneous
CPU08 Instructions Including BCD, Divide, and CCR Operations
gives examples using the DAA instruction and the NSA instruction.
Refer to
Appendix L — CPU08 BCD Example Code
for an example of
BCD code.
DAA
Decimal Adjust Accumulator
Operation:
(A)10
Description: Adjusts the contents of the accumulator and
the state of the CCR carry bit after binary
coded decimal operations so that there is a
correct BCD sum and an accurate carry
indication. The state of the CCR half carry
bit affects operation.
NSA
Nibble Swap Accumulator
Operation:
A
←
(A[3:0]:A[7:4])
Description: Swaps upper and lower nibbles (4 bits) of
the accumulator. This is used for more
ef cient stor age and use of binary coded
operands.
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.