Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Borland Delphi > Wanna do a Writ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 28 Topic 3723 of 3851
Post > Topic >>

Wanna do a WriteLongwordBits contest ?

by "Skybuck Flying" <BloodyShame@[EMAIL PROTECTED] > May 2, 2008 at 10:47 AM

Hello,

The mission is to copy the least significant bits from the "value"
parameter 
to the "dest address" pointer at the "dest bit index" parameter which can
be 
anywhere in memory up to "bit count".

So for example (conceptually):

Copy the first 3 bits from value to dest address 1000 at bit index 10000

The prototype looks like:

procedure WriteLongwordBits( Value : longword; BitCount : longword; 
DestAddress : pointer; DestBitIndex : longword );
begin


end;

The assembler for the empty prototype looks like:

Project1.dpr.1204: begin
00409068 55               push ebp
00409069 8BEC             mov ebp,esp
0040906B 83C4F4           add esp,-$0c
0040906E 894DF4           mov [ebp-$0c],ecx
00409071 8955F8           mov [ebp-$08],edx
00409074 8945FC           mov [ebp-$04],eax

// your code can come here or so...

Project1.dpr.1208: end;
00409077 8BE5             mov esp,ebp
00409079 5D               pop ebp
0040907A C20400           ret $0004


The calling code must use:

value must be in eax
bitcount must be in edx
destaddress must be in ecx
destbitindex must be pushed (4 bytes)
call routine

Many different implementations could be made.

For example:

A1. Assume the destination is all cleared with zero's

vs alternatively/better:

A2. Clear the bits yourself first. (preferred)

or

B1. Assume it's ok to overwrite trailing bits.

vs

B2. Preserve other bits which are not supposed to be modified (preferred).

No range checking needs to be done, assume the buffer is large enough.

The prototype is the 32 bit version.

I have three Delphi versions:

29 instructions 8 bit version (A2B2)
28 instructions 16 bit version (A2B2)
85 instructions 32 bit version (A2B2) <- this is where the pain begins.
(it 
uses int64's which are simulated in Delphi)

So I am starting to wonder if I need to write a special 32 bit assembler 
version to get some decent speed, since the speed in Delphi is lacking. <-

Pissy ;) :)

So I think that's why it's time for a contest, a pretty difficult one this

time.

Show me what you got ! ;) :)

Later I will try to implement my own asm version, but I don't want to 
influence you people.

So give it a try !

If nobody supplies code than I won't either, otherwise I will post code
too 
:)

Bye,
  Skybuck.
 




 28 Posts in Topic:
Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-02 10:47:32 
Re: Wanna do a WriteLongwordBits contest ?
MitchAlsup <MitchAlsup  2008-05-03 14:05:49 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-04 14:05:56 
Re: Wanna do a WriteLongwordBits contest ?
Terje Mathisen <terje.  2008-05-04 17:30:07 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-04 21:25:04 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-05 15:11:42 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-05 15:21:01 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-05 15:39:46 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-05 15:46:18 
Re: Wanna do a WriteLongwordBits contest ?
Terje Mathisen <terje.  2008-05-06 08:31:55 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-06 10:41:53 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-06 14:41:26 
Re: Wanna do a WriteLongwordBits contest ?
Terje Mathisen <terje.  2008-05-06 17:19:16 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-06 20:04:26 
Re: Wanna do a WriteLongwordBits contest ?
Terje Mathisen <terje.  2008-05-07 09:35:30 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-07 13:31:05 
Re: Wanna do a WriteLongwordBits contest ?
"Skybuck Flying"  2008-05-07 14:34:37 
Re: Wanna do a WriteLongwordBits contest ? (Skybuck's SimInt64 C
"Skybuck Flying"  2008-05-05 21:34:20 
Re: Wanna do a WriteLongwordBits contest ? (Skybuck's SimInt64 C
"Skybuck Flying"  2008-05-05 22:02:51 
Re: Wanna do a WriteLongwordBits contest ? (Skybuck's Second Ent
"Skybuck Flying"  2008-05-05 19:38:42 
Re: Wanna do a WriteLongwordBits contest ? (Skybuck's Third Entr
"Skybuck Flying"  2008-05-05 20:02:10 
Re: Wanna do a WriteLongwordBits contest ? (Skybuck's Third Entr
"Skybuck Flying"  2008-05-05 20:35:17 
Re: Wanna do a WriteLongwordBits contest ? (Skybuck's Fourth Ent
"Skybuck Flying"  2008-05-06 21:50:17 
Re: Wanna do a WriteLongwordBits contest ? (Skybuck's Fourth Ent
"Skybuck Flying"  2008-05-06 21:53:40 
Re: Wanna do a WriteLongwordBits contest ? (Skybuck's Fiveth Ent
"Skybuck Flying"  2008-05-06 22:54:22 
Re: Wanna do a WriteLongwordBits contest ? (Skybuck's Fiveth Ent
"Skybuck Flying"  2008-05-06 23:10:52 
Re: Wanna do a WriteLongwordBits contest ? (Benchmark, Verificat
"Skybuck Flying"  2008-05-07 19:09:04 
Re: Wanna do a WriteLongwordBits contest ? (Benchmark, Verificat
"Skybuck Flying"  2008-05-08 02:07:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 12:56:52 CDT 2008.