flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Roman 04 Jan 2014, 17:59
I search example SSE(2 or 4) convert string to 32bit decimal number.
And example SSE convert 32bit decimal number to string |
|||
![]() |
|
typedef 04 Jan 2014, 23:30
First you must know how to convert a number to string and vice versa.
Then (assuming you know how to use SSE) you can implement the algorithm using SSE. |
|||
![]() |
|
Roman 05 Jan 2014, 08:47
For example
mov eax,128 mov ebx,10 sub edx,edx div ebx edx=8 ! Then do again sub edx,edx div ebx edx=2 But SSE not have comand like div ! |
|||
![]() |
|
Roman 05 Jan 2014, 08:53
If i want do this in SSE i can get more commands. This is sad
|
|||
![]() |
|
cod3b453 05 Jan 2014, 15:07
For the "to-string" example shown, division could be done by reciprocal multiplication using fixed point arithmetic; if you are converting a lot of numbers in parallel this might be worth it [more so with SSSE3 pshufb].
For a "string-to" function, SSE can easily convert to BCD using psubb and find a decimal point/null terminator using pcmp. You can then unpack these bytes into d/qwords and scale them using a precomputed LUT of base 10 values [integer or float]. The final stage is then adding all of these terms together with the help of packing/shuffling instructions. This probably has more overhead than using the general purpose registers in 64bit. |
|||
![]() |
|
Roman 11 Jan 2014, 09:49
My idea to convert text to integer number
Code: TxtChislo db '9988000000000859' AndChislo db 48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48 MulChislo db 10,1,1,1,0,0,0,0,0,0,0,0,100,10,10,1 movss xmm1,dword [TxtChislo] movss xmm2,dword [AndChislo] pxor xmm1,xmm2 movss xmm2,dword [MulChislo] pmullw xmm1,xmm2 ;Show int numbers movd eax,xmm1 sub ecx,ecx mov cl,ah PrintInt 'Chislo = ',ecx In ECX number 99 ! Its good. But if PrintInt 'Chislo = ',eax Number in EAX wrong. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.