PDA

View Full Version : IMUL affecting CF OF


evaluator
April 29th, 2012, 04:22
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)

blabberer
April 29th, 2012, 06:37
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)

OHPen
April 30th, 2012, 03:50
@blabberer: lol!!!

evaluator
April 30th, 2012, 09:01
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)

blabberer
May 1st, 2012, 12:11
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>

evaluator
May 1st, 2012, 12:37
now make BOLD or ITALIC sentence, which explains outcome
03030303 * 055 = 0FFFFFFFF >> CF OF set.

Woodmann
May 1st, 2012, 20:51
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

evaluator
May 2nd, 2012, 15:53
now i am giving my view intel-englich:

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

blabberer, is it OK?

blabberer
May 2nd, 2012, 16:53
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

Woodmann
May 2nd, 2012, 21:09
Thank you.

Don

evaluator
May 3rd, 2012, 04:17
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.

Maximus
May 3rd, 2012, 20:58
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!?!?)

Woodmann
May 4th, 2012, 21:38
Quote:
(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