flat assembler
Message board for the users of flat assembler.

Index > Main > [Help] - Saving xmm register

Author
Thread Post new topic Reply to topic
ctl3d32



Joined: 30 Dec 2009
Posts: 206
Location: Brazil
ctl3d32 10 Jan 2011, 03:09
Hi Folks!

Need help to save xmm register state. Is it possible?

Something like:

Code:
push xmm3 ;save xmm3 value
stdcall something ;proc something will change xmm3 register value
pop xmm3 ;restore xmm3 value
    


Thanks in advance,
ctl3d32
Post 10 Jan 2011, 03:09
View user's profile Send private message Reply with quote
idle



Joined: 06 Jan 2011
Posts: 440
Location: Ukraine
idle 10 Jan 2011, 07:15
Code:
movaps [esp] ;if destination aligned
movups [esp] ;if destination !aligned
    
Post 10 Jan 2011, 07:15
View user's profile Send private message Reply with quote
ctl3d32



Joined: 30 Dec 2009
Posts: 206
Location: Brazil
ctl3d32 10 Jan 2011, 13:41
I can't do this:

Code:
proc LUsolve a,l,u
   locals
            lij dq ?
             i dd ?
             j dd ?
   endl
   mov     [i],1
   mov     [j],1
   stdcall getLij,[a],[l],[u],[i],[j]
   movsd   [lij],xmm0
   stdcall setMatrixElem,[l],[i],[j],lij
endp
    


Only works if lij is declared at .bss or .data section.

Code:
proc LUsolve a,l,u
   locals
             i dd ?
             j dd ?
   endl
   mov     [i],1
   mov     [j],1
   stdcall getLij,[a],[l],[u],[i],[j]
   movsd   [lij],xmm0
   stdcall setMatrixElem,[l],[i],[j],lij
endp

section '.bss' ...
align 16
lij dq ?

    


Why?

Thanks
Post 10 Jan 2011, 13:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 12 Jan 2011, 08:13
ctl3d32 wrote:
I can't do this:

Code:
proc LUsolve a,l,u
   locals
            lij dq ?
             i dd ?
             j dd ?
   endl
   mov     [i],1
   mov     [j],1
   stdcall getLij,[a],[l],[u],[i],[j]
   movsd   [lij],xmm0
   stdcall setMatrixElem,[l],[i],[j],lij
endp
    


Only works if lij is declared at .bss or .data section.

Code:
proc LUsolve a,l,u
   locals
             i dd ?
             j dd ?
   endl
   mov     [i],1
   mov     [j],1
   stdcall getLij,[a],[l],[u],[i],[j]
   movsd   [lij],xmm0
   stdcall setMatrixElem,[l],[i],[j],lij
endp

section '.bss' ...
align 16
lij dq ?

    


Why?

Thanks
The reason is alignment. Use movupd to store to unaligned locations.

Also you need to use addr lij
Code:
stdcall setMatrixElem,[l],[i],[j],addr lij    
Post 12 Jan 2011, 08:13
View user's profile Send private message Visit poster's website Reply with quote
ctl3d32



Joined: 30 Dec 2009
Posts: 206
Location: Brazil
ctl3d32 12 Jan 2011, 11:59
Can i make local variables aligned 16 like in .data or .bss section?

Thanks
Post 12 Jan 2011, 11:59
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 12 Jan 2011, 12:27
yes, you can.

with align16 directive.

remember that every instructions and directives are designed to be alone, then, they can be inserted anywhere.
Post 12 Jan 2011, 12:27
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 12 Jan 2011, 13:31
ctl3d32 wrote:
Can i make local variables aligned 16 like in .data or .bss section?

Thanks
Short answer: No.

Long answer: Yes, but ... it requires extra either 1) extra code at function entry to force stack alignment at runtime, or 2) your whole application must be made stack alignment compliant everywhere.
Post 12 Jan 2011, 13:31
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 19 Jan 2011, 22:36
fxsave / fxrstor ??
Post 19 Jan 2011, 22:36
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.