Results 1 to 13 of 13

Thread: IMUL affecting CF OF

  1. #1
    Musician member evaluator's Avatar
    Join Date
    Sep 2001
    Posts
    1,524
    Blog Entries
    1

    IMUL affecting CF OF

    Hello!

    probably of my no-good engliCh, i can't much understand IMUL explanation in intel-doc.
    problem is here:
    for saving register usage, i decided use IMUL EAX EAX 055 instead of MUL.
    now if do
    03030303 * 055 = 0FFFFFFFF
    result is exact, no upper bits need. but CF & OF flags are set.
    (same happens with less operand-form, like IMUL ECX)
    this not happens in MUL case.

    so, please be kind with me & show me exact statement of this fact in doc. (i have 253666 pdf)

  2. #2
    Super Moderator
    Join Date
    Dec 2004
    Posts
    1,529
    Blog Entries
    15
    rezult is crosses the 7fffffff limit then intel set cf and of are set

    for your example upto 29 no set cf of
    more +1 = 30 yes cf of set ever

    jorry for gud englishit

    editz

    more muky see donky do

    mov eax,031F3831
    imul eax,eax,29

    cf of no set possible done due the result of operation comming to low of 0x80000000 (actual 7FFFFFD9)

    inc eax
    imul eax,eax,29

    cf of set done by the result of cuming more in 0x80000000 (real 80000002)
    Last edited by blabberer; April 29th, 2012 at 07:07.

  3. #3
    ::[ Reverse Engineer ]:: OHPen's Avatar
    Join Date
    Nov 2002
    Location
    .text
    Posts
    399
    Blog Entries
    5
    @blabberer: lol!!!
    - Reverse Enginnering can be everything, but sometimes it's more than nothing. Really rare moments but then they appear to last ages... -

  4. #4
    Musician member evaluator's Avatar
    Join Date
    Sep 2001
    Posts
    1,524
    Blog Entries
    1
    eehhmm..

    i written:
    so, please be kind with me & show me exact statement of this fact in doc

    request is still open.

    (my assumption: OF setting is legal when crossing +- ; but not CF;
    but in docs, Intel tied together CF & OF.. and can't untie, bcoz of backward compatibility)

  5. #5
    Super Moderator
    Join Date
    Dec 2004
    Posts
    1,529
    Blog Entries
    15
    the kindest of the intel show the idiot outside this
    u see the paste under below down i stick with my keyboard press ctrl and press v then later

    Code:
    • Three-operand form — This form requires a destination operand (the first 
    operand) and two source operands (the second and the third operands). Here, 
    the first source operand (which can be a general-purpose register or a memory 
    location) is multiplied by the second source operand (an immediate value). The 
    product is then stored in the destination operand (a general-purpose register).
    When an immediate value is used as an operand, it is sign-extended to the length of 
    the destination operand format.
    The CF and OF flags are set when significant bit (including the sign bit) are carried 
    into the upper half of the result. The CF and OF flags are cleared when the result 
    (including the sign bit) fits exactly in the lower half of the result.
    The three forms of the IMUL instruction are similar in that the length of the product 
    is calculated to twice the length of the operands. With the one-operand form, the 
    product is stored exactly in the destination. With the two- and three- operand forms, 
    however, the result is truncated to the length of the destination before it is stored in 
    the destination register. Because of this truncation, the CF or OF flag should be tested 
    to ensure that no significant bits are lost. 
    The two- and three-operand forms may also be used with unsigned operands 
    because the lower half of the product is the same regardless if the operands are 
    signed or unsigned. The CF and OF flags, however, cannot be used to determine if the 
    upper half of the result is non-zero.
    
    
    Vol. 2A 3-495 IMUL—Signed Multiply
    i from pluto the non planet planet we speak bullshitonese in homespaze translating the idiot outside manual from our godtung our professor of cpumasterysir taut us that
    and in englishit says male and female when and is incanted a new form that puts both parts into one comes to being and upper half is bigg of the 7fffffff and lower half is less of 7fffffff
    in result of being

    Code:
     
    
    C:\WinDDK\7600.16385.1\inc>grep -ir "int_max" --include limits.h *
    crt/limits.h:#define INT_MAX       2147483647    /* maximum (signed) int value *
    /
    crt/limits.h:#define UINT_MAX      0xffffffff    /* maximum unsigned int value *
    /
    crt/limits.h:#define SIZE_MAX UINT_MAX
    
    C:\WinDDK\7600.16385.1\inc>set /a 0x7fffffff
    2147483647
    C:\WinDDK\7600.16385.1\inc>
    Last edited by blabberer; May 1st, 2012 at 14:26. Reason: boldify the upper ha and italicify lower lf

  6. #6
    Musician member evaluator's Avatar
    Join Date
    Sep 2001
    Posts
    1,524
    Blog Entries
    1
    now make BOLD or ITALIC sentence, which explains outcome
    03030303 * 055 = 0FFFFFFFF >> CF OF set.

  7. #7
    Okay,

    Enough please Blabby. While I almost choked from laughing so hard.....
    I know it's hard to give just a bit of mercy given Evals rep. but please
    consider it.

    Please.

    Woodmann
    Learn Or Die.

  8. #8
    Musician member evaluator's Avatar
    Join Date
    Sep 2001
    Posts
    1,524
    Blog Entries
    1
    now i am giving my view intel-englich:

    upper-half is upper-half of 64bit number e.g. 32-63bits.

    blabberer, is it OK?

  9. #9
    Super Moderator
    Join Date
    Dec 2004
    Posts
    1,529
    Blog Entries
    15
    no eval i dont think so
    it is not imul rax, eax,imm
    it is imul eax , eax, imm

    so it is in my opinion the upper half of 32 bits not the upper half of 64 bits
    intel specifies if truncation happens including sign bit to fit it in the destination register
    carry flag AND overflow are set
    operative phrase is destination register which is 32 bit not 64 bit

    that is how i understand the wording not sure why you feel different

    anyway making any crackmes based on this ??

    the boss ordered me to translate my godtung to english before posting using google translation service
    hope the translation now is better

  10. #10
    Thank you.

    Don
    Learn Or Die.

  11. #11
    Musician member evaluator's Avatar
    Join Date
    Sep 2001
    Posts
    1,524
    Blog Entries
    1
    blabberer, you are wrong.

    The CF and OF flags are set when significant bit (including the sign bit)
    are carried into the upper half of the result.
    The CF and OF flags are cleared when the result
    (including the sign bit) fits exactly in the lower half of the result.

    this means: upper-half is EDX (with 32-63bits), lower-half is EAX (with 0-31bits)

    otherwise, what is lower-half ??

    also, you are forgotting: truncation not matters.
    (same happens with less operand-form, like IMUL ECX)<< in my first post.

    ********
    Now, as i understand, you are not big Englich-spec, so i suggest, you will stop this waste.
    letz just wait for more Englich-spec one.

  12. #12
    uuugh.
    the only thing i understood is -maybe- the initial question.

    evaluator, you forgot you are doing an IMUL. the fact you get FFFFFFFF means you need an additional bit to store the sign, a bit you do not have. That's why you get the CF/OF. If you do a MUL, the FFFFFFF is always regarded as 4 billion, but doing an IMUL you need to know somehow that you did not get a '-1' instead of a 4 billion. Try to do the IMUL with say -1 * 1 and you see what i mean.

    (OT: fuck cooked wildboar... do i need to get holidays to digest it!?!?)
    Last edited by Maximus; May 3rd, 2012 at 21:17. Reason: can't sleep -.-
    I want to know God's thoughts ...the rest are details.
    (A. Einstein)
    --------
    ..."a shellcode is a command you do at the linux shell"...

  13. #13
    (OT: fuck cooked wildboar... do i need to get holidays to digest it!?!?)
    It's too lean. Sits like a brick in yer belly.

    Woodmann
    Learn Or Die.

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
  •