How do I compare two points to see if they are the same? If the point-struct was defined as two words it would have been easy, but it is two dwords :(

/Delight
Posted on 2002-06-20 12:46:26 by Delight
``````
mov eax, a.x
mov edx, a.y

xor eax, b.x
xor edx, b.y

or eax, edx
jnz not_equal
``````

Mirno
Posted on 2002-06-20 12:53:16 by Mirno
Thank you very much Mirno :alright:

/Delight
Posted on 2002-06-20 13:03:53 by Delight
``````mov eax, a.x
mov edx, a.y
xor eax, edx
jnz Not_equal``````

EDIT
or if it's 2 points in differnet structures

``````mov eax, a.x
mov edx, b.x
xor eax, edx
jnz Not_equal``````
Posted on 2002-06-20 14:17:09 by Kudos
Kudos you are only comparing the first element of 2 structures, rather than both elements of 2 structures.

By checking both axis of a pair of points, you know whether or not it is the same point, while you only check to see whether it is on the same plane (as your second example), or whether it is equidistant from the x axis and y axis (ie it is at an angle of 45 degrees from the origin (assuming square points)) (as your first example does).

If this is your aim, then why use a second register? It would be easier, faster, and less destructive (we'd leave edx in tact) to do this:
``````
mov eax, a.x
sub eax, a.y ; or b.x
jnz not_equal
``````

Mirno
Posted on 2002-06-20 16:50:29 by Mirno
aww for some reason I took "Compare two points" to mean 2 values :eek:
Posted on 2002-06-20 18:19:06 by Kudos