Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define D_TO_I(x) _mm_xor_si128(_mm_castpd_si128(_mm_add_pd(x, _mm_set1_pd(0x0010000000000000))),_mm_castpd_si128(_mm_set1_pd(0x0010000000000000)));
- void _printf_floating_point_strip(safe_double_ref d, int places, uint64_t * o_integer, uint64_t * o_fraction)
- {
- double _pow = 1; //
- for (int i = 0; i < places; i++) //there is no sse instruction and subsequent intrinsic for pow //
- _pow *= 10; // power := pow(10, places)
- //
- __m128d number_double = _mm_load1_pd(d); // number_double := d
- __m128d power_double = _mm_load1_pd(&_pow); // power_double := power
- //
- __m128d int_double = _mm_round_pd(number_double, 0x03 | 0x00); // int_double := round(number_double, truncate)
- __m128d frac_double = _mm_mul_pd(_mm_sub_pd(number_double, int_double), power_double); // frac_double := (number_double - int_double) * power_double
- //
- __m128i integer = D_TO_I(int_double); // integer := int_double
- __m128i fraction = D_TO_I(frac_double); // fraction := frac_double
- //
- *o_integer = integer.m128i_u64[0]; // *o_integer = integer
- *o_fraction = fraction.m128i_u64[0]; // *o_fraction = fraction
- }
- #undef D_TO_I
- .text:0000000180004550 sub_180004550 proc near ; CODE XREF: sub_1800042F0+35p
- .text:0000000180004550 ; DATA XREF: .pdata:000000018002A2D0o
- .text:0000000180004550
- .text:0000000180004550 var_s0 = qword ptr 0
- .text:0000000180004550 var_s8 = dword ptr 8
- .text:0000000180004550 var_s10 = xmmword ptr 10h
- .text:0000000180004550 var_s20 = xmmword ptr 20h
- .text:0000000180004550 var_s30 = xmmword ptr 30h
- .text:0000000180004550 var_s40 = xmmword ptr 40h
- .text:0000000180004550 var_s50 = xmmword ptr 50h
- .text:0000000180004550 arg_0 = qword ptr 0B0h
- .text:0000000180004550 arg_8 = dword ptr 0B8h
- .text:0000000180004550 arg_10 = qword ptr 0C0h
- .text:0000000180004550 arg_18 = qword ptr 0C8h
- .text:0000000180004550
- .text:0000000180004550 mov [rsp-0A8h+arg_18], r9
- .text:0000000180004555 mov [rsp-0A8h+arg_10], r8
- .text:000000018000455A mov [rsp-0A8h+arg_8], edx
- .text:000000018000455E mov [rsp-0A8h+arg_0], rcx
- .text:0000000180004563 push rbp
- .text:0000000180004564 sub rsp, 0A0h
- .text:000000018000456B mov rbp, rsp
- .text:000000018000456E movsd xmm0, cs:qword_180015DF0
- .text:0000000180004576 movsd [rbp+var_s0], xmm0
- .text:000000018000457B mov [rbp+var_s8], 0
- .text:0000000180004582 jmp short loc_18000458C
- .text:0000000180004584 ; ---------------------------------------------------------------------------
- .text:0000000180004584
- .text:0000000180004584 loc_180004584: ; CODE XREF: sub_180004550+59j
- .text:0000000180004584 mov eax, [rbp+var_s8]
- .text:0000000180004587 inc eax
- .text:0000000180004589 mov [rbp+var_s8], eax
- .text:000000018000458C
- .text:000000018000458C loc_18000458C: ; CODE XREF: sub_180004550+32j
- .text:000000018000458C mov eax, [rbp+arg_8]
- .text:0000000180004592 cmp [rbp+var_s8], eax
- .text:0000000180004595 jge short loc_1800045AB
- .text:0000000180004597 movsd xmm0, [rbp+var_s0]
- .text:000000018000459C mulsd xmm0, cs:qword_180015DF8
- .text:00000001800045A4 movsd [rbp+var_s0], xmm0
- .text:00000001800045A9 jmp short loc_180004584
- .text:00000001800045AB ; ---------------------------------------------------------------------------
- .text:00000001800045AB
- .text:00000001800045AB loc_1800045AB: ; CODE XREF: sub_180004550+45j
- .text:00000001800045AB movsd xmm0, [rbp+var_s0]
- .text:00000001800045B0 shufpd xmm0, xmm0, 0
- .text:00000001800045B5 movaps [rbp+var_s10], xmm0
- .text:00000001800045B9 mov rax, [rbp+arg_0]
- .text:00000001800045C0 movsd xmm0, qword ptr [rax]
- .text:00000001800045C4 shufpd xmm0, xmm0, 0
- .text:00000001800045C9 movaps [rbp+var_s20], xmm0
- .text:00000001800045CD movaps xmm0, [rbp+var_s20]
- .text:00000001800045D1 roundpd xmm0, xmm0, 3
- .text:00000001800045D7 movaps [rbp+var_s30], xmm0
- .text:00000001800045DB mov rax, 10000000000000h
- .text:00000001800045E5 cvtsi2sd xmm0, rax
- .text:00000001800045EA unpcklpd xmm0, xmm0
- .text:00000001800045EE mov rax, 10000000000000h
- .text:00000001800045F8 cvtsi2sd xmm1, rax
- .text:00000001800045FD unpcklpd xmm1, xmm1
- .text:0000000180004601 movaps xmm2, [rbp+var_s30]
- .text:0000000180004605 addpd xmm2, xmm1
- .text:0000000180004609 movaps xmm1, xmm2
- .text:000000018000460C pxor xmm1, xmm0
- .text:0000000180004610 movdqa xmm0, xmm1
- .text:0000000180004614 movdqa [rbp+var_s40], xmm0
- .text:0000000180004619 mov rax, 10000000000000h
- .text:0000000180004623 cvtsi2sd xmm0, rax
- .text:0000000180004628 unpcklpd xmm0, xmm0
- .text:000000018000462C mov rax, 10000000000000h
- .text:0000000180004636 cvtsi2sd xmm1, rax
- .text:000000018000463B unpcklpd xmm1, xmm1
- .text:000000018000463F movaps xmm2, [rbp+var_s20]
- .text:0000000180004643 subpd xmm2, [rbp+var_s30]
- .text:0000000180004648 mulpd xmm2, [rbp+var_s10]
- .text:000000018000464D addpd xmm2, xmm1
- .text:0000000180004651 movaps xmm1, xmm2
- .text:0000000180004654 pxor xmm1, xmm0
- .text:0000000180004658 movdqa xmm0, xmm1
- .text:000000018000465C movdqa [rbp+var_s50], xmm0
- .text:0000000180004661 mov eax, 8
- .text:0000000180004666 imul rax, 0
- .text:000000018000466A mov rcx, [rbp+arg_10]
- .text:0000000180004671 mov rax, qword ptr [rbp+rax+var_s40]
- .text:0000000180004676 mov [rcx], rax
- .text:0000000180004679 mov eax, 8
- .text:000000018000467E imul rax, 0
- .text:0000000180004682 mov rcx, [rbp+arg_18]
- .text:0000000180004689 mov rax, qword ptr [rbp+rax+var_s50]
- .text:000000018000468E mov [rcx], rax
- .text:0000000180004691 lea rsp, [rbp+0A0h]
- .text:0000000180004698 pop rbp
- .text:0000000180004699 retn
- .text:0000000180004699 sub_180004550 endp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement