News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CopyMemory API

Started by Mark Jones, March 23, 2006, 10:14:03 PM

Previous topic - Next topic

NightWare

yep, thanks... the thing i always suspected is confirmed... microsoft coders are overpaid  :wink

jdoe

Am I wrong or CopyMemNW1 source pointer must be at least 16 bytes to be GPF safe ?

The Svin

As far as I can see - you are wrong :)
The proc is cheking size
...
Label00:mov ecx,eax
and ecx,11111111111111111111111111110000b ;if less than 16
jz Label02
...
Label02:mov ecx,eax
and ecx,00000000000000000000000000001100b ;if less than 4
jz Label04
...
Label04:mov ecx,eax
and ecx,00000000000000000000000000000011b ;if zero

NightWare

Quote from: jdoe on March 28, 2006, 12:23:33 AM
Am I wrong

sorry but yep, the svin is right... :thumbu  but you involontary dig up something i've forgot to said previously... my code is not only "non-intel specific instruction dependant"... the code is also evolutive... you can use 64 bits register, or simd 128 bits register, etc... there is no limit until you understand how the size have to be managed... i know i've open a small pandora box... but it have to be done...  :green2

jdoe

@NightWare:  Sure your memcopy function is great but the "tweaked" one from Mark Jones CopyMemNW1 is missing one jump to avoid GPF... or maybe I need to sleep  :lol


NightWare

can you tell me where the jump is missing ? coz each AND (the instruction that manage the size) is followed by a JZ (jump to avoid the following part)... (the 2 mov instructions don't affect the flags so i don't see were is the problem)...

EDIT : ok, i see it... there is a missing label and the corresponding jump... he has certainly corrected the code otherwise it crash... but you are right, there was a small error on the tweaked one posted by mark...
thanks jdoe...

MARK !!! you shouldn't change the name of the label... or by something that is recognisable... @ methode is generally error generator...

Mark Jones

Yep, the branch was lost accidentally! Nice catch, jdoe. :wink

Quote from: NightWare on March 28, 2006, 08:03:39 PM
MARK !!! you shouldn't change the name of the label... or by something that is recognisable... @ methode is generally error generator...

Well, when coded properly, they work properly. :toothy

I like to use anonymous jump labels where looping doesn't need an obvious label. Seems to make it clearer to understand. But everyone is different.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08