Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Float values in c++ assembly

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
theashmaster
How do I cheat?
Reputation: 0

Joined: 15 Mar 2021
Posts: 3

PostPosted: Sat Mar 27, 2021 8:00 am    Post subject: Float values in c++ assembly Reply with quote

Hey, guys!

Thanks to @ParkourPenguin, I was able to get the X and Y coords of the mobs, which are both stored in xmm0 register. I was using this code to get the coords in Delphi, and it works like a charm:

Code:
 
asm
     mov edx, [chrPointer]
     mov ecx, [edx]
     push mobID
     add ecx,04
     mov eax,[ecx]
     call dword ptr [eax+$08]
     mov ecx,eax
     call getCoordsCall
     movaps xmm5,xmm0
     movss x,xmm0
     shufps xmm5,xmm5,85
     movss y,xmm5
end;


Now I want to use c++ assembly to get the same values, but this exact same function just crashes the game when I try it in c++. I have lots of other functions written in Delphi assembly that I'm using in c++ with no issues, but when it comes to get float values the game keeps crashing.

Does the above code have any incompatibility with c++? How do I retrieve values stored in xmm0 register in c++ assembly?

ps: this is the code I'm using in c++ assembly, which is actually the same one shown above:

Code:
   
_asm {
            mov eax, [Pointers::chrPointer]
            mov ecx, dword ptr ds : [eax]
            SETNE DL
            push VID
            add ecx, 04
            mov eax, [ecx]
            call dword ptr [eax + 0x8]
            mov ecx, eax
            call getCoordsCall
            movaps xmm5, xmm0
            movss pX, xmm0
            shufps xmm5, xmm5, 0x85
            movss y, xmm5
}
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Sat Mar 27, 2021 11:30 am    Post subject: Reply with quote

Why use dword ptr ds specifier only there, and what's with setne dl?

You can try to debug your application and get more information - i.e. where it's crashing and what machine code the compiler is assembling that code to.

ps: on msvc. you should be using __asm instead of _asm. The latter is only a synonym for the former for compatibility reasons.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites