Skip to content

PPACK - Convert ASCII to Packed

Overview

Mnemonic: ppack Function: Convert ASCII decimal to packed BCD Class: ARITHMETIC Privilege: user Format: PPACK <source/ASCII>, <dest/BCD>


Description

Converts ASCII coded decimal string to packed BCD format. Source contains ASCII digits ('0'-'9'), destination receives packed BCD with automatic sign handling and scaling based on descriptor.

Operation:

ASCII digits → Packed BCD
- Parse ASCII string (supports signs: '+', '-', space)
- Pack two decimal digits per byte
- Apply destination scale factor
- Handle sign according to descriptor bit 26

Key Characteristics:

  • Converts human-readable ASCII to efficient BCD storage
  • Automatic sign detection and handling ('+', '-', space)
  • Descriptor-based precision control
  • Two digits packed per byte (4-bit per digit)
  • Essential for user input processing
  • Validates ASCII digit format (traps on invalid)
  • Common in financial and data entry applications

Operands: 2 | Variants: 1


Variants

Variant Opcode Assembly
1/1 0xFEB5 PPACK

Trap Conditions

  • BCD overflow (BO), Invalid operation (IVO)

Data Status Bits

  • Z,S,BO,K: Set based on result

Examples

Example 1: Convert input field

PPACK IFIELD, VAR1

Example 2: User input

PPACK USER_INPUT, AMOUNT

Example 3: String to number

PPACK ASCII_NUM, BCD_VAL

Example 4: Form processing

PPACK FORM.FIELD1, RECORD.PRICE

Example 5: Batch conversion

LOOP:
        PPACK ASCII_FIELDS(W1), BCD_FIELDS(W1)
        W1 INC
        W1 COMP COUNT
        IF<GO LOOP

Example 6: Validation

PPACK INPUT, TEMP
IFKGO INVALID_INPUT

Example 7: Financial entry

PPACK AMOUNT_TEXT, TRANSACTION.AMOUNT

Reference Manual

Section: §17.7


See Also