Main memory organization
Segment 0 Segment 1
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 17 18 19 1a 1b 1c 1d 1e 1f
Data 00 ff a0 0a 36 91 f4 1b 17 b0 22 00 05 0b e2 dc b8 35 92 29 00 77 45 29 00 07 54 52 00 13 3e 74
Segment 2 Segment 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 37 38 39 3a 3b 3c 3d 3e 3f
Data 28 47 01 00 37 e9 00 00 46 d8 00 00 55 c5 00 00 64 bb 00 00 73 df 00 00 82 54 00 00 90 55 00 00

The data cache table is 4 cells by 4 lines, each cell holds 1 byte of data.
Only data is cached in this example (not instuctions). Click on first table to see sequenced version.

The dual tables above represent a single continuous address space.
The Mem Addr row is there so you don't have to count yourselves.
Memory addresses specifed in hexadecimal to simplify calculations.

Empty cache
on boot up.
Click to see cache
in action.
LDA $06 - Miss - f4 ADC $20 - Miss - 28
06h = 0000 01 10b
tag = 0, line = 1, byte = 2
20h = 0010 00 00b
tag = 2, line = 0, byte = 0
Line
ID
TagData
03---------
02---------
01---------
00 ---------
Line
ID
Tag
Id
Data
03 ---------
02 ---------
01 003691 f41b
00 ---------
Line
ID
Tag
Id
Data
03 ---------
02 ---------
01 003691f41b
00 02 28470100

SBC $07 - Hit - 1bADC $21 - Hit - 47SBC $08 - Miss -17
07h = 0000 01 11b
tag = 0, line = 1, byte = 3
21h = 0010 00 01b
tag = 2, line = 0, byte = 1
08h = 0000 10 00b
tag = 0, line = 2, byte = 1
Line
ID
Tag
Id
Data
03 ---------
02 ---------
010036 91f41b
00 0228470100
Line
ID
Tag
Id
Data
03 ---------
02 ---------
01 003691f41b
000228 470100
Line
ID
Tag
Id
Data
03 ---------
02 00 17b02200
01 003691f41b
00 0228470100

ADC $22 - Hit - 00SBC $09 - Hit - b0ADC $23 - Hit - 00
22h = 0010 00 10b
tag = 2, line = 0, byte = 2
09h = 0000 10 01b
tag = 0, line = 2, byte = 1
23h = 0010 00 11b
tag = 2, line = 0, byte = 3
Line
ID
Tag
Id
Data
03 ---------
02 0017b02200
01 003691f41b
00022847 0000
Line
ID
Tag
Id
Data
03 ---------
02 0017 b02200
01 003691f41b
00 0228470100
Line
ID
Tag
Id
Data
03 ---------
02 0017b02200
01 003691f41b
00 02284701 00

SBC $0A - Hit - 22ADC $24 - Miss - 37SBC $0B - Hit - 00
0Ah = 0000 10 10b
tag = 0, line = 2, byte = 2
24h = 0010 01 00b
tag = 2, line = 1, byte = 0
0Bh = 0000 10 11b
tag = 0, line = 2, byte = 3
Line
ID
Tag
Id
Data
03 ---------
02 0017b0 2200
01 003691f41b
00 0228470100
Line
ID
Tag
Id
Data
03 ---------
02 0017b02200
01 02 37e90000
00 0228470100
Line
ID
Tag
Id
Data
03 ---------
02 0017b022 00
01 0237e90000
00 0228470100