Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 27th, 2005, 10:13 PM   #21
Teecha
Newbie
 
Teecha's Avatar
 
Join Date: Aug 2005
Location: U.S.
Posts: 13
Rep Power: 0 Teecha is on a distinguished road
Send a message via AIM to Teecha Send a message via MSN to Teecha Send a message via Yahoo to Teecha
How boring would life be alone and in the garden?
Teecha is offline   Reply With Quote
Old Sep 27th, 2005, 10:23 PM   #22
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,453
Rep Power: 7 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Sep 27th, 2005, 10:25 PM   #23
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
: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
DaWei is offline   Reply With Quote
Old Sep 27th, 2005, 10:26 PM   #24
Teecha
Newbie
 
Teecha's Avatar
 
Join Date: Aug 2005
Location: U.S.
Posts: 13
Rep Power: 0 Teecha is on a distinguished road
Send a message via AIM to Teecha Send a message via MSN to Teecha Send a message via Yahoo to Teecha
You enjoy that too much...
Teecha is offline   Reply With Quote
Old Sep 27th, 2005, 10:27 PM   #25
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,453
Rep Power: 7 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Oct 7th, 2005, 12:46 PM   #26
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
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:
Last one, I promise.
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote
Old Oct 7th, 2005, 12:49 PM   #27
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Oct 7th, 2005, 12:52 PM   #28
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
I think my obsessive compulsive is showing...
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote
Old Oct 7th, 2005, 1:01 PM   #29
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:30 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC