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 


How to push and pop xmm registers?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Wed Mar 04, 2015 3:27 pm    Post subject: How to push and pop xmm registers? Reply with quote

I can't seem to find a way to push and pop them like with the standard "eax,ecx..." registers. Any of you guys know how?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Mar 04, 2015 8:50 pm    Post subject: Reply with quote

Just trying to save the previous value to restore it later?

Code:
alloc(backup,16)
registersymbol(backup)

movdqu dqword [backup],xmm0 // save it
movdqu xmm0,dqword [backup] // restore it
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Thu Mar 05, 2015 11:17 am    Post subject: Reply with quote

Oh, I thought it was gonna be something like:
Code:
push xmm0
pop xmm0
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Thu Mar 05, 2015 2:16 pm    Post subject: Reply with quote

when you are 100% sure that game code uses only lower half of xmm register (you see movss or movsd or movd or movq or ...., not movaps, not movapd, not .....), you can use this:


Code:
movlhps xmm0,xmm0 // Moves low quadword of xmm0 to high quadword of xmm0
movlhps xmm1,xmm1 // Moves low quadword of xmm1 to high quadword of xmm1
// "push"

do stuff on xmm0 and xmm1. some calculations, compares, etc

movhlps xmm0,xmm0 // Moves high quadword of xmm0 to low quadword of xmm0
movhlps xmm1,xmm1 // Moves high quadword of xmm1 to low quadword of xmm1
// "pop"

(there are MOVLHPS and MOVHLPS)

_________________


Last edited by mgr.inz.Player on Fri Mar 06, 2015 5:48 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
STN
I post too much
Reputation: 42

Joined: 09 Nov 2005
Posts: 2672

PostPosted: Thu Mar 05, 2015 3:17 pm    Post subject: Reply with quote

deama1234 wrote:
Oh, I thought it was gonna be something like:
Code:
push xmm0
pop xmm0


This is not possible because

a)xmm registers set are 128-bit registers (that is pretty huge) and push/pop can only handle 32bit values. There are the instructions pushq/popq for handling 64bit registers (rax, rcx etc) with some limitations (can't handle immediate 64bit values).

b)Most importantly, you know you can't use push to save FPU stack registers even in 32bit (st0, st1 etc) but need specific instruction set called the fpu instruction set to handle them. Same way, you will need special instruction set (THE SSE instruction set) to handle xmm registers.

That is the best i could explain in laymen terms.

Lastly, i guess you could use the FXSAVE and FXRSTOR instructions set but that is a bit extreme and has some limitations (http://x86.renejeschke.de/html/file_module_x86_id_128.html).


PS: To expand on Zanzer's answer, if you can't be arsed to allocate memory and define a symbol (its a hassle) use this.

//For saving of just one xmm register e.g xmm0
sub esp, 16 // allocate space on stack
movdqu dqword [esp], xmm0

//Pop back the value from stack to xmm0
movdqu xmm0, dqword [esp]
add esp, 16 // re-align the stack

Ot if you are manipulating multiple xmm registers, just reserve appropriate space on stack and re-align once you are done (pop or restore emulation) or set up a stack frame.

_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Fri Mar 06, 2015 4:01 pm    Post subject: Reply with quote

Thanks guys!
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