# `unpk`

[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/unpk

**Unpack BCD** · 68020

Category: Arithmetic

Unpacks a byte of packed decimal into two bytes, one digit in each, and adds an adjustment, such as the one that makes them ASCII digits.

68020 only: select `opt p=68020` before any code or data

## Flags

| Flag | Effect |
| --- | --- |
| X | not changed |
| N | not changed |
| Z | not changed |
| V | not changed |
| C | not changed |

## Forms

- `unpk Dn, Dn, #imm`
- `unpk -(An), -(An), #imm`

## Operands

- [`Dn`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/direct.md): A data register, `d0` to `d7`.
- [`#imm`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/immediate.md): A 16-bit adjustment added after unpacking, for example `#$3030` to produce ASCII digits.
- [`-(An)`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/indirect-post-pre-increment.md): The source address decreases by 1 before reading one byte, or by 2 if it is `sp`. The destination address decreases by 2 before writing two bytes.

## Description

`unpk d0, d1, #$3030` converts `$42` to `$3432`, the ASCII text `'42'`.

With data-register operands, it reads the source’s low byte and writes the destination’s low word, leaving the upper word unchanged. With two predecrement operands, it decreases the source address by 1 and reads one byte (by 2 when the source is `sp`), then decreases the destination address by 2 and writes two bytes. The flags are unchanged. [pack](https://asm-editor.specy.app/documentation/m68k/instruction/pack.md) performs the reverse conversion.

## Example

```m68k
opt p=68020
* --- Print a byte of packed decimal as two digits ---
move.b #$42, d0 ; 42 in packed decimal
unpk d0, d1, #$3030 ; d1 = 13362, which is $3432: the text "42"
lea text, a1
move.w d1, (a1)
move.b #14, d0
trap #15 ; prints "42"
bra END

text:
    dc.b 0, 0, 0, 0 ; the two digits, and the 0 that ends the text

END:
```
