Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One memory location in a computer stores how much data?

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?

like image 916
Akh Avatar asked Mar 07 '11 03:03

Akh


People also ask

Are the memory location in computer's memory to store data?

When you declare variables you are given a memory location to use from the free memory available. Think of the computer's memory as a column of pidgeon holes which can store values, as in figure 1. Each pidgeon hole has it's own unique location number or memory address.

How are memory locations stored?

Memory addresses in a program are represented in hexadecimal format, by a variable name or label, etc. In assembly the address can be stored in a register so it can be referred as the content of the register, for example, (R1) is the address stored in register 1.

How many bits are in a location?

The processor uses 32 bits to store an address.


2 Answers

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

like image 146
ProdigySim Avatar answered Oct 02 '22 10:10

ProdigySim


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.

like image 25
Apalala Avatar answered Oct 02 '22 12:10

Apalala