If you have two 16-bit quantities in memory or register and you want to test if they are both zero you can OR
them together. If the result of the OR
is zero, then both operands were zero.
If you have two 32-bit quantities each represented as two 16-bit quantities and you want to know if the two 32-bit quantities compare equal, then subtract the upper 16-bits of the two quantities and the lower 16-bits of the two quantities and OR
those differences together... again, if the result of the OR
is zero, then both 32-bit quantities were equal.
Let's say you have a 32-bit quantity in DX:AX and another in CX:BX and you want to know if they are equal:
sub ax,bx ; ax = ax - bx
sub dx,cx ; dx = dx - cx
or ax,dx ; ax = ax OR dx
je they_are_equal
The SUB
can be replaced with XOR
:
xor ax,bx ; ax = ax ^ bx
xor dx,cx ; dx = dx ^ cx
or ax,dx ; ax = ax OR dx
je they_are_equal