前提・実現したいこと
アセンブラ用コードを基に足し算が実際にどのやうに行われているか説明することができません。
発生している問題・エラーメッセージ
gccを用いてコンパイルすることはできましたが、どこがどうなっているのかわかりません
該当のソースコード
#include <stdio.h>
int
main (void)
{
int i;
int a = 0;
int b = 1;
for (i = 0; i < 10; i++)
{
a = a + i;
b = b * i;
}
return 0;
}
試したこと
.file "andoryu.c"
.text
.Ltext0:
.globl main
.type main, @function
main:
.LFB0:
.file 1 "andoryu.c"
.loc 1 5 0
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
.loc 1 7 0
movl $0, -8(%rbp)
.loc 1 8 0
movl $1, -12(%rbp)
.loc 1 9 0
movl $0, -4(%rbp)
jmp .L2
.L3:
.loc 1 11 0 discriminator 2
movl -4(%rbp), %eax
addl %eax, -8(%rbp)
.loc 1 12 0 discriminator 2
movl -12(%rbp), %eax
imull -4(%rbp), %eax
movl %eax, -12(%rbp)
.loc 1 9 0 discriminator 2
addl $1, -4(%rbp)
.L2:
.loc 1 9 0 is_stmt 0 discriminator 1
cmpl $9, -4(%rbp)
jle .L3
.loc 1 14 0 is_stmt 1
movl $0, %eax
.loc 1 15 0
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.Letext0:
.section .debug_info,"",@progbits
.Ldebug_info0:
.long 0xb2
.value 0x4
.long .Ldebug_abbrev0
.byte 0x8
.uleb128 0x1
.long .LASF9
.byte 0x1
.long .LASF10
.long .LASF11
.quad .Ltext0
.quad .Letext0-.Ltext0
.long .Ldebug_line0
.uleb128 0x2
.byte 0x8
.byte 0x7
.long .LASF0
.uleb128 0x2
.byte 0x1
.byte 0x8
.long .LASF1
.uleb128 0x2
.byte 0x2
.byte 0x7
.long .LASF2
.uleb128 0x2
.byte 0x4
.byte 0x7
.long .LASF3
.uleb128 0x2
.byte 0x1
.byte 0x6
.long .LASF4
.uleb128 0x2
.byte 0x2
.byte 0x5
.long .LASF5
.uleb128 0x3
.byte 0x4
.byte 0x5
.string "int"
.uleb128 0x2
.byte 0x8
.byte 0x5
.long .LASF6
.uleb128 0x2
.byte 0x8
.byte 0x7
.long .LASF7
.uleb128 0x2
.byte 0x1
.byte 0x6
.long .LASF8
.uleb128 0x4
.long .LASF12
.byte 0x1
.byte 0x4
.long 0x57
.quad .LFB0
.quad .LFE0-.LFB0
.uleb128 0x1
.byte 0x9c
.uleb128 0x5
.string "i"
.byte 0x1
.byte 0x6
.long 0x57
.uleb128 0x2
.byte 0x91
.sleb128 -20
.uleb128 0x5
.string "a"
.byte 0x1
.byte 0x7
.long 0x57
.uleb128 0x2
.byte 0x91
.sleb128 -24
.uleb128 0x5
.string "b"
.byte 0x1
.byte 0x8
.long 0x57
.uleb128 0x2
.byte 0x91
.sleb128 -28
.byte 0
.byte 0
.section .debug_abbrev,"",@progbits
.Ldebug_abbrev0:
.uleb128 0x1
.uleb128 0x11
.byte 0x1
.uleb128 0x25
.uleb128 0xe
.uleb128 0x13
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.uleb128 0x1b
.uleb128 0xe
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x7
.uleb128 0x10
.uleb128 0x17
.byte 0
.byte 0
.uleb128 0x2
.uleb128 0x24
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.byte 0
.byte 0
.uleb128 0x3
.uleb128 0x24
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.uleb128 0x3
.uleb128 0x8
.byte 0
.byte 0
.uleb128 0x4
.uleb128 0x2e
.byte 0x1
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x27
.uleb128 0x19
.uleb128 0x49
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x7
.uleb128 0x40
.uleb128 0x18
.uleb128 0x2117
.uleb128 0x19
.byte 0
.byte 0
.uleb128 0x5
.uleb128 0x34
.byte 0
.uleb128 0x3
.uleb128 0x8
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2
.uleb128 0x18
.byte 0
.byte 0
.byte 0
.section .debug_aranges,"",@progbits
.long 0x2c
.value 0x2
.long .Ldebug_info0
.byte 0x8
.byte 0
.value 0
.value 0
.quad .Ltext0
.quad .Letext0-.Ltext0
.quad 0
.quad 0
.section .debug_line,"",@progbits
.Ldebug_line0:
.section .debug_str,"MS",@progbits,1
.LASF3:
.string "unsigned int"
.LASF9:
.string "GNU C 4.8.5 20150623 (Red Hat 4.8.5-16) -mtune=generic -march=x86-64 -g"
.LASF0:
.string "long unsigned int"
.LASF10:
.string "andoryu.c"
.LASF8:
.string "char"
.LASF1:
.string "unsigned char"
.LASF12:
.string "main"
.LASF6:
.string "long int"
.LASF2:
.string "short unsigned int"
.LASF4:
.string "signed char"
.LASF11:
.string "/home/s19h007"
.LASF5:
.string "short int"
.LASF7:
.string "sizetype"
.ident "GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-16)"
.section .note.GNU-stack,"",@progbits
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答2件
あなたの回答
tips
プレビュー