Compare the last 2 bytes of an address in a register

Anything Cheat Engine related, bugs, suggestions, helping others, etc..
Post Reply
User avatar
EyeOfTheMind86
Expert Cheater
Expert Cheater
Posts: 50
Joined: Sun Mar 12, 2017 5:39 pm
Reputation: 14

Compare the last 2 bytes of an address in a register

Post by EyeOfTheMind86 »

Hello everyone, I'm learning a lot through your tutorials and posts but I'm having a hard time doing what maybe is a simple thing.
I'm playing around with Helldivers, the first game specifically and I was looking for a way to filter out the main gun ammo count from the rest of the addresses stored in the register RCX.
By using breakpoints, I realised that, to the specific ammo address in RCX, corresponds an address in RAX where the last 2 bytes are always the same: ????3E78.
Is there a way to check, in ASM, if a specific address in RAX ends with 3E78?
I hope my question makes sense, and I apologise if it was already answered somewhere.

User avatar
Messy6666
Table Makers
Table Makers
Posts: 724
Joined: Fri Sep 25, 2020 5:45 pm
Reputation: 743

Re: Compare the last 2 bytes of an address in a register

Post by Messy6666 »

only to answer to your 2 bytes comparing:
use the 16bit part of the register, ie: AX

so: cmp AX, 3E78

User avatar
Rhark
Expert Cheater
Expert Cheater
Posts: 2934
Joined: Tue Apr 16, 2019 1:27 am
Reputation: 1248

Re: Compare the last 2 bytes of an address in a register

Post by Rhark »

You could also try something like this:

Code: Select all

push r15
mov r15,rcx
add r15,3e78
cmp rax,r15
jne @f
//your code here

@@:
pop r15

User avatar
EyeOfTheMind86
Expert Cheater
Expert Cheater
Posts: 50
Joined: Sun Mar 12, 2017 5:39 pm
Reputation: 14

Re: Compare the last 2 bytes of an address in a register

Post by EyeOfTheMind86 »

Thank you both very much. I knew about the AX being useful to check half of an address, but I thought using cmp AX would compare the first 16 bit only and not the last part of the address. I guess I need to find a proper ASM manual which explains those registers more in depth, I'm learning by trial and error mostly.
I learned a new thing, thanks very much.

User avatar
Messy6666
Table Makers
Table Makers
Posts: 724
Joined: Fri Sep 25, 2020 5:45 pm
Reputation: 743

Re: Compare the last 2 bytes of an address in a register

Post by Messy6666 »

Nice! +rep
never stop learning (same for me).

[Link]
in your example we are talking about little-endian.

and this one explains it
[Link]

I used to have a good assembly site.. but can't find it atm.
Best to find it yourself

regards

Post Reply

Who is online

Users browsing this forum: No registered users