Page 1 of 1

Why boolean gives me 0101 instead of 0 or 1

Posted: Sun Aug 21, 2022 7:09 pm
by MaZy
Hi

this asm part mov r13, [r13+1F0] // isPlayer? stores in r13 = 0101 (257 as decimal) even this is a boolean in the code. But I want this as byte so it can store 0 or 1. How can I do this?

I want to compare later with cmp r13, (byte)1 but won't work. For now I replaced the 1 with 101

Re: Why boolean gives me 0101 instead of 0 or 1

Posted: Sun Aug 21, 2022 8:38 pm
by Messy6666
use movzx

Code: Select all

movzx rax, BYTE PTR [r13+1f0]
test  rax, rax
je iszero
or just a byte part of a register:

Code: Select all

mov al, [r13+1f0]
test al, al
je iszero
if you want to compare it later maybe use one of the cmov instructions for better performance

Re: Why boolean gives me 0101 instead of 0 or 1

Posted: Mon Aug 22, 2022 9:28 pm
by MaZy
Thanks I tried yesterday and it worked. Couldn't reponse. I will try cmov as well. Does cmov just work with al or also with byte ptr?

I have another problem. For now I set [r13+28] to 1f. It is a floating number from 0f to 1f. xmm5 contains the new value. I thought instead of setting to 1 I compare if the new value is greater. If yes just use xmm5 otherwise skip setting new value. So it can never go down but up. In the end it does not matter if I do just 1 directly or let the game just use new higher values. It is just for learning.

But I tried many things like comiss, or cmpss etc but in the cheat engine it shows xmm5 is 0.5 when it is (for instance) 0.51383419 in game. So it looks like it compares 0.5 with 0.5 and it is always equal and not greater or less.

Do you have an idea?

Code: Select all

movss xmm11, [rsi+28] // get the current value
comiss xmm5, xmm11 // compare (ingame is not equal, but here it is).
jng return // if not greater (xmm5 should greater than the current value xmm11) then skip.