flat assembler
Message board for the users of flat assembler.

Index > Main > SSE and SSE2 tutorial?

Author
Thread Post new topic Reply to topic
alf_ua



Joined: 18 Dec 2003
Posts: 11
Location: Ukraine, Lviv
alf_ua
I have a very good MMX one but still can't found any SSE and SSE2 tutorial. If anyone have a link to it then please post it here.

Thanks a lot.

_________________
Codeing is an ART !
Post 07 Jan 2004, 00:01
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
SSE and SSE2 instructions are described in FASM manual, it should be anough to start. I haven't seen any tutorial yet Confused
Post 07 Jan 2004, 14:16
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen

_________________
x86asm.net
Post 07 Jan 2004, 19:44
View user's profile Send private message Visit poster's website Reply with quote
MattBro



Joined: 08 Nov 2003
Posts: 37
MattBro
Ive been playing around with some of the SSE2 instructions and I've run into a brick wall with this issue of privileged instructions. In particular I need to use fxsave and fxrstor to temporarily save these registers, however I run into an unhandled exception and a privileged instruction error when I try to use fxsave.

I have a 2.6 GHz pentium 4 and am running Windows XP SP-1, which I thought was SSE aware. I even tried setting bits in cr4, but I can't even access that register I believe due to the same privileged instruction error. I know my processor has SSE2 instructions, but I can't seem to run some of them. I must be missing something obvious with this privileged mode stuff, but I haven't find much about it on the web so far.

-Matt

_________________
-- -------------------------------------------------------
"I am the Way and the Truth and the Light, no one comes to the Father except through me" - Jesus
---------------------------------------------------------
Post 08 Oct 2004, 06:42
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
Quote:

I run into an unhandled exception...

You probably forgot to align the memory operand on a 16-byte boundary. Otherwise you get #GP.
Post 09 Oct 2004, 03:14
View user's profile Send private message Visit poster's website Reply with quote
MattBro



Joined: 08 Nov 2003
Posts: 37
MattBro
Perhaps you are right. I actually am a bit confused about how the alignment directive works in fasm. Here is a code fragment:

Code:

; printf call to a message box
; this version creates it's own local format string data
; It uses a different temporary buffer from Bprintf
; formstr should be an immediate string variable
macro Aprintf  formstr, [args]
{
common
local str00
jmp @f
str00 db formstr,0
@@:
  fxsave [fxmem]
  pusha
  if ~ args eq
   cinvoke wsprintf, _ctmp, str00, args
  else
   cinvoke wsprintf, _ctmp, str00
  end if
   invoke MessageBox,  HWND_DESKTOP, _ctmp, _gencap,MB_OK
  popa
  fxrstor [fxmem]
}

section '.data' data readable writeable

  times 2047 dd 0 
 stacktop dd 0 
_ctmp db ? 
 times 127 db 0  
 _gencap db 'MacroFlow',0000000
 align 4
label fxmem 
times 512 db 0
str0 db ' register 0 contains 0',0
align 4 
one dd 0

    


My basic problem is that I want to protect mmx / xmm registers while they are being used by external function calls. In this case I need to preserve the state while calling my print macro Aprintf. The data segment was auto-generated by my compiler, so its a little ugly.

Update: Actually looking at the debug output of my crashed routine, the fxsave call decompiles to:

fxsave [ds:40508Ch]

The hex address appears to be divisable by 4.

_________________
-- -------------------------------------------------------
"I am the Way and the Truth and the Light, no one comes to the Father except through me" - Jesus
---------------------------------------------------------
Post 09 Oct 2004, 04:35
View user's profile Send private message Visit poster's website Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
It should be
Code:
 align 16
label fxmem  
    
Post 09 Oct 2004, 06:10
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
MattBro



Joined: 08 Nov 2003
Posts: 37
MattBro
Well I'll be ! You are right. Thanks for your help.
I suppose that a lot of the other memory move instructions require 16 byte alignment as well ?

-Regards
Post 09 Oct 2004, 06:25
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
alf_ua wrote:
I have a very good MMX one but still can't found any SSE and SSE2 tutorial. If anyone have a link to it then please post it here.

Thanks a lot.


and that was what i saw on intel.com
however i was searching for cpu instructions's descriptions from 8086 to pentium Sad
and they don't care about it.

MATRIX
Post 09 Oct 2004, 13:20
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
MattBro wrote:
I suppose that a lot of the other memory move instructions require 16 byte alignment as well ?

AFAIK there are only a few such instructions, such as some forms of MOV instructions. Note that these instructions have its versions which don't require the alignment: MOVDQA vs MOVDQU, MOVAPD vs MOVUPD, ...

_________________
x86asm.net
Post 16 Oct 2004, 16:04
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-2020, Tomasz Grysztar.

Powered by rwasa.