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 |
Author |
|
AsmGuru62 14 Feb 2013, 15:54
I wrote the test and I see very different results.
Fascinating! -- as Mr. Spock would say. The same code runs and produces results in range from around 7000 counts (for 1000 strings converted) to around 9000 counts. So, there is a difference in 2000 counts from time to time. I think it happens because the other tasks (I test on Windows) are preempting the function I am calling. Like all kind of services, etc. These things are running all the time, right? So, basically, it would be not very reliable to test one function against the other unless they differ in times by a very large margin, like few times slower or faster. I am afraid my testing would produce no real results. Maybe reduce the string count, so preempting tasks will have less chance to interrupt? What about making the loop run with highest priority (SetThreadPriority API)? Any ideas? |
|||
14 Feb 2013, 15:54 |
|
HaHaAnonymous 14 Feb 2013, 17:40
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:29; edited 1 time in total |
|||
14 Feb 2013, 17:40 |
|
AsmGuru62 14 Feb 2013, 17:55
I see the almost same results on this code: around 7000 to 9000 counts for 1000 strings.
|
|||
14 Feb 2013, 17:55 |
|
AsmGuru62 14 Feb 2013, 18:27
@edfed: your ATOI gives errors on negative values with 10 digits, like: "-1794094678"
|
|||
14 Feb 2013, 18:27 |
|
AsmGuru62 14 Feb 2013, 18:59
SetThreadPriority does not help.
Around same results for everyone's code. Weird... Maybe I need to try more strings to convert? I have only a 1000 strings generated by VS 2008 C++ compiler. |
|||
14 Feb 2013, 18:59 |
|
HaHaAnonymous 14 Feb 2013, 19:10
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:29; edited 1 time in total |
|||
14 Feb 2013, 19:10 |
|
edfed 14 Feb 2013, 21:32
ok, i'll try to correct it thx for the output
|
|||
14 Feb 2013, 21:32 |
|
HaHaAnonymous 15 Feb 2013, 19:32
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:28; edited 1 time in total |
|||
15 Feb 2013, 19:32 |
|
sleepsleep 16 Feb 2013, 12:55
ok, we got the result & winner! for 2 million ascii string number!
i only see mine, HaHaAnonymous & johnfound code, i dont see AsmGuru62 code? to check the winner, please view the spreadsheet congratulation to winner! thanks for participation!
|
|||||||||||||||||||||||||||||||
16 Feb 2013, 12:55 |
|
HaHaAnonymous 16 Feb 2013, 13:34
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:27; edited 1 time in total |
|||
16 Feb 2013, 13:34 |
|
JohnFound 16 Feb 2013, 14:12
Thanks. This result only proves my belief that the smallest code is very often the fastest one.
BTW, what is the QueryPerformanceFrequency on the test machine? |
|||
16 Feb 2013, 14:12 |
|
HaHaAnonymous 16 Feb 2013, 14:18
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 21:26; edited 1 time in total |
|||
16 Feb 2013, 14:18 |
|
sleepsleep 16 Feb 2013, 20:23
@HaHaAnonymous
mine is slowest too, but there is room of improvement for everybody, which is good after all. @JohnFound there is truth in that statement. btw, congratulation! =) Code: invoke QueryPerformanceFrequency,_frequency mov eax, dword [_frequency] mov ecx, dword [_frequency + 4] cinvoke wsprintf,_obuffer,<'Performance Frequency : %lu %lu',13,10,0>,eax,ecx stdcall consoleWrite,_obuffer Performance Frequency : 14318180 0 |
|||
16 Feb 2013, 20:23 |
|
edfed 16 Feb 2013, 20:53
i tested my version with 10 digits + minus sign, no problem, but in fact, i have a trim at the begining of the function and it gives that code:
maybe esi is not correctlly ajusted in the previous code posted cause trim does something with esi to point to the first non space char. Code: ;return value from signed decimal at [esi] in eax ;when executing a command from command line, ;esi will point directlly after the command. ;carry set if valid decimal number atoi: .trim: call trim dec esi .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 Code: trim: ;esi => text ;return esi => text - spaces ;al = [esi] SPACE equ ' ' TAB equ 9 @@: lodsb case al,0,@f case al,SPACE,@b case al,TAB,@b @@: ret i wonder if the function itself doesn't modify registers used in the test loop. and then lead to crash i've tested it with itoa, just to verify the value entered is correctly converted in integer.. Code: CR equ 13 LF equ 10 ;transparent return itoa: cmp eax,0 mov byte[edi],' ' jg @f mov byte[edi],'-' neg eax @@: mov ecx,10 mov ebx,edi push eax @@: mov al,[ebx] inc ebx case al,CR,@f case al,LF,@f casne al,0,@b @@: pop eax dec ebx .loop: dec ebx casl ebx,edi,.end xor edx,edx div ecx casne edx,0,@f casne eax,0,@f mov dl,' '-'0' @@: add dl,'0' cmp byte[ebx],'-' je .end mov [ebx],dl jmp .loop .end: ret |
|||
16 Feb 2013, 20:53 |
|
Goto page Previous 1, 2, 3, 4 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.