我正在尝试使用Scheme语言构建一个编译器到X86_64bit,同时使用gdb进行调试,以便查看程序崩溃的位置:(我显示了相关的寄存器,你可以看到rax = 1 ,r15 = 1,崩溃我程序的命令是div r15)
0x000000000040088f in L_add_fraction ()
1: $r11 = 1
2: $r12 = 3
3: $rax = 1
4: $r15 = 1
(gdb) disass
Dump of assembler code for function L_add_fraction:
0x000000000040087b <+45>: push %r11
0x000000000040087d <+47>: push %r12
0x000000000040087f <+49>: callq 0x400588 <gcd>
---Type <return> to continue, or q <return> to quit---
0x0000000000400884 <+54>: pop %r12
0x0000000000400886 <+56>: pop %r11
0x0000000000400888 <+58>: mov %rax,%r15
0x000000000040088b <+61>: mov %r11,%rax
0x000000000040088e <+64>: push %rdx
=> 0x000000000040088f <+65>: div %r15
0x0000000000400892 <+68>: pop %rdx
0x0000000000400893 <+69>: mov %rax,%r11
0x0000000000400896 <+72>: mov %r15,%rax
0x0000000000400899 <+75>: mov %r12,%rax
0x000000000040089c <+78>: push %rdx
0x000000000040089d <+79>: div %r15
0x00000000004008a0 <+82>: pop %rdx
0x00000000004008a1 <+83>: mov %rax,%r12
0x00000000004008a4 <+86>: cmp $0x1,%r11
0x00000000004008a8 <+90>: je 0x4008d0 <L_result_is_integer_plus>
0x00000000004008aa <+92>: push %r11
0x00000000004008ac <+94>: push %r12
0x00000000004008ae <+96>: mov $0x8,%edi
0x00000000004008b3 <+101>: callq 0x400570 <my_malloc>
0x00000000004008b8 <+106>: pop %r12
0x00000000004008ba <+108>: pop %r11
0x00000000004008bc <+110>: mov %r11,(%rax)
---Type <return> to continue, or q <return> to quit---
0x00000000004008bf <+113>: shlq $0x22,(%rax)
0x00000000004008c3 <+117>: shl $0x4,%r12
0x00000000004008c7 <+121>: or %r12,(%rax)
0x00000000004008ca <+124>: orq $0x4,(%rax)
0x00000000004008ce <+128>: jmp 0x4008e9 <L_plus_bin_end>
End of assembler dump.
(gdb) ni
Program received signal SIGFPE, Arithmetic exception.
0x000000000040088f in L_add_fraction ()
1: $r11 = 1
2: $r12 = 3
3: $rax = 1
4: $r15 = 1
我搜索了这个问题,但我能看到的是,除以零时给出了SIGFPE(显然不是这里的情况)