# Understanding addressing and size in memory map

TM4C123 has 256 kiBytes of flash ROM as shown in the memory map. The range of memory addresses for the ROM is 0x0000.0000 to 0x0003.FFFF (a 32bit address), totaled to 3x16x16x16x16 = 196,608 number of addresses. The memory is byte addressable so that block of memory addresses adds up to 196,608 bytes instead. Why does the manufacturer claim it has 256 kiB and not 196kB ROM memory size?

Even if the range of addresses can't sum up to an exact 256k, wouldn't 0x0000.0000 - 0.0004.FFFF (4x16x16x16x16 = 262k) give a size closer to 256k than 0x0003.FFFF's 196k?

• It starts at 0, so 4 X 16 x ... not 3 x. See also "fencepost error" – user_1818839 Jul 24 '20 at 10:04
• It has 00000000 up to 0000FFFF, then it has 00010000 up to 0001FFFF, then it has 00020000 up to 0002FFFF, then it has 00030000 up to 0003FFFF. 4 lots of 0000 up to FFFF. – user253751 Jul 24 '20 at 10:56

## 1 Answer

You have an off by one error in your calculations and also kilobyte is not 1000 bytes but 1024. The device really has 256 kilobytes of memory. 2^18 is 262144 bytes and 262144 / 1024 is exactly 256 kilobytes. A kilobyte is 2^10 = 1024 bytes.

• Well, according to international engineering standards, 2^10 bytes is a kibibyte and not a kilobyte. You can say I'm being pedantic, but flash drive manufacturers lost a lot of money in lawsuits over the matter. – Elliot Alderson Jul 24 '20 at 11:39