Results 1 to 6 of 6

Thread: Asm help: Opcode JNB xxxxx help needed

  1. #1
    morlac
    Guest

    Asm help: Opcode JNB xxxxx help needed

    Hi guys,
    Im faced with a problem.
    How can i translate the JNB 'Jump not below' to C/C++ statement?
    I tried the following:
    if ( var < 3 ) {
    statement1
    } else {
    statement2
    }
    but that translates to:
    cmp var,3
    jge ggg <-- should be 'jnb ggg'
    statement1
    ggg:
    statement2

    And according to the opcode docs 'JGE' is different from 'JNB'
    so, what can i do?

    Morlac.
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  2. #2
    The Owl
    Guest
    so, what can i do?
    maybe check the intel manuals (vol 2: instruction set, to be precise) and observe the difference between signed/unsigned compares (hint, hint ;-)).
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  3. #3
    morlac
    Guest
    Hi Owl,

    I did check the manuals before i asked. I always do.

    I tried unsigned/signed integer compares but still the same.
    'JNB' seems to depened on CF, but how? I dont have a clue.
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  4. #4
    The Owl
    Guest
    [pre]
    hmmm.... guys, beat me if i understand what your problems are...
    [/pre]
    [pre]
    1. JNB is 'jump if not below', ie. when CF=0 (it's in the manual...).
    CF is set to 0 for example by 'CMP' when the first operand is NOT BELOW
    (ie. above or equal to) the second operand IF the values were being treated
    as unsigned integers. CF is also set to 0 (cleared) by CLC for example.
    [/pre]
    [pre]
    2. JNB has two equivalent mnemonics: JAE (jump if above or equal) and
    JNC (jump if no carry). it's quite logical (and confusing at first perhaps), since
    they all test CF for the same value. an assembly programmer uses one over
    the other to express what the purpose of the Jcc is: test for integer values
    used in the program logic somewhere earlier or test for CF itself (which can
    be used for signaling error from a previous function call as it is the case for
    many DOS interrupts or VxD calls - just for example).
    [/pre]
    [pre]
    3. the following compiled by djgpp (gcc/dosx) will do what was asked for
    (tweak the direction of the comparison and perhaps some optimization
    flags if needed for your compiler):
    [/pre]
    [pre]
    int main()
    {
    unsigned int a,b;
    if (a<b)
    printf("a
    ");
    }
    [/pre]
    [pre]
    the only thing you have to pay attention to is that BOTH sides of the comparison
    should have the same signedness property (ie. a constant by deault is treated as
    signed in c/c++, you have to either cast it or append a 'u' to make it unsigned).
    [/pre]
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  5. #5
    morlac
    Guest
    Thanx guys.

    I got it right this time.

    Cheers.
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  6. #6
    morlac
    Guest
    Thanks alot for your time.
    Hopefully ill return the favour sometime.

    Morlac
    I promise that I have read the FAQ and tried to use the Search to answer my question.

Similar Threads

  1. help needed
    By dotuanvn1977 in forum The Newbie Forum
    Replies: 2
    Last Post: February 2nd, 2011, 02:29
  2. Opcode Operand Sizes
    By RITZ in forum Advanced Reversing and Programming
    Replies: 10
    Last Post: July 4th, 2006, 20:29
  3. Opcode length recognition
    By Latigo in forum Advanced Reversing and Programming
    Replies: 11
    Last Post: April 30th, 2001, 14:00
  4. Help needed
    By hoschi in forum Advanced Reversing and Programming
    Replies: 5
    Last Post: March 9th, 2001, 17:53
  5. Help needed
    By kingkaz in forum Advanced Reversing and Programming
    Replies: 0
    Last Post: November 9th, 2000, 00:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •