Hi guys,

i have a code that i would like to replace with another instruction and produces the same effect.

The beginning of the function is:



dis DRAWITEMSTRUCT <?>
(....)
Function proc uses edi esi ecx, param:DWORD

mov esi, param
lea edi, dis
mov ecx, sizeof dis
rep movsb


I?m trying to replace the rep movsb instruction with another one....but it is not working

I tried to replace the rep movsb with

mov edi, dword ptr

but it is not working.


And then i replaced with

push esi
add esi, ecx
pop esi

And it didn?t worked either

What is the replacement for the rep movsb instruction ?

Best Regards,

Guga
Posted on 2004-09-07 21:17:54 by Beyond2000!
something along these lines maybe..

    xor ecx,ecx

mov esi, param
lea edi, dis
mov ecx, sizeof dis
@@:
mov al, byte ptr [esi]
mov byte ptr [edi],al
dec ecx
cmp ecx,0
jne @B
Posted on 2004-09-07 21:37:42 by smurf
You mean you want this?



mov esi, param
lea edi, dis
mov ecx, sizeof dis
mov edi, dword ptr [dis+sizeof dis]


That's really weird. Why would you set EDI, and then set it again before using the first value?

Are you trying to do the ASM equivalent to this:



DRAWITEMSTRUCT dis;
void copystruct ( DRAWITEMSTRUCT * param ) {
dis = *param;
}


There is no other single instruction that can copy any arbitrarily sized data. If you replace "rep movsb" with that "mov edi", you'll notice that there is no longer anything that actually writes to "dis".

If the DRAWITEMSTRUCT is 1, 2 or 4 bytes, you can move the whole structure into a register and then copy the register to the new location. If the DRAWITEMSTRUCT is a multiple of 2 bytes, you can use the "rep movsw" instruction (don't forget to divide ecx by 2). If DRAWITEMSTRUCT is a multiple of 4 bytes, you can use "rep movsd".

What you can do is make a macro that can copy a fixed size of data from one location to another, choosing between using registers, rep movsb, rep movsw, rep movsd, or some combination, depending on the length of the data. Remember that you can combine movsb, movsw, and movsd to copy any size of data as fast as possible. For example, if you want to copy 255 bytes, you can do:



mov ecx, 255 / 4
rep movsd
movsw
movsb
Posted on 2004-09-07 21:42:02 by yessopotamus
Hi...Tks for the reply,

I?m trying to use drawitemstructure works on a editbox. and bypass the usage of WM_DRAWITEM and replace it with an WM_CTLCOLORSTATIC.

It is this example on the other thread i posted

http://www.asmcommunity.net/board/viewtopic.php?t=19268


Guga
Posted on 2004-09-07 22:24:03 by Beyond2000!
I?m trying to make a Editbox display text in different collours using a parser that is able to convert the colors, without using RichEdit controls or libraries.

The close i got was this file.


But i?m still stuck on te coding...

Best Regards,

Guga
Posted on 2004-09-08 11:16:30 by Beyond2000!
You cant have different coloured text in a normal edit control, you can have red text or yellow text or whatever but that applies to ALL the text in the edit control.

this is just one of the reasons Microsoft gave us the richedit control...
Posted on 2004-09-08 12:12:03 by Lennon
Hi Lennon

What i don?t want is use richedit....For exmaple, if i have a richedit doc with 500 Kb...only the text has no more then 20 Kb, and using the parser tokesn, it wil be no mroe then 30 Kb.

What?s i?m trying to reroduce is nemo?s code for an editbox.

So, the basics of an richedit can have the same result as his code on a editbox.
Guga
Posted on 2004-09-08 12:38:41 by Beyond2000!
I dont fully understand what you mean, but i know you dont want to use richedit, what im saying is you cant have multi coloured texted using a normal edit control.

So you have two choices, you can use richedit or make your own custom control...
Posted on 2004-09-08 13:20:48 by Lennon