The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: kohlyang on June 26, 2010, 03:54:50 PM

Title: cmp negative value
Post by: kohlyang on June 26, 2010, 03:54:50 PM
hi all, i met a simple problem, have thought one night, but still could not get the answer, please help me.

  mov eax, -1
  cmp eax, 0
jb label_negative
  mov eax, 1
label_negative:
  mov eax, 2

because eax is -1, so should jump to label_negative, why not?

can anybody here help to find the reason, and how to jump to that label, many thanks ...
Title: Re: cmp negative value
Post by: jj2007 on June 26, 2010, 04:14:01 PM
Check the difference between jb and jl. opcodes.chm has all the info you need.
Or go here (http://www.webalice.it/jj2006/Masm32_Tips_Tricks_and_Traps.htm) and look for " The .if eax<0 trap"
Title: Re: cmp negative value
Post by: kohlyang on June 26, 2010, 04:41:12 PM
Quote from: jj2007 on June 26, 2010, 04:14:01 PM
Check the difference between jb and jl. opcodes.chm has all the info you need.
Or go here (http://www.webalice.it/jj2006/Masm32_Tips_Tricks_and_Traps.htm) and look for " The .if eax<0 trap"

brother, thank you very much, you also answered my second queston, what I actually want to ask is ".if eax<0", i'm very suprised to get my queston answered so quickly, thanks very much, I should post here earlier.

I do read "opcodes.chm" and "jxx" before I posted here, but just read the first several conditions, and searched two's complement to represent negtive value.

a good place here, i like here.  :bg :U