To Mirno: You've got an interesting idea, but your proc has not been finished yet. It will work only if lenth of reversing string is aligned 8. I any other case it gives you unpredictable results. As to how benchmark two procs to compare. For me it is the simplest task. You can use it if you like. I wrote lots of temples and and one of them called Test2procs. Here is a code: .586 .model flat,stdcall option casemap:none include C:\masm32\include\windows.inc include C:\masm32\include\kernel32.inc include C:\masm32\include\user32.inc includelib kernel32.lib includelib user32.lib TimeTest_ON macro db 0fh,31h push edx push eax endm TimeTest_OFF macro db 0fh,31h pop ebx pop ecx sub eax,ebx sbb edx,ecx endm .data tmpl db 'First proc took %i clocks avrg',13,10 db 'Second proc took %i clocks avrg',0 .data? buffer db 64 dup (?) firstres dd ? secondres dd ? .code start: TimeTest_ON mov ecx,10000h test1: push ecx ;Here is first tested proc ;for example invoke MirnoProc,arg1,arg2 pop ecx dec ecx jne test1 TimeTest_OFF shr eax,16 mov firstres,eax TimeTest_ON mov ecx,10000h test2: push ecx ;Here is second tested proc ;for example invoke OtherProc,agr1,arg2 pop ecx dec ecx jne test2 TimeTest_OFF shr eax,16 mov secondres,eax invoke wsprintf,addr buffer,addr tmpl,firstres,secondres invoke MessageBox,0,addr buffer,0,0 call ExitProcess ;Here is code ;for first and second proc end start In fact I have an option in menu of my AsmEdit and it call simple but very usefull Hutchs prog - qetb.exe. It resives in command line path as parameter and the rest it does you can see for yourself. So I can see in group "Templates" in my editor those options as Headers Macros Tables Loops ect Chosing any of them opens an appropiete folder inside qetb viewer for me to look and copy anithing with ease. So if I have text of two procs it will take ~ 4 - 8 seconds for me to write and compile program wich benchmarks and compares them. With caret at left upper corner: 1. Click Templates\Tests 2. In opened qetb click Test2procs \sellall\copy 3. Paste in my editor and press F4 (compile and run) To All : I am for library section. The Svin.
Posted on 2001-03-22 06:00:00 by The Svin
Firstly, thanks "The Svin" (should we call you "The" for short :P ) for the benchmarking stuff! Secondly, I fixed my revstr2 (it works properly now I think), so its open season on my code again! well here it is:

revstr2 proc lpszSource:DWORD
    invoke StrLen,lpszSource
    .IF eax == 0
        ret

    .ELSEIF eax < 4
        mov ecx, lpszSource
        add eax, ecx
        dec eax
        mov dl, 
        mov dh, 
        mov , dh
        mov , dl
        ret

    .ELSE
        push esi
        push edi

        mov edi, eax
        mov esi, lpszSource
        add edi, esi

        and eax, 4
        jnz @F
        sub edi, 2
        mov ax, 
        mov dx, 
        ror ax, 8
        ror dx, 8
        mov , ax
        mov , dx
        add esi, 2
        .IF esi >= edi
            pop edi
            pop esi
            ret
        .ENDIF

@@:     
        .REPEAT
            sub edi, 4
            mov eax, 
            mov edx, 
            bswap eax
            bswap edx
            mov , eax
            mov , edx
            add esi, 4
        .UNTIL esi >= edi

        pop edi
        pop esi
        ret
    .ENDIF
revstr2 endp
It seems about 20-30 clocks faster (but quite a bit bigger) than yours :) when using the alphabet 4 times (104 chars). I also checked the new code (always a good idea :P ) on strings from ... db 0 ... db "a",0 ... db "ab",0 All the way through to ... db "abcdefghijklmnopqrstuvwxyz",0 And I think they worked (it gets a bit boring checking all of them :( ) Mirno
Posted on 2001-03-22 10:27:00 by Mirno
Vivat, Mirno! Well done! I knew you can do it. And I'm glad you accepted my way of testing, we can now talk the same languge (You can call me S for short). Not complitly the same though.... I always do three things with any code 1. Disassemle it 2. Debug it 3. Test it. Now to buisness: You need to get clear picture what kind of code produce all this .IF .ELSEIF .WHILE .ect .... So disassemble (or list) all code using it and analize. You made your idea work proparly, and it about the time you made finishing. Now ,if you will, look at some changes(addings with ;! and removings with ;) revstr3 proc lpszSource:DWORD invoke StrLen,lpszSource mov ecx,lpszSource ;! .IF eax == 0 ret .ELSEIF eax < 4 ; mov ecx, lpszSource ; add eax, ecx ; dec eax lea eax, ;! mov dl, mov dh, mov , dh mov , dl ; ret .ELSE ; push esi push edi ; mov edi,eax lea edi, ; mov esi, lpszSource ; add edi, esi and eax, 4 jnz @F sub edi, 2 mov ax, mov dx, ror ax, 8 ror dx, 8 mov , ax mov , dx add ecx, 2 ; .IF esi >= edi .IF ecx < edi ;! ; pop edi ; pop esi ; ret ; .ENDIF @@: .REPEAT sub edi, 4 mov eax, mov edx, bswap eax bswap edx mov , eax mov , edx add ecx, 4 .UNTIL ecx >= edi .ENDIF ;! pop edi ; pop esi .ENDIF ret revstr3 endp
Posted on 2001-03-22 13:17:00 by The Svin
To Mirno: I found one more needless ret (actually any your ret = 3 instr) revstr3 proc lpszSource:DWORD invoke StrLen,lpszSource mov ecx,lpszSource ;! ; .IF eax ==0 .IF eax != 0 ; ; ret .IF eax < 4 ; mov ecx, lpszSource ; add eax, ecx ; dec eax lea eax, ;! mov dl, mov dh, mov , dh mov , dl ; ret .ELSE ; push esi push edi ; mov edi,eax lea edi, ; mov esi, lpszSource ; add edi, esi and eax, 4 jnz @F sub edi, 2 mov ax, mov dx, ror ax, 8 ror dx, 8 mov , ax mov , dx add ecx, 2 ; .IF esi >= edi .IF ecx < edi ;! ; pop edi ; pop esi ; ret ; .ENDIF @@: .REPEAT sub edi, 4 mov eax, mov edx, bswap eax bswap edx mov , eax mov , edx add ecx, 4 .UNTIL ecx >= edi .ENDIF ;! pop edi ; pop esi .ENDIF ;! .ENDIF ret revstr3 endp
Posted on 2001-03-22 13:57:00 by The Svin