flat assembler
Message board for the users of flat assembler.

Index > Windows > SSE Convert numbers to string.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 28 Jul 2020, 11:57
I'm looking example how do this.

One FBSTP convert to BCD num , but take about 260 CPU tiks.
One Div instruction take about 50 CPU tiks.

SSE mulss take about 2 CPU tiks.
If use mulss on 0.1 we get divide on 10.
Post 28 Jul 2020, 11:57
View user's profile Send private message Reply with quote
pabloreda



Joined: 24 Jan 2007
Posts: 116
Location: Argentina
pabloreda 28 Jul 2020, 12:34
Post 28 Jul 2020, 12:34
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 28 Jul 2020, 13:35
I would recommend first checking out this old thread: Binary number to decimal ASCII string conversion.
Post 28 Jul 2020, 13:35
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 28 Jul 2020, 15:03
I try on 999998 and 9999997
9999998 get me text 9999999
Code:
         mov eax,999998; or 9999997
         cvtsi2ss xmm1,eax
         mov eax,0.1
         movd xmm0,eax
         mov eax,1.0
         movd xmm2,eax
         sub eax,eax
.22:     mulss xmm1,xmm0
         inc eax
         comiss xmm1,xmm2
         jae .22
         sub edx,edx
         mov ebx,10.0
         ;inc eax
         xorps xmm2,xmm2
         movd xmm0,ebx
         mov ebx,Status22
.33:
         cvtsi2ss xmm2,edx

         subss xmm1,xmm2
         mulss xmm1,xmm0
         ;cvtss2si edx,xmm1
         roundss xmm3,xmm1,9
         cvtss2si edx,xmm3
         mov [ebx],dl
         add byte [ebx],48
         inc ebx
         dec eax
         test eax,eax
         jnz .33
         invoke MessageBox,0,Status22,0,0
    
Post 28 Jul 2020, 15:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.