Contents

Digital Electronics
Number Systems
Logic Gates
Boolean Algebra
Combinational Circuits
Sequential Circuits
Memory & PLDs
Digital System Design
Other Topics
Other Subjects
Section Progress87%

13 of 15 articles

ASCII Code

7-bit character encoding, printable and control characters.

Darshan N
Updated: 7 April 2026
11 min read

ASCII is the encoding that maps every keystroke on your keyboard to a 7-bit integer. From the UART inside every microcontroller to the character ROM of a terminal IC, ASCII is the bedrock of human-readable digital communication.

ASCII Code Structure (7-bit)Used in UART (16550A), LCD controllers (HD44780), RS-232 interfacesKey ASCII RangesRange (decimal) — Category0 – 31, 127 : Control characters (NUL, CR, LF)32 – 47 : Symbols (space, !, ", #, $…)48 – 57 : Digits 0–965 – 90 : Uppercase A–Z97 – 122 : Lowercase a–z32 (0x20) : SPACE characterBit Structure7-bit code: b6 b5 b4 b3 b2 b1 b0'A' = 65 = 100 0001'a' = 97 = 110 0001'0' = 48 = 011 0000a - A = 32 = 0x20(toggle bit 5 for case)Extended ASCII: 8-bit, 256 charsFigure 1: ASCII 7-bit structure, key ranges, and case-toggle relationship
Figure 1: ASCII 7-bit encoding — digits start at 48, uppercase at 65, lowercase at 97

Core Concept

ASCII stands for American Standard Code for Information Interchange. It defines 128 characters using 7-bit codes (0 to 127). The first 32 codes (0–31) and code 127 are non-printable control characters used for terminal and communication control: NUL (0), LF (10), CR (13), ESC (27), DEL (127).

The 16550A UART IC transmits ASCII serially at baud rates from 50 to 115200 bps. It appends an optional parity bit (making 8 bits total) for error detection. The HD44780 LCD controller uses ASCII codes directly to display characters from its internal ROM — writing 0x41 to its data register displays the letter A.

A key arithmetic relationship: lowercase and uppercase letters differ by exactly 32 (bit 5 differs). So toggling bit 5 of any letter ASCII code switches its case. Digit '0' starts at 48 (0x30), so converting a digit character to its numeric value requires subtracting 48.

Boolean Expression

There is no single Boolean expression for ASCII — it is a lookup table. But the case-toggle rule gives: lowercase_code = uppercase_code OR 0x20; uppercase_code = lowercase_code AND 0xDF. For digit extraction: numeric_value = ASCII_code AND 0x0F (works for digits 0–9 only because their lower nibble matches the digit value).

Example
Given:
  Character = 'M'
  ASCII of 'M' = 77 decimal = 0100 1101 binary

Formula / Rule:
  Lowercase = ASCII OR 0x20 (set bit 5)
  Uppercase = ASCII AND 0xDF (clear bit 5)

Step by step:
  'M' in binary:    0100 1101
  0x20 in binary:   0010 0000
  OR result:        0110 1101  = 109 decimal = 'm'

Verification:
  'm' = 109, 'M' = 77, difference = 32 = 0x20  -- correct

Digit extraction:
  '7' = 55 = 0011 0111
  AND 0x0F:  0000 0111 = 7 -- numeric value extracted

Final Answer:
  'M' (77) → lowercase 'm' (109) by OR with 0x20
  ASCII digit '7' (55) → numeric 7 by AND with 0x0F
Exam Tip: GATE frequently asks for the ASCII code of a specific character or asks you to identify a character from its code. Memorize three anchor points: '0' = 48 (0x30), 'A' = 65 (0x41), 'a' = 97 (0x61). From these three, you can derive any digit or letter by adding the offset. A common trap: students write ASCII of '5' as 5 instead of 53. Always add 48 to a digit to get its ASCII value.

Key Properties

  • 7-bit standard: 128 characters total; extended ASCII uses 8 bits for 256 characters.
  • Control characters: 0–31 and 127; printable characters: 32–126.
  • 16550A UART: transmits ASCII at up to 115200 bps, 5 V TTL or 3.3 V supply.
  • HD44780 LCD controller maps ASCII 0x20–0x7F directly to its character ROM.
  • Case toggle: uppercase XOR 0x20 = lowercase (bit 5 flip).
  • Digit to value: ASCII_digit - 48 or ASCII_digit AND 0x0F.
  • Unicode is backward-compatible with ASCII for the first 128 code points (U+0000 to U+007F).

Quick Revision

  • ASCII: 7-bit, 128 characters, standard for text in all digital systems.
  • Anchors: NUL=0, SPACE=32, '0'=48, 'A'=65, 'a'=97.
  • Case difference = 32 = 0x20 = bit 5.
  • Control characters 0–31 and 127 are non-printable.
  • UART (16550A) transmits ASCII serially with optional parity bit.
  • Extended ASCII: 8-bit, 256 characters, not standardized (varies by code page).
  • Unicode UTF-8 encodes ASCII identically — first 128 code points are single byte.
  • Exam trap: ASCII of digit 'n' is not n — it is n + 48. Writing ASCII('3') = 3 is a classic wrong answer.

ASCII Code Quiz

Test your knowledge of 7-bit ASCII encoding, character ranges, and control codes.

Question 1 of 3

Q1.The ASCII code for the character 'A' is 65 (decimal). What is the ASCII code for the character 'a'?