KDOC 449: 32bitマシンでint64型を使うとどうなるのか?
この文書のステータス
- 作成
- 2025-10-12 貴島
- レビュー
- 2025-10-17 貴島
概要
32bitマシンだとレジスタに入り切らないため1度で処理できず、スタックを使う想定だが、正しいだろうか。レジスタよりサイズが大きい場合にどう扱うか、ともいえる。
アセンブラを見る。
tmpfile=$(mktemp /tmp/tmp.XXXXXX.c) cat > $tmpfile <<EOF #include <stdio.h> int main() { long long a = 1234567890123; int b = 42; printf("%lld %d\n", a, b); return 0; } EOF docker run --rm -v /tmp:/tmp -w /tmp i386/ubuntu bash -c "apt update -y && apt install -y build-essential && gcc -m32 -S $tmpfile -o 32.s && cat 32.s" rm $tmpfile
tmpfile=$(mktemp /tmp/tmp.XXXXXX.c) cat > $tmpfile <<EOF #include <stdio.h> int main() { long long a = 1234567890123; int b = 42; printf("%lld %d\n", a, b); return 0; } EOF gcc -S $tmpfile -o /tmp/64.s rm $tmpfile
cat /tmp/32.s cat /tmp/64.s diff /tmp/32.s /tmp/64.s
関連
なし。