Reputation: 700
Will this set of instructions jump? My main concern is the CMP expression. Does CMP handle only unsigned numbers? if so it would jump, since the Zero flag would have been set. Otherwise it would not jump since the numbers are specifically different.
mov ax, -127d
cmp ax, 128d
je Target
Upvotes: 1
Views: 84
Reputation: 9377
cmp
actually handles both signed and unsigned arithmetic simultaneously. After cmp
executes the overflow, carry, sign and zero flags will all be suitably set: any interpretation of these flags is up to the subsequent conditional instruction(s).
For example jz
/jnz
are insensitive to sign, ja/jb
implies unsigned comparison, and jl/jg
implies signed comparison. See an x86 manual for the (extensive) details of condition codes.
Upvotes: 1
Reputation: 64904
Equality is sign-oblivious.
-127 = FF81 = 65409
128 = 0080 = 128
Numbers that are unequal are unequal both in signed and unsigned interpretations. This follows directly from the fact that subtraction is the same procedure for signed and unsigned - since it's the same procedure, it can't, for the same inputs, result in 0 for one interpretation and not-0 for the other.
Upvotes: 2