0

A question was asked saying "what is the lowest and highest address given 2^10 bytes of memory in which 4 byte word is the smallest addressable unit?"

The lowest address is 0 The answer key has the highest address 2^10-4 I thought it would be (2^10-1)/4 since every 4 bytes are addressed?

3 Answers3

1

I guess the person who made the question got tangled in his own definition. Indeed, if the "smallest addressable unit" is a "4 byte word", then it would follow that in 2^10 bytes there are 2^8 different addresses, which means that the highest address is 2^8-1 or 255.

In typical computer architectures though this is not the case. The smallest addressable unit is actually a byte (since all addresses represent the number of bytes from "the start"), but valid addresses are only those that divide by 4. So 0 is a valid address and 4 is a valid address, but trying to use 3 would result in an exception. This is called "alignment", by the way, and different instructions can require different alignment, which can vary anywhere from 1 to 128, and sometimes even more. Typically though it is a power of 2, because those are easy to work with.

I suppose the question was really about alignments, but the it got phrased in an awkward way. You can also try asking about this to your teacher, who should be able to clear things up.

Vilx-
  • 104,512
  • 87
  • 279
  • 422
0

So you have 2^10 bytes, which makes 1024 bytes, which is 1MB. Now your memory is 4byte aligned, so the first address will be: 0x4 and the last address will be 1020/4 = 255 which is 0xFF in hex.

Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
0

You want the highest address so your address key is right. The highest address would be the location where you would have enough room (4 bytes) to add data. You answer just yields the number of 4 byte data items that memory can hold.

Kenneth Funk
  • 396
  • 2
  • 12