News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Dword to ascii (dw2a, dwtoa, dw2str, Str$, ...)

Started by jj2007, April 01, 2024, 03:42:50 AM

Previous topic - Next topic

lingo

Hi six_L, :thumbsup:

QuoteYou should blame me, not him.
I cannot and do not blame anyone directly, neither you nor jj.
I only expressed my opinion about the algorithm and the code of the program.
I wonder why jj is interrupting OUR conversation and acting in such a nervous manner.

QuoteI hope the competition continues.
After these insults from jj, I lost the interest, sorry! :sad:
Quid sit futurum cras fuge quaerere.

jj2007

The latest version. I had to tweak the code from our genius a little bit because a) it crashed and b) it overwrote the table, but now it works :thumbsup:

And indeed, Lingo's code is faster than mine :thumbsup:  :thumbsup:  :thumbsup:

I feel honoured that he used almost all my tricks :cool:

There are tiny little problems here and there, but hey, it's fast :thumbsup:

This program was assembled with UAsm64 in 64-bit format.
AMD Athlon Gold 3150U with Radeon Graphics
41      bytes for loadTable
140     bytes for MbDw2Str
-1
0
1
-1234567890123456789
1234567890123456789


Lingo: a) no negative numbers, b) leading zero, c) but only for numbers with odd number of digits

938     ms for 50Mio*MbDw2Str   result  $rdi    1234567890123456789
2187    ms for 50Mio*Roberts    result  $rdi    1234567890123456789
797     ms for 50Mio*Lingo's    result  $rdi    01234567890123456789
1532    ms for 5 Mio*sprintf    result  $rdi    1234567890123456789

718     ms for 50Mio*MbDw2Str   result  $rdi    123456789012345678
2032    ms for 50Mio*Roberts    result  $rdi    123456789012345678
687     ms for 50Mio*Lingo's    result  $rdi    123456789012345678
1484    ms for 5 Mio*sprintf    result  $rdi    123456789012345678

719     ms for 50Mio*MbDw2Str   result  $rdi    12345678901234567
1953    ms for 50Mio*Roberts    result  $rdi    12345678901234567
672     ms for 50Mio*Lingo's    result  $rdi    012345678901234567
1250    ms for 5 Mio*sprintf    result  $rdi    12345678901234567

906     ms for 50Mio*MbDw2Str   result  $rdi    -1234567890123456789
2297    ms for 50Mio*Roberts    result  $rdi    17212176183586094827
766     ms for 50Mio*Lingo's    result  $rdi    17212176183586094827
1531    ms for 5 Mio*sprintf    result  $rdi    -1234567890123456789

LiaoMi

Quote from: jj2007 on April 11, 2024, 05:25:22 AMThe latest version. I had to tweak the code from our genius a little bit because a) it crashed and b) it overwrote the table, but now it works :thumbsup:

And indeed, Lingo's code is faster than mine :thumbsup:  :thumbsup:  :thumbsup:

I feel honoured that he used almost all my tricks :cool:

There are tiny little problems here and there, but hey, it's fast :thumbsup:

This program was assembled with UAsm64 in 64-bit format.
AMD Athlon Gold 3150U with Radeon Graphics
41      bytes for loadTable
140     bytes for MbDw2Str
-1
0
1
-1234567890123456789
1234567890123456789


Lingo: a) no negative numbers, b) leading zero, c) but only for numbers with odd number of digits

938     ms for 50Mio*MbDw2Str   result  $rdi    1234567890123456789
2187    ms for 50Mio*Roberts    result  $rdi    1234567890123456789
797     ms for 50Mio*Lingo's    result  $rdi    01234567890123456789
1532    ms for 5 Mio*sprintf    result  $rdi    1234567890123456789

718     ms for 50Mio*MbDw2Str   result  $rdi    123456789012345678
2032    ms for 50Mio*Roberts    result  $rdi    123456789012345678
687     ms for 50Mio*Lingo's    result  $rdi    123456789012345678
1484    ms for 5 Mio*sprintf    result  $rdi    123456789012345678

719     ms for 50Mio*MbDw2Str   result  $rdi    12345678901234567
1953    ms for 50Mio*Roberts    result  $rdi    12345678901234567
672     ms for 50Mio*Lingo's    result  $rdi    012345678901234567
1250    ms for 5 Mio*sprintf    result  $rdi    12345678901234567

906     ms for 50Mio*MbDw2Str   result  $rdi    -1234567890123456789
2297    ms for 50Mio*Roberts    result  $rdi    17212176183586094827
766     ms for 50Mio*Lingo's    result  $rdi    17212176183586094827
1531    ms for 5 Mio*sprintf    result  $rdi    -1234567890123456789

This program was assembled with UAsm64 in 64-bit format.
13th Gen Intel(R) Core(TM) i9-13980HX
41      bytes for loadTable
140     bytes for MbDw2Str
-1
0
1
-1234567890123456789
1234567890123456789


Lingo: a) no negative numbers, b) leading zero, c) but only for numbers with odd number of digits

313     ms for 50Mio*MbDw2Str   result  $rdi    1234567890123456789
734     ms for 50Mio*Roberts    result  $rdi    1234567890123456789
250     ms for 50Mio*Lingo's    result  $rdi    01234567890123456789
438     ms for 5 Mio*sprintf    result  $rdi    1234567890123456789

281     ms for 50Mio*MbDw2Str   result  $rdi    123456789012345678
687     ms for 50Mio*Roberts    result  $rdi    123456789012345678
219     ms for 50Mio*Lingo's    result  $rdi    123456789012345678
406     ms for 5 Mio*sprintf    result  $rdi    123456789012345678

297     ms for 50Mio*MbDw2Str   result  $rdi    12345678901234567
641     ms for 50Mio*Roberts    result  $rdi    12345678901234567
219     ms for 50Mio*Lingo's    result  $rdi    012345678901234567
391     ms for 5 Mio*sprintf    result  $rdi    12345678901234567

484     ms for 50Mio*MbDw2Str   result  $rdi    -1234567890123456789
765     ms for 50Mio*Roberts    result  $rdi    17212176183586094827
250     ms for 50Mio*Lingo's    result  $rdi    17212176183586094827
438     ms for 5 Mio*sprintf    result  $rdi    -1234567890123456789

jj2007

Thanks, LiaoMi :thup:

Your cpu beats mine by almost a factor three. That is a fine machine - I could become a bit envious :mrgreen:

I attach sources and executables for both 64- and 32-bit versions. Note it's the same source ("dual assembly"), there is just one option OPT_64 n on top, with n=0 or 1. My MbDw2Str has only two tiny conditionals on entry:
    if @64
        mov rax, rcx        ; xwValue
    else
        mov eax, xwValue
    endif
...
    if @64
        mov rcx, 051EB851EB851EB85h
    else
        mov ecx, 051EB851Fh
    endif

CRT sprintf requires a different format specifier:
    mov rcx, number
    if @64
        jinvoke sprintf, rdi, Chr$("%lld"), rcx
    else
        jinvoke sprintf, rdi, Chr$("%d"), rcx
    endif

The Roberts and Lingo versions cannot be converted to 32-bit because of their register usage. Latest timings:
a) 64-bit:
This program was assembled with UAsm64 in 64-bit format.
AMD Athlon Gold 3150U with Radeon Graphics
41      bytes for loadTable
111    bytes for MbDw2Str
-1      minus 1
0      zero
1      one
Lingo: a) no negative numbers, b) leading zero, c) but only for numbers with odd number of digits

828     ms for 50Mio*MbDw2Str   result  $rdi    1234567890123456789
2156    ms for 50Mio*Roberts    result  $rdi    1234567890123456789
782     ms for 50Mio*Lingo's    result  $rdi    01234567890123456789
1500    ms for 5 Mio*sprintf    result  $rdi    1234567890123456789

687     ms for 50Mio*MbDw2Str   result  $rdi    123456789012345678
1984    ms for 50Mio*Roberts    result  $rdi    123456789012345678
688     ms for 50Mio*Lingo's    result  $rdi    123456789012345678
1453    ms for 5 Mio*sprintf    result  $rdi    123456789012345678

703     ms for 50Mio*MbDw2Str   result  $rdi    12345678901234567
1953    ms for 50Mio*Roberts    result  $rdi    12345678901234567
672     ms for 50Mio*Lingo's    result  $rdi    012345678901234567
1235    ms for 5 Mio*sprintf    result  $rdi    12345678901234567

843     ms for 50Mio*MbDw2Str   result  $rdi    -1234567890123456789
2219    ms for 50Mio*Roberts    result  $rdi    17212176183586094827
766     ms for 50Mio*Lingo's    result  $rdi    17212176183586094827
1531    ms for 5 Mio*sprintf    result  $rdi    -1234567890123456789

b) 32-bit:
This program was assembled with UAsm64 in 32-bit format.
AMD Athlon Gold 3150U with Radeon Graphics
37      bytes for loadTable
86      bytes for MbDw2Str
-1      minus 1
0       zero
1       one
469     ms for 50Mio*MbDw2Str   result  $rdi    123456789
1078    ms for 5 Mio*sprintf    result  $rdi    123456789

328     ms for 50Mio*MbDw2Str   result  $rdi    12345678
1016    ms for 5 Mio*sprintf    result  $rdi    12345678

375     ms for 50Mio*MbDw2Str   result  $rdi    1234567
765     ms for 5 Mio*sprintf    result  $rdi    1234567

469     ms for 50Mio*MbDw2Str   result  $rdi    -123456789
1063    ms for 5 Mio*sprintf    result  $rdi    -123456789

six_L

Hi,Lingo

QuoteAfter these insults from jj, I lost the interest, sorry! :sad:
This is a scene that most of our members do not want to see. I respect your choice. It's you who exhibited us the power of assembly language and the dazzling skills.

jj2007 not only argued with you, but also with many members. such as hutch--/aw27/nidud/_japheth. Some outstanding members had left forever because of arguing. Arguing is his inherent attribute. Human beings need the biological diversity. i guess our forum also needs member diversity. you may ignore him.

regard
Say you, Say me, Say the codes together for ever.

jj2007

Quote from: six_L on April 11, 2024, 10:52:13 PMjj2007 not only argued with you, but also with many members. such as hutch--/aw27/nidud/_japheth.

Stop this nonsense, dear. Yes, I argued with some of them, but it was always civilised. With Hutch, I had a very good relationship.

Lingo comes here out of the blue, never supplied a valid email address to our administrators, wants to take over the forum, posts crappy code, most of which (badly) copied from mine, and then has the chuzpe to call me a thief.

This is all documented in Bravo, Lingo!

I have no problem with Lingo using my code, although just using other registers to hide that sort of "reuse" is a bit fishy imho. I do have a problem, though, if he calls me a thief.

If I were the moderator, I would have kicked him out a long time ago.

TimoVJL

Many of us hoped, that this site's old style vanish, but old dogs are, what they are.
I am only here, as i use Pelle's C and i need to know something about assembly, when i try to hunt bugs.
Hopefully this site users still have an open mind for programming.
May the source be with you

jj2007

I've added the fast algo to the MasmBasic library of 12 April 2024, in two flavours:

a) as Str$(number):
  Print Str$("Rect left/top/right/bottom=%i", [esi.RECT.left]), "/", Str$(MyRC.top), "/", Str$(MyRC.right), "/", Str$([esi.RECT.bottom])
Flexibel, and a tick faster than the Masm32 SDK str$().

b) invoke MbDw2Str, number: ultrafast but no concatenation as in a).

stoo23

I'll try this Again

lingo

Can you Please Read and Respond to the PM's I have sent.
Thanking you in advance,
Stewart

zedd151

#159
Testing the laptop. As predicted elsewhere, not very high performance. Not even medium-performance.

64 bit



This program was assembled with UAsm64 in 64-bit format.
AMD A8-6410 APU with AMD Radeon R5 Graphics
41      bytes for loadTable
111     bytes for MbDw2Str
-1      minus 1
0       zero
1       one


Lingo: a) no negative numbers, b) leading zero, c) but only for numbers with odd
 number of digits

2762    ms for 50Mio*MbDw2Str   result  $rdi    1234567890123456789
5382    ms for 50Mio*Roberts    result  $rdi    1234567890123456789
2558    ms for 50Mio*Lingo's    result  $rdi    01234567890123456789
2449    ms for 5 Mio*sprintf    result  $rdi    1234567890123456789

2528    ms for 50Mio*MbDw2Str   result  $rdi    123456789012345678
4492    ms for 50Mio*Roberts    result  $rdi    123456789012345678
2309    ms for 50Mio*Lingo's    result  $rdi    123456789012345678
2356    ms for 5 Mio*sprintf    result  $rdi    123456789012345678

2558    ms for 50Mio*MbDw2Str   result  $rdi    12345678901234567
5008    ms for 50Mio*Roberts    result  $rdi    12345678901234567
2309    ms for 50Mio*Lingo's    result  $rdi    012345678901234567
2230    ms for 5 Mio*sprintf    result  $rdi    12345678901234567

2793    ms for 50Mio*MbDw2Str   result  $rdi    -1234567890123456789
4852    ms for 50Mio*Roberts    result  $rdi    17212176183586094827
2558    ms for 50Mio*Lingo's    result  $rdi    17212176183586094827
2558    ms for 5 Mio*sprintf    result  $rdi    -1234567890123456789


32 bit



This program was assembled with UAsm64 in 32-bit format.
AMD A8-6410 APU with AMD Radeon R5 Graphics
37      bytes for loadTable
86      bytes for MbDw2Str
-1      minus 1
0       zero
1       one
1092    ms for 50Mio*MbDw2Str   result  $rdi    123456789
1779    ms for 5 Mio*sprintf    result  $rdi    123456789

936     ms for 50Mio*MbDw2Str   result  $rdi    12345678
1622    ms for 5 Mio*sprintf    result  $rdi    12345678

936     ms for 50Mio*MbDw2Str   result  $rdi    1234567
1482    ms for 5 Mio*sprintf    result  $rdi    1234567

1139    ms for 50Mio*MbDw2Str   result  $rdi    -123456789
1841    ms for 5 Mio*sprintf    result  $rdi    -123456789


On the bright side, it does have 4 cores...  :undecided:
:azn:

TimoVJL

With old PC


This program was assembled with UAsm64 in 32-bit format.
AMD Athlon(tm) II X2 220 Processor
37      bytes for loadTable
86      bytes for MbDw2Str
-1      minus 1
0       zero
1       one
967     ms for 50Mio*MbDw2Str   result  $rdi    123456789
1903    ms for 5 Mio*sprintf    result  $rdi    123456789

874     ms for 50Mio*MbDw2Str   result  $rdi    12345678
1638    ms for 5 Mio*sprintf    result  $rdi    12345678

780     ms for 50Mio*MbDw2Str   result  $rdi    1234567
1357    ms for 5 Mio*sprintf    result  $rdi    1234567

1092    ms for 50Mio*MbDw2Str   result  $rdi    -123456789
1763    ms for 5 Mio*sprintf    result  $rdi    -123456789



This program was assembled with UAsm64 in 64-bit format.
AMD Athlon(tm) II X2 220 Processor
41      bytes for loadTable
111     bytes for MbDw2Str
-1      minus 1
0       zero
1       one


Lingo: a) no negative numbers, b) leading zero, c) but only for numbers with odd
 number of digits

2075    ms for 50Mio*MbDw2Str   result  $rdi    1234567890123456789
4040    ms for 50Mio*Roberts    result  $rdi    1234567890123456789
1841    ms for 50Mio*Lingo's    result  $rdi    01234567890123456789
2792    ms for 5 Mio*sprintf    result  $rdi    1234567890123456789

1841    ms for 50Mio*MbDw2Str   result  $rdi    123456789012345678
3760    ms for 50Mio*Roberts    result  $rdi    123456789012345678
1669    ms for 50Mio*Lingo's    result  $rdi    123456789012345678
2590    ms for 5 Mio*sprintf    result  $rdi    123456789012345678

1840    ms for 50Mio*MbDw2Str   result  $rdi    12345678901234567
3604    ms for 50Mio*Roberts    result  $rdi    12345678901234567
1654    ms for 50Mio*Lingo's    result  $rdi    012345678901234567
2433    ms for 5 Mio*sprintf    result  $rdi    12345678901234567

2091    ms for 50Mio*MbDw2Str   result  $rdi    -1234567890123456789
4181    ms for 50Mio*Roberts    result  $rdi    17212176183586094827
1856    ms for 50Mio*Lingo's    result  $rdi    17212176183586094827
2824    ms for 5 Mio*sprintf    result  $rdi    -1234567890123456789

May the source be with you