Reputation: 75
I have a noob questions about how memory address stores values.
For example,
addr +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F +0123456789ABCDEF
0000 50 61 78 20 69 73 20 61 20 72 65 61 6C 6C 79 20 Pax is a really
0010 63 6F 6F 6C 20 67 75 79 00 cool guy.
Is 0000 an address? Is 50 61 78 20 69 73 20 61 20 72 65 61 6C 6C 79 20 the value stored in 0000 address?
Upvotes: 4
Views: 8856
Reputation: 118593
Yes, 0000
can be considered an address. As to what is "stored" at 0000
, specifically the value 50
is stored there, and at 0001
the value of 61
is stored, and on and on.
However, with higher level data structures, such as 16 bit integers, or 32 bit integers, or Strings, or even record structures, the answer to "what is stored at 0000
" gets much muddier.
If a 16 bit binary integer is stored at 0000
, for an Intel architecture, then the value would be 6150
, or 24912 in decimal. This is because the Intel is "little endian", and stored the Most Significant bytes later in the address space. For a "big endian" processor, the value is 5160
or 20832 decimal.
Now, this could be coded in Binary Coded Decimal, in that case the value would be 6150 or 5160 in decimal (depending on endian-ness).
So, you can see, even for something as simple as an integer, there are different ways it can be stored within memory.
So, at the byte level, the answer is pretty simple. Going beyond that, it depends on how the data being stored is represented at the byte level.
Upvotes: 1
Reputation:
Here 0000
is an address, from the label addr
. The only value that is stored at 0000
is 50
. Each byte has it's own address:
------+--------
addr | data
------+--------
0000 | 50
0001 | 61
0002 | 78
0003 | 20
0004 | 69
0005 | 73
0006 | 20
0007 | 61
0008 | 20
0009 | 72
000A | 65
000B | 61
000C | 6C
000D | 6C
000E | 79
000F | 20
if you considered for example 0000
as the base address, you can say 20
, the last value is stored at F
as 0000 + F = 000F
, base address + offset from that address.
Upvotes: 4
Reputation: 4312
addr +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F +0123456789ABCDEF
0000 50 61 78 20 69 73 20 61 20 72 65 61 6C 6C 79 20 Pax is a really
0010 63 6F 6F 6C 20 67 75 79 00 cool guy.
0000 seems to be an address but might be a relative address (or offset). This output seems to say that
addr value
0000+0 (0000) 0x50
0000+1 (0001) 0x61
0000+2(0002) 0x78
....
Upvotes: 2
Reputation: 16007
0000
is likely just an offset from a localized address. Basically, BaseAddress + 0000
, BaseAddress + 0010
, etc.
The values are ASCII, and they match the characters on the right. You've stored a text message (or string) in that memory.
Each memory address stores one byte (also 8 bits, also 2 hexadecimal ("hex") digits). 0000
(0000 +0
) has the hex value 50
, 0001
(0000 +1
) has the hex value 61
, and so on.
Upvotes: 2