flat assembler
Message board for the users of flat assembler.
Index
> Main > dword to ascii, ascii to dword Goto page Previous 1, 2, 3, 4 Next |
Author |
|
JohnFound 11 Feb 2013, 07:12
Fixed in the above post.
|
|||
11 Feb 2013, 07:12 |
|
revolution 11 Feb 2013, 11:12
JohnFound wrote:
Code: lea eax,[eax*2+edx] |
|||
11 Feb 2013, 11:12 |
|
JohnFound 11 Feb 2013, 11:17
revolution wrote: What about: Yes, it is better! But not faster on my tests. Strange. _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
11 Feb 2013, 11:17 |
|
revolution 11 Feb 2013, 11:20
IMO testing for "faster" is rather futile for minor changes. There are far too many factors that can change the results that make it a very unsatisfying experience.
|
|||
11 Feb 2013, 11:20 |
|
JohnFound 11 Feb 2013, 11:27
But this is really faster from 2620ms for the previous variant to 1545ms for this (for 100000000 conversions):
Code: johnfound_ascii2d: push esi xor eax, eax mov esi, [esp+8] mov edx, eax mov ecx, eax cmp byte [esi], '-' jne .loop add esi, 1 sub ecx, 1 .loop: lodsb sub al, '0' jc .ends lea edx, [5*edx] lea edx, [2*edx+eax] jmp .loop .ends: xor edx, ecx sub edx, ecx mov eax, edx pop esi retn 4 This evening I will test on Intel Atom. I expect, the result will be different. |
|||
11 Feb 2013, 11:27 |
|
revolution 11 Feb 2013, 11:30
JohnFound wrote: But this is really faster from 2620ms for the previous variant to 1545ms for this (for 100000000 conversions): ... So many things to check before we know if it will be faster in the "real world". |
|||
11 Feb 2013, 11:30 |
|
JohnFound 11 Feb 2013, 11:33
revolution, you are right of course. But the faster algorithm is always faster. Of course, it is not so important if the bottleneck is somewhere else - for example on the disk operations. That is why I always argue that it is always better to optimize for size, not for speed.
But here it is a game - isn't it? |
|||
11 Feb 2013, 11:33 |
|
revolution 11 Feb 2013, 11:38
JohnFound wrote: But the faster algorithm is always faster. * where the definition of best is left open to interpretation. |
|||
11 Feb 2013, 11:38 |
|
JohnFound 11 Feb 2013, 11:51
Revolution, when I use the word "faster" I mean "In the same conditions" of course. Another type of comparison is impossible at all. And of course on some conditions even theoretically faster algorithm can be slower - for example Bubble sort is faster than Quick sort on very small arrays.
|
|||
11 Feb 2013, 11:51 |
|
AsmGuru62 11 Feb 2013, 12:05
@uart777:
Why load the address into EDX? It can be shorter: Code: mov cx, [table + eax*2] |
|||
11 Feb 2013, 12:05 |
|
HaHaAnonymous 11 Feb 2013, 19:59
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:34; edited 2 times in total |
|||
11 Feb 2013, 19:59 |
|
sleepsleep 12 Feb 2013, 00:18
ok guys,
will come back to work after 2 days holiday, what i would do is, copy paste ur code and run it, i would use my proc and every of ur guys submitted proc and cmp the EAX returned, to verify that each proc return valid value, then i will test the speed =) will announce the winner on 16th Feb 2013 u can use MMX SSE1 SSE2 or etc if u think that could help. *plez note that, i am not suppose to do anything with your code in case they are not in the form that i proposed, i only will copi paste and call it then time it. |
|||
12 Feb 2013, 00:18 |
|
edfed 12 Feb 2013, 01:53
what does give my atoi function?
Code: mov esi,test call atoi mov [result],eax ... test db '-1235697',0 ;on return: ;value from signed decimal string at [esi] in eax ;esi will point directlly after the command. ;carry set if valid decimal number atoi: .seekend: lodsb case al,' ',@f case al,'.',@f case al,',',@f case al,'!',@f casne al,0,.seekend @@: dec esi push esi dec esi xor ebx,ebx mov edx,1 .next: movzx eax,byte[esi] dec esi case al,'-',.neg case al,' ',.end case al,',',.end case al,'.',.end casl al,'0',@f casg al,'9',@f sub al,'0' imul eax,edx add ebx,eax imul edx,10 jmp .next @@: pop esi clc mov eax,ebx ret .neg: mov al,[esi] casne al,' ',@b neg ebx .end: pop esi stc mov eax,ebx ret .null: xor ebx,ebx clc mov eax,ebx ret need that: Code: macro case var,value,jmp { cmp var,value je jmp } macro casne var,value,jmp { cmp var,value jne jmp } macro casa var,value,jmp { cmp var,value ja jmp } macro casle var,value,jmp { cmp var,value jle jmp } macro casg var,value,jmp { cmp var,value jg jmp } macro casge var,value,jmp { cmp var,value jge jmp } macro casl var,value,jmp { cmp var,value jl jmp } |
|||
12 Feb 2013, 01:53 |
|
AsmGuru62 12 Feb 2013, 13:32
I will also test these routines -- keep posting!
|
|||
12 Feb 2013, 13:32 |
|
sleepsleep 12 Feb 2013, 14:40
if got any better method or what you see more suitable, please let us know, so everybody will get more fair assessment,
and for our future game as well |
|||
12 Feb 2013, 14:40 |
|
AsmGuru62 12 Feb 2013, 17:46
What if my code is the slowest!?...
First I'll measure it and then post it -- you know, not to be embarassed... Basically, my idea is an unrolled loop. The maximum of digits is 10, so I call my macro for converting a digit ten times. Should be simple enough. No jumps -- well, only one jump if no more digits found. But the measurement will actually decide if it is really fast code or not. Maybe not... we''ll see. It is all very intriguing! |
|||
12 Feb 2013, 17:46 |
|
HaHaAnonymous 12 Feb 2013, 20:48
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:33; edited 2 times in total |
|||
12 Feb 2013, 20:48 |
|
AsmGuru62 12 Feb 2013, 23:16
I will still post my code, even if it will be slow.
|
|||
12 Feb 2013, 23:16 |
|
HaHaAnonymous 12 Feb 2013, 23:25
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:33; edited 1 time in total |
|||
12 Feb 2013, 23:25 |
|
Goto page Previous 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.