Hi, Someone can help me with this codesnippet ???:
mov eax, ecx // EAX = RANDOM-Value
mov esi, 00000035
cdq
idiv esi // EAX = EAX div ESI, Rest in EDX
mov dword ptr , eax
fild dword ptr
fcompp
fstsw ax //ax contains 4000h if: ecx mod 35h = 0
sahf // set Flags, like Z-Flag
jne 0046A8B5 is Z-Flag ??? then Jump
mov dword ptr , ebx
fild dword ptr
fdiv dword ptr [0046A938] (contains 422c0000h)
fsub dword ptr [0046A940] (contains 48631c00h)
mov dword ptr , ecx (contains the value from start)
fild dword ptr
fdiv dword ptr [0046A93C] (contains 42540000h)
fsub dword ptr [0046A944] (contains 48384200h)
fcompp
fstsw ax (i want here in AX : 4000) so the jump won't do
sahf // set or clear the Z-Flag
jne 0046A8B5 //Jump if Z-Flag set
Can someone explain me, how the values in ecx must be, that the last jump won't do ????
thx
Posted on 2001-11-06 07:53:00 by Spookie
There are several details not given:
1) There is something on the fp-stack for the first fcompp to work.
2) There is a value in ebx which you've not given.

If it is your code snippet, why have you given the disassembled code? If you aren't the owner of the code, then there are certain moral questions that should be asked before we really continue with this discussion.

If you can provide a good reason for only having the disassembled code, and also answer the above two questions, I'm sure we can help more.
(Also if you could convert the binary values into floats (422c0000h, 48631c00h, 42540000h, 48384200h) it would also help as I really cannot be bothered to work it out :P ).

Mirno

------ additional ------
I've been bothered to do some of the work already!
422c0000h = 43.0
48631c00h = 232560
42540000h = 53
48384200h = 188680

I could be wrong though
(it was a kinda quick working it out thing).
Posted on 2001-11-06 08:35:19 by Mirno
HI,
the reason is that i would understand how these functions work like fild, fdiv, fcompp ....
it is not my code. is something. it can be some code from every software.
here is the complete codesnippet:

mov eax, ebx /EBX= 1st Value
mov esi, 0000002B
cdq
idiv esi
mov dword ptr , eax
fild dword ptr
fcompp
fstsw ax
sahf
jne 0046A8B5
mov dword ptr , ecx /2nd Value
fild dword ptr
fdiv dword ptr [0046A93C] (contains 42540000h)

mov eax, ecx // ECX = 2nd Value
mov esi, 00000035
cdq
idiv esi // EAX = EAX div ESI
mov dword ptr , eax
fild dword ptr
fcompp
fstsw ax //ax contains 4000h if ecx mod 35h = 0
sahf // set Flags, like Z-Flag
jne 0046A8B5 //is Z-Flag not set then Jump
mov dword ptr , ebx
fild dword ptr
fdiv dword ptr [0046A938] (contains 422c0000h)
fsub dword ptr [0046A940] (contains 48631c00h)
mov dword ptr , ecx (contains the value from start)
fild dword ptr
fdiv dword ptr [0046A93C] (contains 42540000h)
fsub dword ptr [0046A944] (contains 48384200h)
fcompp
fstsw ax (i want here in AX : 4000) so the jump won't do
sahf // set or clear the Z-Flag
jne 0046A8B5 //Jump if Z-Flag not set
Posted on 2001-11-06 09:12:12 by Spookie
In the MASM32 package (with service packs 1 & 2 installed too), there is a an FPHELP.HLP file which details many of the FPU (x87) instructions.
It outlines all the most common uses of the FPU.

The FPU status word wasn't in there (or I'm not good at looking :P ), but there are docs on http://developer.intel.com do a search for FPU status word, and there are several docs.

Mirno
Posted on 2001-11-06 09:28:19 by Mirno
Oki,
i will look there.

thx a lot
Posted on 2001-11-06 09:31:01 by Spookie