| View previous topic :: View next topic |
| Author |
Message |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Tue Mar 13, 2012 10:21 am Post subject: jump if value is below 0 |
|
|
this does not work
| Code: | cmp dword ptr [label],00000000
jb whatever |
label is a float an equals to -1
why the code above does not jump ?
how to make it jump if label < 0 ?
_________________
... Fresco |
|
| Back to top |
|
 |
Freiza Grandmaster Cheater
Reputation: 22
Joined: 28 Jun 2010 Posts: 662
|
Posted: Tue Mar 13, 2012 11:46 am Post subject: Re: jump if value is below 0 |
|
|
Try this
| Code: | fld dword ptr [value] ; load -1
ftst ; compare with 0
fstsw ax ; load status word to ax
sahf ; transfer condition to flag register
jb here ; jump if below |
_________________
|
|
| Back to top |
|
 |
Kavvman Master Cheater
Reputation: 2
Joined: 17 Apr 2004 Posts: 316
|
Posted: Tue Mar 13, 2012 12:25 pm Post subject: Re: jump if value is below 0 |
|
|
| Fresco wrote: | this does not work
| Code: | cmp dword ptr [label],00000000
jb whatever |
label is a float an equals to -1
why the code above does not jump ?
how to make it jump if label < 0 ? |
Try JL the signed version of it. Or JS should work as well if the sign is set (negative)
_________________
... |
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Wed Mar 14, 2012 9:08 am Post subject: Re: jump if value is below 0 |
|
|
| Freiza wrote: | Try this
| Code: | fld dword ptr [value] ; load -1
ftst ; compare with 0
fstsw ax ; load status word to ax
sahf ; transfer condition to flag register
jb here ; jump if below |
|
I see you push [value] into the fpu, but when do you pop it out ? because in then game i play it is crucial that the fpu does not get messed with.
should i push and pop flasg too ? pushfd popfd
_________________
... Fresco |
|
| Back to top |
|
 |
Freiza Grandmaster Cheater
Reputation: 22
Joined: 28 Jun 2010 Posts: 662
|
Posted: Wed Mar 14, 2012 10:41 am Post subject: Re: jump if value is below 0 |
|
|
| Fresco wrote: | | Freiza wrote: | Try this
| Code: | fld dword ptr [value] ; load -1
ftst ; compare with 0
fstsw ax ; load status word to ax
sahf ; transfer condition to flag register
jb here ; jump if below |
|
I see you push [value] into the fpu, but when do you pop it out ? because in then game i play it is crucial that the fpu does not get messed with.
should i push and pop flasg too ? pushfd popfd |
Yes you should pop the the elements using
fstp st
and also save the state of the flags.
_________________
|
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Wed Mar 14, 2012 11:07 am Post subject: |
|
|
i have tried both solution but unfortunately no one works
| Code: | cmp dword ptr [label],00000000 // float
jb whatever |
_________________
... Fresco |
|
| Back to top |
|
 |
Freiza Grandmaster Cheater
Reputation: 22
Joined: 28 Jun 2010 Posts: 662
|
Posted: Wed Mar 14, 2012 11:36 am Post subject: |
|
|
| Code: | globalalloc(value,4)
value:
dd (float)-1
fld dword ptr [value] ; load -1
ftst ; compare with 0
fstsw ax ; load status word to ax
sahf ; transfer condition to flag register
jb here ; jump if below |
This didn't worked? And also use fstp st.
| Code: | cmp dword ptr [label],00000000
jl whatever |
jl should also work.
_________________
|
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Wed Mar 14, 2012 1:43 pm Post subject: |
|
|
| Freiza wrote: | | Code: | globalalloc(value,4)
value:
dd (float)-1
fld dword ptr [value] ; load -1
ftst ; compare with 0
fstsw ax ; load status word to ax
sahf ; transfer condition to flag register
jb here ; jump if below |
This didn't worked? And also use fstp st.
| Code: | cmp dword ptr [label],00000000
jl whatever |
jl should also work. |
none of the above worked
_________________
... Fresco |
|
| Back to top |
|
 |
Freiza Grandmaster Cheater
Reputation: 22
Joined: 28 Jun 2010 Posts: 662
|
Posted: Wed Mar 14, 2012 1:47 pm Post subject: |
|
|
Technically both of them are correct.
_________________
|
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Wed Mar 14, 2012 1:50 pm Post subject: |
|
|
| Freiza wrote: | | Technically both of them are correct. |
i know, thanks
is there anything else i could try?
_________________
... Fresco |
|
| Back to top |
|
 |
Freiza Grandmaster Cheater
Reputation: 22
Joined: 28 Jun 2010 Posts: 662
|
Posted: Wed Mar 14, 2012 2:22 pm Post subject: |
|
|
Converting float to integer or Using hexadecimal value instead of float.
But it's shooting arrow in dark night. Can you give some info of what you are doing?
_________________
|
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Wed Mar 14, 2012 2:41 pm Post subject: |
|
|
| Freiza wrote: | Converting float to integer or Using hexadecimal value instead of float.
But it's shooting arrow in dark night. Can you give some info of what you are doing? |
there's this code that writes a float that goes from 0 to 100
if the user inserts a value bigger than 100 or smaller than zero ( 0 ) the game crashes, the game uses
fstp dword ptr [destination pointer] //it's a float
to store the val between 0 and 100 (0 & 100) included
in my code ...
0_100val = the user input's that value
| Code: | pushfd
cmp dword ptr [0_100val],42C80000 // 42C8 = 100 float
ja Store_MAX
cmp dword ptr [0_100val],00000000
jb Store_MIN
Continue:
nop
popfd
// ::code:: //
Store_MAX:
nop
mov dword ptr [0_100val],42C80000
jmp Continue
nop
Store_MIN:
nop
mov dword ptr [0_100val],00000000
jmp Continue
nop |
i hope that is enough for you, to tell me where this code doesn't work.
if user input = < 0 then write 0
if user input = > 100 then write 100
_________________
... Fresco |
|
| Back to top |
|
 |
Freiza Grandmaster Cheater
Reputation: 22
Joined: 28 Jun 2010 Posts: 662
|
Posted: Wed Mar 14, 2012 3:07 pm Post subject: |
|
|
Make sure 0_100val is assigned value before your code is running and is not changing by your other codes.
And make jb to jl.
_________________
|
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Wed Mar 14, 2012 3:17 pm Post subject: |
|
|
yes 0_100val is assigned
and no other code is modifying it
also tried jl, but still not positive results
_________________
... Fresco |
|
| Back to top |
|
 |
Freiza Grandmaster Cheater
Reputation: 22
Joined: 28 Jun 2010 Posts: 662
|
Posted: Wed Mar 14, 2012 3:22 pm Post subject: |
|
|
Then I don't know. Btw identifiers shouldn't be starting with a number. Ofcourse it is working in ce . But it is not right doing so. And if you come to any solution do let me know.
_________________
|
|
| Back to top |
|
 |
|