Skip to content
Advanced Microprocessor

8051 Architecture, Harvard Memory & On-Chip RAM Map

Computer-on-a-chip, 128 bytes RAM (Register Banks 0–3, Bit-Addressable Area, Scratchpad), SFR register space, and PSW flags.

Knova editors12 min readQuick checkSources

The 8051 Microcontroller Architecture

Introduced by Intel in 1980, the 8051 is an 8-bit microcontroller designed specifically for embedded control systems.

Unlike a general-purpose microprocessor (such as the 8085 or 8086) which contains only a CPU and requires external chips for RAM, ROM, timers, and I/O ports, the 8051 is a self-contained "computer on a chip".

Key Hardware Specifications

A standard 8051 microcontroller integrates the following on a single silicon die:

  • 8-bit CPU with Boolean bit-processing capabilities.
  • 4 KB of On-Chip Program Memory (ROM/EPROM/Flash): Expandable to 64 KB externally.
  • 128 Bytes of On-Chip Data Memory (RAM): Expandable to 64 KB externally.
  • 32 Bidirectional I/O Lines: Organized as four 8-bit ports (P0,P1,P2,P3P_0, P_1, P_2, P_3).
  • Two 16-bit Timers/Counters: Timer 0 and Timer 1.
  • Full-Duplex UART Serial Channel: Supports programmable baud rates.
  • Five-Vector, Two-Priority Interrupt Architecture.
  • On-chip crystal oscillator generating system timing (typically 11.0592 MHz11.0592\text{ MHz} or 12 MHz12\text{ MHz}).

Harvard Architecture: Separate Code and Data Spaces

The 8051 employs a Harvard Architecture, where program code (ROM) and data memory (RAM) exist in completely separate physical address spaces and utilize independent bus paths:

Memory SpaceAddress RangeAccess InstructionControl Strobe
Internal Program ROM0000H−0FFFH (4 KB)0000\text{H} - 0\text{FFFH } (4\text{ KB})MOVC A, @A+DPTRPSEN‾ (Program Store Enable)\overline{PSEN} \text{ (Program Store Enable)}
External Program ROM0000H−FFFFH (64 KB)0000\text{H} - \text{FFFFH } (64\text{ KB})MOVC A, @A+PCPSEN‾\overline{PSEN}
Internal Data RAM00H−7FH (128 Bytes)00\text{H} - 7\text{FH } (128\text{ Bytes})MOV A, direct / @RiInternal CPU bus
Special Function Regs80H−FFH (21 SFRs)80\text{H} - \text{FFH } (21\text{ SFRs})MOV directInternal CPU bus
External Data RAM0000H−FFFFH (64 KB)0000\text{H} - \text{FFFFH } (64\text{ KB})MOVX A, @DPTRRD‾ and WR‾\overline{RD} \text{ and } \overline{WR}

Internal RAM Organization (128 Bytes)

The 128128 bytes of on-chip RAM (00H−7FH00\text{H}-7\text{FH}) are partitioned into three functional areas:

Fig 9.1: Intel 8051 Internal RAM Memory Layout Across Banks, Bit-Addressable, and SFR Areas
Fig 9.1: Intel 8051 Internal RAM Memory Layout Across Banks, Bit-Addressable, and SFR Areas

1. Working Register Banks (00H−1FH00\text{H}-1\text{F}\text{H})

Thirty-two bytes allocated as four distinct banks (Bank 0, Bank 1, Bank 2, Bank 3), each containing eight 8-bit registers (R0−R7R_0-R_7). The active bank is chosen dynamically by the RS1RS_1 and RS0RS_0 bits of the Program Status Word (PSW):

RS1RS_1RS0RS_0Active Register BankRAM Address Range
00Bank 0 (Default on reset)00H−07H00\text{H} - 07\text{H}
01Bank 108H−0FH08\text{H} - 0\text{FH}
10Bank 210H−17H10\text{H} - 17\text{H}
11Bank 318H−1FH18\text{H} - 1\text{FH}

2. Bit-Addressable RAM (20H−2FH20\text{H}-2\text{F}\text{H})

Sixteen bytes (16×8=128 bits16 \times 8 = 128\text{ bits}) that can be accessed either as standard 8-bit bytes (20H−2FH20\text{H}-2\text{F}\text{H}) or as 128 individually addressable bits numbered 00H00\text{H} to 7FH7\text{FH}.

Instructions such as SETB 05H, CLR 2AH, or JB 7FH, TARGET test and modify individual boolean flags in a single clock cycle without requiring byte masking.

3. General-Purpose Scratchpad RAM (30H−7FH30\text{H}-7\text{F}\text{H})

Eighty bytes of general-purpose read/write storage for variables, buffers, and the system stack.

The Program Status Word (PSW)

The 8-bit Program Status Word (D0HD0\text{H}) contains math flags and bank selection bits:

D7D_7D6D_6D5D_5D4D_4D3D_3D2D_2D1D_1D0D_0
CYACF0F_0RS1RS_1RS0RS_0OV-P
  • CY (Carry Flag): Also functions as the 1-bit accumulator for Boolean operations.
  • AC (Auxiliary Carry): Carries between BCD nibbles during addition.
  • F0 (User Flag 0): General-purpose programmable bit flag.
  • RS1, RS0 (Register Bank Select): Selects active register bank 0−30-3.
  • OV (Overflow Flag): Indicates signed arithmetic overflow.
  • P (Parity Flag): Automatically tracks even parity in the Accumulator (1=even number of 1s1 = \text{even number of 1s}).
Harvard Architecture Memory Architecture

Intel 8051 Internal RAM & Special Function Registers (SFR)

Explore 128 bytes of low internal RAM (Register Banks 0–3, Bit-Addressable Area, Scratchpad) and Special Function Registers (SFRs).

On-Chip Memory Space00H – FFH
Special Function Registers (SFR)Ports, Timers, ACC, B, PSW, SCON
80H – FFH
General Purpose RAM (Scratchpad)80 bytes general storage & stack
30H – 7FH
Bit-Addressable RAM16 bytes = 128 individual bit addresses
20H – 2FH
4 Register Banks (R0–R7 each)Bank 0, 1, 2, 3 selected by PSW.4 & PSW.3
00H – 1FH
Register Banks (32 bytes total)
00H – 1FH
Selected via Program Status Word (PSW):RS1=0, RS0=0. Address range: 0X00H – 0X07H.
R0
00H
R1
01H
R2
02H
R3
03H
R4
04H
R5
05H
R6
06H
R7
07H
Try it
8051 Bit-Addressable Memory Mapping: What is the direct bit address of bit 3 of RAM byte location 25H25\text{H}?

Sources

  1. 1.Intel 8051 Microcontroller Datasheet · reference · Wikipedia (opens in a new tab)

Was this chapter useful?

Editors read every answer.

Star this chapter

Each star goes once to every reader who improved this chapter.

Finished reading?

Mark it to keep your place in the course.