How to calculate size of memory by given a range of address?

Julie picture Julie · Jan 1, 2013 · Viewed 86.9k times · Source

I have an exercice that I couldn't resolve it, I have 3 memory range :

      First @      Last @ 

range1: FD00 0000 to FDFF FFFF

range2 : D000 0000 to DFFF FFFF

range3 : FA00 0000 to FBFF FFFF

the question is :give the size of the memory for each range (Mega byte)?

what I know is that I should calculate size of the range = last address - first address so the result for the first range is : 00FF FFFF . Is this right? then what should I do? I have searched on the internet I didn't found an example

Please help

Answer

Eric J. picture Eric J. · Jan 1, 2013

In your example for Range 1, you are correct. That is the size of the memory, stated in hexidecimal, in bytes.

You may gain the most insight by first converting 00FF FFFF to a decimal number, then converting that number of bytes into megabytes.

To convert from bytes to megabytes use the relationship

1 MB = 1 Megabyte = 1024 * 1 KB = 1,048,576 bytes.

There are tons of online Hex to Decimal converters. The calculator built in to Windows can also do the conversion.

For the other ranges, you again want to do subtraction to determine the size of the range, and then apply the steps above, e.g.

 FBFF FFFF
-
 FA00 0000
 ---------
 01FF FFFF

Having gone through those steps to better grasp what is happening, the following relationship will allow you to answer such questions faster:

0010 0000 = 1,048,576

So 1MB is the same as 0010 0000 (sometimes called 0x100000).