Last active
April 6, 2020 21:42
-
-
Save samth/8b8659c0cdcca6b9e9b3ee640fc282eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[samth@huor:~/.../math-test/math/tests (master) plt] cat x.c | |
/* pow example */ | |
#include <stdio.h> /* printf */ | |
#include <math.h> /* pow */ | |
int main (int argc, char** argv) | |
{ | |
double d = 1.4916681462400412e-154; | |
double x = -1.0; | |
if (argc > 5) { | |
x = x+(double)argc; | |
} | |
printf ("test = %20.20g\n", pow (d, x) ); | |
printf ("test = %20.20g\n", pow (d, -1.0) ); | |
return 0; | |
} | |
[samth@huor:~/.../math-test/math/tests (master) plt] gcc x.c -S -masm=intel -m32 -o x32.s | |
[samth@huor:~/.../math-test/math/tests (master) plt] gcc x.c -S -masm=intel -m64 -o x64.s | |
[samth@huor:~/.../math-test/math/tests (master) plt] gist x.c x32.s x64.s | |
https://gist.github.com/8b8659c0cdcca6b9e9b3ee640fc282eb | |
[samth@huor:~/.../math-test/math/tests (master) plt] gcc x.c -masm=intel -m64 -o x64 | |
/bin/ld: /tmp/ccWrf1uh.o: in function `main': | |
x.c:(.text+0x59): undefined reference to `pow' | |
collect2: error: ld returned 1 exit status | |
[samth@huor:~/.../math-test/math/tests (master) plt] gcc x.c -masm=intel -m64 -o x64 -lm | |
[samth@huor:~/.../math-test/math/tests (master) plt] gcc x.c -masm=intel -m32 -o x32 -lm | |
[samth@huor:~/.../math-test/math/tests (master) plt] ./x64 | |
test = 6.7039039649712985498e+153 | |
test = 6.7039039649713000384e+153 | |
[samth@huor:~/.../math-test/math/tests (master) plt] ./x32 | |
test = 6.7039039649712985498e+153 | |
test = 6.7039039649712985498e+153 | |
[samth@huor:~/.../math-test/math/tests (master) plt] | |
[samth@huor:~/.../math-test/math/tests (master) plt] uname -a | |
Linux huor 5.3.0-29-generic #31-Ubuntu SMP Fri Jan 17 17:27:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux | |
[samth@huor:~/.../math-test/math/tests (master) plt] gcc -v | |
Using built-in specs. | |
COLLECT_GCC=gcc | |
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper | |
OFFLOAD_TARGET_NAMES=nvptx-none:hsa | |
OFFLOAD_TARGET_DEFAULT=1 | |
Target: x86_64-linux-gnu | |
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.2.1-9ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu | |
Thread model: posix | |
gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* pow example */ | |
#include <stdio.h> /* printf */ | |
#include <math.h> /* pow */ | |
int main (int argc, char** argv) | |
{ | |
double d = 1.4916681462400412e-154; | |
double x = -1.0; | |
if (argc > 5) { | |
x = x+(double)argc; | |
} | |
printf ("test = %20.20g\n", pow (d, x) ); | |
printf ("test = %20.20g\n", pow (d, -1.0) ); | |
return 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "x.c" | |
.intel_syntax noprefix | |
.text | |
.section .rodata | |
.LC2: | |
.string "test = %20.20g\n" | |
.text | |
.globl main | |
.type main, @function | |
main: | |
.LFB0: | |
.cfi_startproc | |
endbr32 | |
lea ecx, 4[esp] | |
.cfi_def_cfa 1, 0 | |
and esp, -16 | |
push DWORD PTR -4[ecx] | |
push ebp | |
.cfi_escape 0x10,0x5,0x2,0x75,0 | |
mov ebp, esp | |
push ebx | |
push ecx | |
.cfi_escape 0xf,0x3,0x75,0x78,0x6 | |
.cfi_escape 0x10,0x3,0x2,0x75,0x7c | |
sub esp, 16 | |
call __x86.get_pc_thunk.bx | |
add ebx, OFFSET FLAT:_GLOBAL_OFFSET_TABLE_ | |
mov eax, ecx | |
fld QWORD PTR .LC0@GOTOFF[ebx] | |
fstp QWORD PTR -16[ebp] | |
fld1 | |
fchs | |
fstp QWORD PTR -24[ebp] | |
cmp DWORD PTR [eax], 5 | |
jle .L2 | |
fild DWORD PTR [eax] | |
fld QWORD PTR -24[ebp] | |
faddp st(1), st | |
fstp QWORD PTR -24[ebp] | |
.L2: | |
push DWORD PTR -20[ebp] | |
push DWORD PTR -24[ebp] | |
push DWORD PTR -12[ebp] | |
push DWORD PTR -16[ebp] | |
call pow@PLT | |
add esp, 16 | |
sub esp, 4 | |
lea esp, -8[esp] | |
fstp QWORD PTR [esp] | |
lea eax, .LC2@GOTOFF[ebx] | |
push eax | |
call printf@PLT | |
add esp, 16 | |
fld1 | |
fdiv QWORD PTR -16[ebp] | |
sub esp, 4 | |
lea esp, -8[esp] | |
fstp QWORD PTR [esp] | |
lea eax, .LC2@GOTOFF[ebx] | |
push eax | |
call printf@PLT | |
add esp, 16 | |
mov eax, 0 | |
lea esp, -8[ebp] | |
pop ecx | |
.cfi_restore 1 | |
.cfi_def_cfa 1, 0 | |
pop ebx | |
.cfi_restore 3 | |
pop ebp | |
.cfi_restore 5 | |
lea esp, -4[ecx] | |
.cfi_def_cfa 4, 4 | |
ret | |
.cfi_endproc | |
.LFE0: | |
.size main, .-main | |
.section .rodata | |
.align 8 | |
.LC0: | |
.long 4294967295 | |
.long 536870911 | |
.section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat | |
.globl __x86.get_pc_thunk.bx | |
.hidden __x86.get_pc_thunk.bx | |
.type __x86.get_pc_thunk.bx, @function | |
__x86.get_pc_thunk.bx: | |
.LFB1: | |
.cfi_startproc | |
mov ebx, DWORD PTR [esp] | |
ret | |
.cfi_endproc | |
.LFE1: | |
.ident "GCC: (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008" | |
.section .note.GNU-stack,"",@progbits | |
.section .note.gnu.property,"a" | |
.align 4 | |
.long 1f - 0f | |
.long 4f - 1f | |
.long 5 | |
0: | |
.string "GNU" | |
1: | |
.align 4 | |
.long 0xc0000002 | |
.long 3f - 2f | |
2: | |
.long 0x3 | |
3: | |
.align 4 | |
4: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "x.c" | |
.intel_syntax noprefix | |
.text | |
.section .rodata | |
.LC2: | |
.string "test = %20.20g\n" | |
.text | |
.globl main | |
.type main, @function | |
main: | |
.LFB0: | |
.cfi_startproc | |
endbr64 | |
push rbp | |
.cfi_def_cfa_offset 16 | |
.cfi_offset 6, -16 | |
mov rbp, rsp | |
.cfi_def_cfa_register 6 | |
sub rsp, 32 | |
mov DWORD PTR -20[rbp], edi | |
mov QWORD PTR -32[rbp], rsi | |
movsd xmm0, QWORD PTR .LC0[rip] | |
movsd QWORD PTR -8[rbp], xmm0 | |
movsd xmm0, QWORD PTR .LC1[rip] | |
movsd QWORD PTR -16[rbp], xmm0 | |
cmp DWORD PTR -20[rbp], 5 | |
jle .L2 | |
cvtsi2sd xmm0, DWORD PTR -20[rbp] | |
movsd xmm1, QWORD PTR -16[rbp] | |
addsd xmm0, xmm1 | |
movsd QWORD PTR -16[rbp], xmm0 | |
.L2: | |
movsd xmm0, QWORD PTR -16[rbp] | |
mov rax, QWORD PTR -8[rbp] | |
movapd xmm1, xmm0 | |
movq xmm0, rax | |
call pow@PLT | |
lea rdi, .LC2[rip] | |
mov eax, 1 | |
call printf@PLT | |
movsd xmm0, QWORD PTR .LC3[rip] | |
divsd xmm0, QWORD PTR -8[rbp] | |
lea rdi, .LC2[rip] | |
mov eax, 1 | |
call printf@PLT | |
mov eax, 0 | |
leave | |
.cfi_def_cfa 7, 8 | |
ret | |
.cfi_endproc | |
.LFE0: | |
.size main, .-main | |
.section .rodata | |
.align 8 | |
.LC0: | |
.long 4294967295 | |
.long 536870911 | |
.align 8 | |
.LC1: | |
.long 0 | |
.long -1074790400 | |
.align 8 | |
.LC3: | |
.long 0 | |
.long 1072693248 | |
.ident "GCC: (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008" | |
.section .note.GNU-stack,"",@progbits | |
.section .note.gnu.property,"a" | |
.align 8 | |
.long 1f - 0f | |
.long 4f - 1f | |
.long 5 | |
0: | |
.string "GNU" | |
1: | |
.align 8 | |
.long 0xc0000002 | |
.long 3f - 2f | |
2: | |
.long 0x3 | |
3: | |
.align 8 | |
4: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment