25

Assume 32 Bit OS.

  1. One memory location in a computer stores how much data?

  2. Whats the basic unit of memory storage in a computer?

  3. For Example to a store a integer what will be the memory addresses required? If basic unit is BYTE the integer requires 4 bytes. So if I need to store a byte then if start putting in the 1st byte in memory location 0001 then will my integer end at 0003 memory location?

Please correct me if am wrong?

StayOnTarget
  • 7,829
  • 8
  • 42
  • 59
Akh
  • 5,532
  • 13
  • 48
  • 79

3 Answers3

27

Most commonly, modern systems are what you call "byte-accessible". This means:

  1. One memory location stores 1 byte (8 bits).
  2. The basic storage unit for memory is 1 byte.
  3. If you need to store 4 bytes, and place the first byte at 0001, the last byte will be at 0004. That's one byte at each of 0001, 0002, 0003, and 0004.

Keep in mind while systems have different CPU word sizes (a 32-bit system has a 32-bit or 4-byte word), memory is usually addressed by byte. The CPU's registers used in arithmetic are 4 bytes, but the "memory" programmers use for data storage is addressed in bytes.

On x86 systems, many memory-accessing instructions require values in memory to be "aligned" to addresses evenly divisible by the word size. e.g. 0x???0, 0x???4, 0x???8, 0x???C. So, storing an int at 0001 won't happen on most systems. Non-numeric data types can usually be found at any address.

See Wikipedia: Alignment Word (Computing) Memory Address

Choylton B. Higginbottom
  • 1,966
  • 1
  • 19
  • 31
ProdigySim
  • 2,235
  • 19
  • 17
2

One memory location in a computer stores how much data?

It depends on the computer. A memory location means a part of memory that the CPU can address directly.

Whats the basic unit of memory storage in a computer?

It is the Bit, and then the Byte, but different CPUs are more comfortable addressing memory in words of particular sizes.

For Example to a store a integer what will be the memory addresses required? If basic unit is BYTE the integer requires 4 bytes.

In mathematics, the integer numbers are infinite, so infinite memory should be required to represent all/any of them. The choice made by a computer architecture about how much memory should be used to represent an integer is arbitrary. In the end, the logic about how integers are represented and manipulated is in software, even if it is embedded in the firmware. The programming language Python has an unbounded representation for integers (but please don't try a googol on it).

In the end, all computer architectures somehow allow addressing down to the Byte or Bit level, but they work best with addresses at their word size, which generally matches the bit-size of the CPU registers.

It is not about the amount of data, or the size of integers, but about the number of memory addresses the computer can use.

There are 4GiB addresses (for bytes) in 32 bits. To manage a cluster of machines with more than 4GiB of RAM, each system must manage larger addresses.

Again, it is all about the addressable memory space, and not about the size of integers. There were 64 bit integers even when CPUs preferred 8bit word addressing.

Apalala
  • 8,159
  • 3
  • 26
  • 47
  • Sir , i asked a question similar to this but little different and it got downvoted , i asked a genuine doubt that every beginner would have in mind , could you please see the question and tell me was that a wrong question to ask , i then just entered C and was studying pointer , see as a beginner . http://stackoverflow.com/questions/34774322/how-is-memory-allocated-to-variables-of-different-data-types – Suraj Jain Dec 28 '16 at 14:04
  • I think it was downvoted for it being considered a duplicate. – Apalala Dec 29 '16 at 15:24
  • And This One http://stackoverflow.com/questions/34826036/confused-about-pointer-dereferencing – Suraj Jain Dec 29 '16 at 17:28
  • In the case of that other question, my guess is that people here expect OPs to have at least gone through some basic programming and computing courses or books, and are usually not willing to answer homework or Programming 101 questions. – Apalala Dec 31 '16 at 00:16
  • Do you think that was a HW Question , i was having a genuine doubt , here people think a lot , and try ways not to answer , just mark duplicate , it was -7 , and then with continuous effort it reached -4, it is an perfectly good question , and being a beginner means , he knows less than you all , this site was meant for knowledge sharing , and it is losing it. – Suraj Jain Dec 31 '16 at 02:37
1
  1. Depends on the architecture. 32-bits for 32-bits. 64-bits for 64-bits.
  2. Usually it's called a "word"
  3. Most values need to be aligned, so the addresses end with 0 4 8 or C
Edward Z. Yang
  • 25,246
  • 16
  • 75
  • 102
  • Sir , i asked a question similar to this but little different and it got downvoted , i asked a genuine doubt that every beginner would have in mind , could you please see the question and tell me was that a wrong question to ask , i then just entered C and was studying pointer , see as a beginner . http://stackoverflow.com/questions/34774322/how-is-memory-allocated-to-variables-of-different-data-types – Suraj Jain Dec 28 '16 at 14:04
  • 2
    The question doesn't ask how much bits are required to address a memory location but how many bits can be stored in a memory location which usually depends on size of data bus. Most modern computers are byte-addressable. Each address identifies a single byte (eight bits) of storage. Data larger than a single byte may be stored in a sequence of consecutive addresses. [Wikipedia] – Y M Aug 10 '18 at 03:24