Bits in a memory address

2019-08-24 02:29发布

问题:

While debugging on Windows XP 32-bit using the immunity debugger, I see the following on the stack:

_Address_ -Value_
00ff2254 ff090045
00ff2258 00000002

My understanding is that every address location contains 8 bits.

Is this correct?

回答1:

If I'm understanding your question correctly, the answer is yes, every individual memory location contains 8 bits.

The debugger is showing you 4 bytes (32 bits) at a time, to make the display more compact (and because many data types take up 32 bits, so it's often useful to see 32-bit values). That's why the addresses in the left column are 4 locations apart.

If the debugger showed one byte (8 bits) at a time, the display would look like this:

_Address_ -Value_
00ff2254 45
00ff2255 00
00ff2256 09
00ff2257 ff
00ff2258 02
00ff2259 00
00ff225a 00
00ff225b 00

(assuming you're on a "little-endian" machine, which most modern desktop PCs are.)



回答2:

I think the main problem with your question is that you ask for one thing, but I detect a different question lurking in the shadows.

First, and foremost, addressable entities in the memory of a computer is organized as bytes, which are 8 bits each, so yes, each address can be said to refer to 8 bits, or a byte.

However, you can easily group more bytes together to form bigger and more complex data structures.

If your question is really "Why am I seeing an 8-digit value as the contents at an address in my stack dump", then the reason for that is that it dumps 32-bit (4 bytes) values.

In other words, you can take the address, the address+1, the address+2, and the address+3, grab the bytes from each of those, and combine to a 32-bit value.

Is that really your question?



回答3:

To complete the answer of RH, you may be surprised to have so many numbers for a given address.

You should consider

Address  Byte (8 bits)
00ff2254 45
00ff2255 00
00ff2256 09
00ff2257 ff
00ff2258 02
... 

(On a cpu architecture used by XP)



回答4:

A memory location refers to a location of memory, and each consecutive memory location refers to the next byte in memory. So, you can only address memory on a one byte boundary, and everyone should know that a byte is 8 bits wide.