![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Newbie
|
How boring would life be alone and in the garden?
|
|
|
|
|
|
#22 |
|
Programming Guru
![]() ![]() ![]() |
you can always play with the snake
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#23 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
:eek:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#24 |
|
Newbie
|
You enjoy that too much...
![]() |
|
|
|
|
|
#25 |
|
Programming Guru
![]() ![]() ![]() |
I was referring to the serpent... but if eve had adam there, it could be taken both ways
![]()
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#26 |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
I commented my code. This runs in 33 clocks on a 2.8 ghz XP sp2 after terminating any high priority processes.
str1 db 'abcdefghijklmnopqrstuvwxyzabc',0 str2 db 64 dup(0) lea esi,str1 ; load effective address of string lea edi,str2 ; load effective address of buffer mov ecx,[sizeof str1-1] ; determine length of string less terminating '0' mov ebx,ecx ; load length for manipulation cmp ecx,4 ; ensure string is large enough for dword manipulations jb l1 ; if not, work with one byte at a time and ebx,3 ; test dword alignment by checking two least significant bytes jz l2 ; if zero it's 4 byte aligned cmp ebx,3 ; test if both lsb's set jnz @f ; next test sub ecx,1 ; both lsb's are set, work byte by byte until dword aligned mov al,[esi+ecx] ; load last character sub ebx,1 ; decrement for next test mov [edi],al ; save byte to beginning of buffer add edi,1 ; increment buffer position for next byte @@: cmp ebx,2 ; test only bit 1 jnz @f ; next test sub ecx,1 ; decrement string position mov al,[esi+ecx] ; load byte sub ebx,1 ; prepare for next byte mov [edi],al ; save byte to buffer add edi,1 ; increment buffer position @@: cmp ebx,1 ; test only bit 0 jnz l1 ; next sub ecx,1 ; update string position mov al,[esi+ecx] ; load byte mov [edi],al ; store to buffer add edi,1 ; update buffer position jmp l2 ; move on to dword manipulation l1: sub ecx,1 ; string is less than 4 characters mov al,[esi+ecx] ; load byte mov [edi],al ; store byte add edi,1 ; update buffer or ecx,ecx ; last byte? jz l3 ; done jmp l1 ; continue l2: sub ecx,4 ; back up 4 bytes jnz @f ; if > 0 go to dword loading loop mov eax,[esi+ecx]; else load the only dword bswap eax ; reverse dword mov [edi],eax ; store dword jmp l3 ; done @@: mov eax,[esi+ecx]; load dword bswap eax ; swap bytes mov [edi],eax ; store dword add edi,4 ; update buffer for next dword sub ecx,4 ; back up to next dword jnz @b ; loop mov eax,[esi] ; load last dword bswap eax ; swap mov [edi],eax ; store and done. str2 contains str1 reversed l3: ![]()
__________________
-- lostcauz Stepped in what?... Behind whose barn?... I didn't even know they had a cow! |
|
|
|
|
|
#27 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
What, you can't get enough speed, or somep'n?
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#28 |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
I think my obsessive compulsive is showing...
![]()
__________________
-- lostcauz Stepped in what?... Behind whose barn?... I didn't even know they had a cow! |
|
|
|
|
|
#29 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Well, as you know, one of mine is checking function returns. If you could speed that up as much, all these guys would hear is a quick Donald-Ducky quacky gobble garble. Then the lecture would be over and they could go home.
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|