# `abcd`

[M68K Documentation](https://asm-editor.specy.app/documentation/m68k.md) › [Instructions](https://asm-editor.specy.app/documentation/m68k/instruction.md)

Web page: https://asm-editor.specy.app/documentation/m68k/instruction/abcd

**Add decimal with extend**

Category: Arithmetic

Adds two packed decimal bytes and X, and stores the packed decimal result in the destination.

Size .b

## Flags

| Flag | Effect |
| --- | --- |
| X | depends on the result |
| N | undefined (do not rely on it) |
| Z | depends on the result |
| V | undefined (do not rely on it) |
| C | depends on the result |

Reads: X

## Forms

- `abcd Dn, Dn`
- `abcd -(An), -(An)`

## Operands

- [`Dn`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/direct.md): A data register, `d0` to `d7`.
- [`-(An)`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/indirect-post-pre-increment.md): Decreases an address register by 1, 2 or 4 bytes for a byte, word or long access, then accesses memory there. A byte access through `sp` decreases it by 2 to keep it even.

## Description

Each byte holds two decimal digits, one in each half: `$42` represents 42. Both operands must be data registers, or both must use predecrement addressing. The registers need not be the same.

For a decimal number stored in several bytes, start with its least significant pair of digits. C and X carry a result above 99 into the next byte. Set Z and clear X before the first byte, for example with `move.w #4, ccr`: each zero result preserves Z, and each nonzero result clears it, so the final Z tests the whole number.
