0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

アドレスとメモリの内容の理解メモ

Last updated at Posted at 2023-08-22

注意

こちらの記事はアドレスとメモリについての個人的なメモ。
なぜ、下記のようにアドレスが16byteごとなのか、メモリの内容とリンクしなかった。

0x7fffffffdc20: ...
0x7fffffffdc30: ...

対象プログラム

#include <stdio.h>

int
main() {
    char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\0";
    printf("s = %s\n", s);
}

アドレスとメモリの内容表示

gdb-peda$ x/32xw $rsp - 16
0x7fffffffdc20: 0x00000000      0x00000000      0x00000000      0x00000000
0x7fffffffdc30: 0x44434241      0x48474645      0x4c4b4a49      0x504f4e4d
0x7fffffffdc40: 0x54535251      0x58575655      0x00005a59      0x00000000
0x7fffffffdc50: 0x00000001      0x00000000      0xf7db4d90      0x00007fff
0x7fffffffdc60: 0x00000000      0x00000000      0x00401136      0x00000000
0x7fffffffdc70: 0x00000000      0x00000001      0xffffdd68      0x00007fff
0x7fffffffdc80: 0x00000000      0x00000000      0x99b65ce0      0xbac8aaa4
0x7fffffffdc90: 0xffffdd68      0x00007fff      0x00401136      0x00000000

理解メモ

例) "ABCD"の場合
0x41(1byte) = 0b01000001(8bit)
0x44434241(4byte) = 0b01000100_01000011_01000010_01000001(32bit)

0x7fffffffdc30: 0x44434241 0x48474645 0x4c4b4a49 0x504f4e4dのように、4byteが4つあるので、アドレスが16byteごとになっている。

0x7fffffffdc20: ...
0x7fffffffdc30: ...
0x7fffffffdc40: ...
0x7fffffffdc50: ...

ビットとバイトについて
8bit = 1byte
32bit = 4byte
64bit = 8byte

16進数について
0x10(16進数) = 16(10進数)

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?