News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

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

learn64bit

yes, I need more, not less.
sometimes, I feel the world getting smaller and smaller, too sad
(1000 versions are better than 100)

sudoku

Quote from: learn64bit on April 12, 2024, 12:12:59 AMyes, I need more, not less.
sometimes, I feel the world getting smaller and smaller, too sad
(1000 versions are better than 100)
What??  :dazzled:  That makes absolutely no sense, in the context of this thread.  :rolleyes:
:cool:

NoCforMe

Um, I think I kinda get what he (assuming he) is saying here, surprisingly: that diversity is good, more versions better than fewer, some disagreement is fine.

Maybe ...
Assembly language programming should be fun. That's why I do it.

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