|
From: fly on 3 Apr 2006 11:46 Hello, i'm trying to mutiply two numbers useing Asemlber: 4 294 967 295 and 4 294 967 295 ;) the code: .... mianownik1 dq 0 mianownik2 dq 0 .. .. mov dword ptr mianownik1,esi mov dword ptr mianownik2,esi .. .. fild mianownik1 fild mianownik2 fmulp The answer i get is wrong. there should be 18446744065119617025 and I get 18446744065119617020. I view the aswer by OllyDbg in the FPU registers. Everything seems to be ok, but the multiplying is wrong. Any ideas why that's happening? Thanks in advance fly
From: spamtrap on 3 Apr 2006 17:54 fly wrote: > Hello, > i'm trying to mutiply two numbers useing Asemlber: > 4 294 967 295 and 4 294 967 295 ;) > the code: > ... > mianownik1 dq 0 > mianownik2 dq 0 Here you define 2 quadwords... > . > . > mov dword ptr mianownik1,esi > mov dword ptr mianownik2,esi I don't know what this is for... > . > . > fild mianownik1 Here there is no mention that 'mianownik1' is a pointer to a quadword... > fild mianownik2 ditto... > fmulp > Nathan.
From: Evenbit on 3 Apr 2006 17:59 fly wrote: > Hello, > i'm trying to mutiply two numbers useing Asemlber: > 4 294 967 295 and 4 294 967 295 ;) > the code: > ... > mianownik1 dq 0 > mianownik2 dq 0 Here, you define 2 quadwords... > . > . > mov dword ptr mianownik1,esi > mov dword ptr mianownik2,esi I don't know what this is for... > . > . > fild mianownik1 Here, you forget to tell the assembler that 'mianownik1' is a pointer to a quadword... > fild mianownik2 ditto... > fmulp > > The answer i get is wrong. there should be 18446744065119617025 > and I get 18446744065119617020. > I view the aswer by OllyDbg in the FPU registers. Everything seems to be > ok, but the multiplying is wrong. Any ideas why that's happening? > > > Thanks in advance > > fly Nathan.
From: randyhyde@earthlink.net on 3 Apr 2006 17:11 fly wrote: > Hello, > i'm trying to mutiply two numbers useing Asemlber: > 4 294 967 295 and 4 294 967 295 ;) > the code: > ... > mianownik1 dq 0 > mianownik2 dq 0 > . > . > mov dword ptr mianownik1,esi > mov dword ptr mianownik2,esi > . > . > fild mianownik1 > fild mianownik2 > fmulp > > The answer i get is wrong. there should be 18446744065119617025 > and I get 18446744065119617020. > I view the aswer by OllyDbg in the FPU registers. Everything seems to be > ok, but the multiplying is wrong. Any ideas why that's happening? > > Well, for one thing you're getting overflow. The product of $ffff_ffff and $FFFF_FFFF requires 64 bits to hold. But the 80-bit floating point value holds a 64-bit *signed* value. Therefore, you start to lose precision (that is, the FPU approximates the value) when you multiply numbers whose signed result cannot fit in 64 bits (including the sign bit). Cheers, Randy Hyde
From: o//annabee on 4 Apr 2006 01:54 P? Mon, 03 Apr 2006 17:46:58 +0200, skrev fly <spamtrap(a)crayne.org>: > Hello, > i'm trying to mutiply two numbers useing Asemlber: > 4 294 967 295 and 4 294 967 295 ;) > the code: > ... > mianownik1 dq 0 > mianownik2 dq 0 > . > . > mov dword ptr mianownik1,esi > mov dword ptr mianownik2,esi > . > . > fild mianownik1 > fild mianownik2 > fmulp > > The answer i get is wrong. there should be 18446744065119617025 > and I get 18446744065119617020. What you do is load -1 twice to the FPU. The result should be 1. To load what you really want, use a 64 bit variable. > I view the aswer by OllyDbg in the FPU registers. Everything seems to be > ok, but the multiplying is wrong. Any ideas why that's happening? > > > Thanks in advance > > fly >
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: Formatting in assembly Next: why this assembly language is not good? |