BCD (Character Encoding)

Deep Explanation & Connection to Computer Organization & Architecture

What is BCD in Character Encoding?
Definition
Not the same as numeric BCD (4-bit decimal representation).
Here, BCD refers to Binary Coded Decimal Interchange Codes (BCDIC) — a family of 6-bit encodings for letters, numbers, and symbols.

It evolved from IBM punched card codes (1920s) → adopted in early IBM computers → later became EBCDIC (8-bit).

Think of BCDIC as the grandfather of ASCII/EBCDIC, used before ASCII became the global standard.
How it Worked (Real Example)
Imagine an IBM 1401 computer (1960s). You type "HELLO" on a punched card. Each letter was represented by a pattern of holes (punches). That punch pattern was mapped into a 6-bit BCD code.
Character to BCD Mapping
'A' → 110001 (in one BCD variant)
'0' → 111100
'#' → 010011
Punched Card Representation of "HELLO":
H
E
L
L
O
Real World Application
A bank in the 1960s would have customer names and balances stored as punched card records in BCDIC format. Printers, card readers, and mainframes all had to agree on the same BCD table.
Connection to Computer Organization & Architecture
Instruction Set & CPU Design
Early CPUs (like IBM 1401, IBM 1620) had instructions specifically for BCD arithmetic and character handling.

Example: IBM 1401 had Move Characters, Edit, and Add Packed Decimal instructions.

This means the ISA (Instruction Set Architecture) was designed around character codes like BCD.
If a payroll system stored salary as "1234.56" in BCDIC → the CPU had to add/subtract directly in BCD form, not binary integers.
Memory Organization
A character in BCDIC = 6 bits.

But computers usually stored in 8-bit bytes.

So memory alignment was tricky → many machines stored packed BCD (two digits per byte).
"1975" in packed BCD = 0001 1001 0111 0101.

Stored efficiently in memory → saves space but CPU must decode.
Input/Output Devices
Punch cards, magnetic tapes, printers all worked on BCD encoding.

If your punched card used a hole pattern for "%", that had to match the CPU's internal BCD table → otherwise wrong symbols would print.
In Spanish IBM systems, "Ñ" wasn't available → manufacturers mapped it to "@". This caused problems when migrating to ASCII systems later.
Transition to EBCDIC and ASCII
IBM standardized on EBCDIC (8-bit) for System/360 in 1964 → an evolution of BCDIC.

Other companies and universities shifted to ASCII (7-bit, later 8-bit).

This shift is crucial in COA history because:

CPU microcode, ALUs, and memory handling had to change from 6-bit BCD words to 8-bit ASCII bytes.

This was one of the biggest architectural transitions in computing.
Real-World Examples
Example 1: Bank Ledger (1960s)
A punched card record:
CUSTOMER: JOHN DOE
BALANCE: 001234.56
Stored in BCDIC codes on magnetic tape.

When printed on an IBM 1403 printer, the CPU translated BCD → printer characters.

If you migrated this data to ASCII computers in the 1970s, symbols like "@" or "%" might map differently.
Example 2: Unix File Permissions (Today)
Unix permissions use octal (base 8), but historically BCD-based encoding was used in some IBM systems.

When those IBM systems moved to ASCII/Unix machines, conversions had to happen → this is why character encoding compatibility is critical.
Example 3: Character Misinterpretation
Old BCDIC files → converted to ASCII → "Ñ" turned into "/" or "@".

In databases, customer names could get corrupted.

This problem still exists when migrating mainframe (EBCDIC) → modern cloud (ASCII/UTF-8) systems.
Why It Matters in COA Course
Evolution of Data Representation
Shows evolution of data representation: from punched cards → BCDIC → ASCII → Unicode.
Hardware-Software Interface
Connects architecture to real world: Instruction sets (like IBM 1401 BCD arithmetic) show how hardware was built to support character encodings.
Legacy Instructions
Explains why modern CPUs still have decimal instructions (Intel x86 has DAA – Decimal Adjust after Addition, a leftover from BCD arithmetic).
Data Compatibility
Highlights data compatibility issues: Encoding mismatches between ASCII, EBCDIC, and Unicode → still a big deal in software engineering.
Evolution of Character Encoding
1920s
Punched Cards
Physical hole patterns
1950s
BCDIC
6-bit encoding
1964
EBCDIC
IBM 8-bit standard
1967
ASCII
7-bit standard
Summary for COA Connection
BCDIC = 6-bit character codes, derived from punched cards. Used in early IBM/other computers to encode letters, digits, and symbols.
CPU instruction sets, memory layouts, and I/O devices were designed specifically around BCD
Transition to EBCDIC (IBM) and ASCII (others) shaped modern computer architecture
Still affects data migration from mainframes to PCs, and explains why certain CPU instructions exist today