c - My 64 bit machine can only store 4 bytes each memory location -
my computer 64bit mac.
how many bytes of information stored in 1 of these locations in memory?
when tried in gdb
x /2x first 0x7ffff661c020: 0xf661b020 0x00007fff
my code
#define put(p, val) (*((size_t *)(p)) = (val)) put(first, (size_t)some pointers);
i use gcc -g compile
it seems 4 bytes store in 0x7ffff661c020 . 0x00007fff
stores in 0x7ffff661c024. why cant store 0x00007ffff661b020 in 0x7ffff661c020.
thanks
each memory location can store 8 bits, because memory byte addressable. 64-bit machine doesn't give 64 bits in every memory location, means can naturally handle 64 bits @ time.
for example, registers 64 bits wide (unless intentionally manipulate sub-registers ax
or eax
instead of 64-bit rax
), , can load many bits memory single instruction.
you can see it's byte addressable fact 2 addresses have difference of 4 between them:
0x7ffff661c020: 0xf661b020 0x7ffff661c024: 0x00007fff \____________/ four-byte \ difference
and, if used byte-based output, you'd see more "naturally", such as:
(gdb) x/8xb first 0x7ffff661c020: 0x20 0xb0 0x61 0xf6 0xff 0x7f 0x00 0x00
so 64-bit value @ 0x7ffff661c020
is 0x00007ffff661b020
expected, need adjust gdb
command out full 64-bit values, like:
x/1xg first
where 1xg
means 1 value, hex format, giant word (eight bytes). details on x
command can found here, important bit question description of unit size (my bold):
b
= bytes.h
= halfwords (two bytes).w
= words (four bytes). this initial default.g
= giant words (eight bytes).
Comments
Post a Comment