Skip to content

Instantly share code, notes, and snippets.

@dfyz
Last active Sep 11, 2022
Embed
What would you like to do?
We have FJCVTZS at home
.global _d2i
.align 4
_d2i:
fcvtzs x0, d0
ret
.intel_syntax noprefix
.global d2i
d2i:
cvttsd2si rax, xmm0
ret
> gcc -O2 -o ./cvt cvt.c cvt_x86_cheat.s -lm && ./cvt
-1.000000 -1
-133.700000 -133
-17875.690000 -17875
-2389979.753000 -2389979
-319540292.976100 -319540292
-42722537170.904549 227135790
-5712003219749.938477 303283931
-763694830480566.625000 1894355786
1.000000 1
133.700000 133
17875.690000 17875
2389979.753000 2389979
319540292.976100 319540292
42722537170.904549 -227135790
5712003219749.938477 -303283931
763694830480566.625000 -1894355786
> gcc -O2 -o ./cvt cvt.c cvt_aarch64_cheat.s && ./cvt
-1.000000 -1
-133.700000 -133
-17875.690000 -17875
-2389979.753000 -2389979
-319540292.976100 -319540292
-42722537170.904549 227135790
-5712003219749.938477 303283931
-763694830480566.625000 1894355786
1.000000 1
133.700000 133
17875.690000 17875
2389979.753000 2389979
319540292.976100 319540292
42722537170.904549 -227135790
5712003219749.938477 -303283931
763694830480566.625000 -1894355786
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment