Announcement

Collapse
No announcement yet.

SSE & floating point

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SSE & floating point

    Does anyone know how to load a xmm register with a single precision variable?

  • #2
    This works in FreeBASIC.
    Code:
    Function Dummy( ByVal x As Single, ByVal y As Single ) As Single
    
    Asm
      movd xmm0, [x]
      movd xmm1, [y]
      mulss xmm0, xmm1
      movd [Function], xmm0
    End Asm
    
    End Function
    
    Print Dummy( 3.142, 4.5 )
    
    Sleep
    This does not in PowerBASIC
    Code:
    #Compile Exe
    #Dim All
    
    Function PBMain () As Long
    
    Print Dummy( 3.142, 4.5 )
    
    WaitKey$
    
    End Function
    
    Function Dummy( ByVal x As Single, ByVal y As Single ) As Single
    
    Prefix "!"
      movd xmm0, [x]
      movd xmm1, [y]
      mulss xmm0, xmm1
      movd [Function], xmm0
    End Prefix
    
    End Function
    With regard 'movd xmm0, [x]' I am getting "Integer constant expected".

    Comment


    • #3
      David

      Try this.
      .
      Code:
      #COMPILE EXE
      #DIM ALL
      
      FUNCTION PBMAIN () AS LONG
      
      PRINT Dummy( 3.142, 4.5 )
      
      WAITKEY$
      
      END FUNCTION
      
      FUNCTION Dummy( BYVAL x AS SINGLE, BYVAL y AS SINGLE ) AS SINGLE
      
       ! movd xmm0, x
       ! movd xmm1, y
       ! mulss xmm0, xmm1
       ! movd Function, xmm0
      
      END FUNCTION

      Comment


      • #4
        Blimey! I tried so many things but removing the square brackets did not occur to me, flaming compilers.

        Thanks, Ribeiro.

        And this for Doubles
        Code:
        Function Dummy( ByVal x As Double, ByVal y As Double ) As Double
        
         ! movq xmm0, x
         ! movq xmm1, y
         ! mulsd xmm0, xmm1
         ! movq Function, xmm0
        
        End Function

        Comment


        • #5
          I had tried it.
          Big numbers.

          https://forum.powerbasic.com/forum/u...floating-point

          And for EXTEND also.

          Code:
          FUNCTION Dummy( BYVAL x AS EXT, BYVAL y AS EXT ) AS EXT
          
           ! movd xmm0, x
           ! movd xmm1, y
           ! mulss xmm0, xmm1
           ! movd Function, xmm0
          
          END FUNCTION
          Last edited by Ribeiro Alvo; 13 May 2019, 06:19 PM. Reason: addendum

          Comment


          • #6
            No. Look at my last post, every opcode is different because Doubles are used. The devil is in the detail, remember?

            We can use my last post for EXT but moving a quad word is as good as it gets, so we will be casting a Double as an EXT but only get 53-bit granularity.

            Comment

            Working...
            X