shr cx, 1

rep movsw
rcl cx, 1
movsb
Posted on 2003-08-12 23:22:00 by bitRAKE
It appears Im witnessing the first case of sleep-walking to your cpu, and posting random thoughts of moving data around in ones sleep...

To bad it lacks more 'content' ;)
Posted on 2003-08-12 23:59:02 by NaN
The content is for the reader to discern.
I'm saddened you did not find it filling.
Would you care to add to the conversation? ;)
Posted on 2003-08-13 00:19:50 by bitRAKE
I understand the source's purpose, just not this post... :confused:

Sorry to sadden you ;)
Posted on 2003-08-13 00:34:05 by NaN
looks like VC++ 6's strcpy... I liked it too :)
Posted on 2003-08-13 02:00:05 by FearHQ
Is it a generic string copy (unicode)?
Posted on 2003-08-13 07:40:17 by roticv

Is it a generic string copy (unicode)?
It is a drop in replacement for "REP MOSVB/STOSB". In the case of MOVSB, the only difference is the flags are effected. Alternate solutions would have to use another instruction, and possibly another register or memory. Here are some alternatives I've seen:
shr cx, 1

rep movsw
jnc @F
movsb
@@:
push cx

shr cx, 1
rep movsw
pop cx
and cx, 1
movsb


I posted it in the heap because it's 16-bit code. I'm always amazed at little snips of code - I don't always have a use for them, but I do enjoy looking at them.
Posted on 2003-08-13 08:32:16 by bitRAKE
Shouldn't it be
shr cx, 1

rep movsw
rcl cx, 1
rep movsb

Since movsx is not dependent on ecx unless there is a prefix F3h.
Posted on 2003-08-13 10:04:36 by roticv
roticv, absolutely right - now I see why the whole thread got off track!
Oh, I play the fool for everyone. :grin: Thank you!
Posted on 2003-08-13 20:37:38 by bitRAKE