The following table represents a 64 byte long block of main memory being used to hold three data arrays, one starting at address $04, the second starting at $A0, and the third starting at $20.

The main memory representation broken into to tables to fit on the screen/page. Addresses and contents of cells are expressed as hexadecimal values.

Segment 0 Segment 1 Segment 2 Segment 3
Line 0 Line 1 Line 2 Line 3 Line 0 Line 1 Line 2 Line 3 Line 0 Line 1 Line 2 Line 3 Line 0 Line 1 Line 2 Line 3
Mem
Addr
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 m 18 19 1a m 1c 1d 1e 1f
Data D o n ' t - c r y - b e c a u s e - i t ' s - o v e r ,        
Segment 4Segment 5 Segment 6Segment 7
Line 0 Line 1 Line 2 Line 3 Line 0 Line 1 Line 2 Line 3 Line 0 Line 1 Line 2 Line 3 Line 0 Line 1 Line 2 Line 3
Mem
Addr
20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 S 38 39 3a 3b 3c 3d 3e 3f
Data s m i l e - b e c a u s e - i t - h a p p e n e d .            

The data cache is 2 cells by 4 lines, each cell holds 1 byte of data. But, because it is 2-way set associative, there are two instances of the cache.

Only data is cached in this example (not instuctions).

Empty cache
Click to see 2-way
cache in action.
LDA $00 - Miss - SADC $0A - Miss - e2SBC $22 - Miss - b4
00h = 00000 00 0b
tag = 0, line = 0, byte = 0
0Ah = 00001 o 0b
tag = 1, line = 1, byte = 0
22h = 00100 o 0b
tag = 4, line = 1, byte = 0
LineTag  Data 
03    
02    
o    
00    
03    
02    
o    
00    
Grey not part of cache
LineTag  Data 
03    
02    
o    
00    
03    
02    
o    
00 0So
Grey not part of cache
LineTag  Data 
03    
02    
o    
00    
03    
02    
o 1e2dc
00 0So
Grey not part of cache
LineTag  Data 
03    
02    
o 4b4a1
00    
03    
02    
o 1e2dc
00 0So
Grey not part of cache

LDA $o - Hit - oADC $0B - Hit - dcSTA $23 - Hit - 4b
01h = 00000 00 m
tag = 0, line = 0, byte = 1
0Bh = 00001 o m
tag = 1, line = 1, byte = 1
23h = 00100 o m
tag = 4, line = 1, byte = 1
LineTag  Data 
03    
02    
o 4b44b
00    
03    
02    
o 1e2dc
00 0So
Grey not part of cache
Line Tag  Data 
03    
02    
o 4b44b
00    
03    
02    
o 1e2dc
00 0So
Grey not part of cache
Line Tag  Data 
03    
02    
o 4b44b
00    
03    
02    
o 1e2dc
00 0So
Grey not part of cache

LDA $02 - Miss - -ADC $0C - Miss - b8SBC $24 - Miss - a1
02h = 00000 o 0b
tag = 0, line = 1, byte = 0
0Ch = 00001 10 0b
tag = 1, line = 2, byte = 0
24h = 00100 10 0b
tag = 4, line = 2, byte = 0
LineTag  Data 
03    
02    
o 4b44b
00    
03    
02    
o 0-m
00 0So
Grey not part of cache
Line Tag  Data 
03    
02    
o 4b44b
00    
03    
02 1b835
o 0-m
00 0So
Grey not part of cache
Line Tag  Data 
03    
02 4a17c
o 4b44b
00    
03    
02 1b835
o 0-m
00 0So
Grey not part of cache

ADC $03 - Hit - mADC $0D - Hit - 35SBC $25 - Hit - 7c
03h = 00000 o m
tag = 0, line = 1, byte = 1
0Dh = 00001 10 m
tag = 1, line = 2, byte = 1
25h = 00100 10 m
tag = 4, line = 2, byte = 1
Line Tag  Data 
03    
02 4a17c
o 4b44b
00    
03    
02 1b835
o 0-m
00 0So
Grey not part of cache
LineTag  Data 
03    
02 4a17c
o 4b44b
00    
03    
02 1b835
o 0-m
00 0So
Grey not part of cache
LineTag  Data 
03    
02 4a17c
o 4b44b
00    
03    
02 1b835
o 0-m
00 0So
Grey not part of cache