It is currently Fri Apr 10, 2020 9:08 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: UpdateString: destructive insert
PostPosted: Tue Oct 04, 2011 10:14 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8049
Location: Fort Nelson, BC, Canada
It says that if you use ebx the c++ compiler will have to preserve it for you, which implies it needs preserved. It can be assumed then that it will need preserved everywhere. The reference I quoted is simply giving the wrong impression.

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: UpdateString: destructive insert
PostPosted: Tue Oct 04, 2011 10:53 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Aug 15, 2009 6:59 pm
Posts: 1252
Demivec wrote:
netmaestro wrote:
Thorium pointed me to an x64 registers page. Have a look here:

http://msdn.microsoft.com/en-us/library/k1a8ss06.aspx

That's a helpful reference but it deals with C++ inline assembly. How does that relate to PureBasic's inline assembly?

Yes it's for C++ but Windows uses that ABI, so any software on Windows needs to stick to that ABI. Otherwise there would be major incompatiblity with DLL's and stuff.


Top
 Profile  
Reply with quote  
 Post subject: Re: UpdateString: destructive insert
PostPosted: Tue Oct 04, 2011 11:29 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8049
Location: Fort Nelson, BC, Canada
@wilbert: Yes I failed to consider the case where the operands fall through each other, my mistake. Your solution seems elegant enough and is also very economical in clocks. With Procedure changed to ProcedureDLL it tailbites up with no problem (just ascii for now), passes fairly exhaustive testing and is now in my production library. Thanks for your help.

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: UpdateString: destructive insert
PostPosted: Sun Oct 23, 2011 3:38 pm 
Offline
Always Here
Always Here

Joined: Mon Sep 22, 2003 6:45 pm
Posts: 7446
Location: Norway
I'm on 64-bit so I can't test the 32-bit assembly, but it would be interesting if someone could compare the speed of the assembly to this version:
Code:
Macro UpdateString2(target, source, pos)
  CopyMemory(source, target+pos-1, MemoryStringLength(source))
EndMacro


Also I can confirm that EBX needs to be preserved.


Top
 Profile  
Reply with quote  
 Post subject: Re: UpdateString: destructive insert
PostPosted: Sun Oct 23, 2011 8:21 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8049
Location: Fort Nelson, BC, Canada
Quote:
it would be interesting if someone could compare the speed of the assembly to this version:

Not quite apples to apples as there are two differences:

-assembly version returns the number of successfully replaced chars (impossible with a macro)
-assembly version contains a safety check for length and will never write past the end of the target string

Anyway, with those differences in mind, here is the result of this test (debugger off, of course):
Code:
s=ElapsedMilliseconds()
For i=1 To 100000000
  updatestring2(@"hello world!", @"girls", 6)
Next
t=ElapsedMilliseconds()

MessageRequester("", Str(t-s))

Macro version: 1748 ms
Assembly version: 904 ms (wilbert's last version, not my original)

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye