It is currently Wed Jan 20, 2021 4:43 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: learning asm
PostPosted: Sat Aug 02, 2014 4:56 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jul 02, 2009 5:42 am
Posts: 327
I am trying to learn asm and have these instructions.

x.d=1
y.d=2
!fld qword [v_x]
!fld qword [v_y]
!cmp st0,st1

I want to compare st0,st1 to see if it is greater than, but I get an error on the cpm instructions.

I am trying to do an if statement, if x>y :D


Top
 Profile  
Reply with quote  
 Post subject: Re: learning asm
PostPosted: Sat Aug 02, 2014 5:14 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3710
Location: Netherlands
You need the fcomi instruction to compare when using x87 fpu.
http://x86.renejeschke.de/html/file_mod ... id_88.html

If you don't mind using SSE2, you can use xmm registers and use comisd to compare.
The advantage of SSE2 is that you don't have to consider the fpu stack.

_________________
macOS 10.15 Catalina, Windows 10


Top
 Profile  
Reply with quote  
 Post subject: Re: learning asm
PostPosted: Sat Aug 02, 2014 5:46 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jul 02, 2009 5:42 am
Posts: 327
Thanks Wilbert :D

I got this working now, but how would I use SSE2 instructions for this?


Top
 Profile  
Reply with quote  
 Post subject: Re: learning asm
PostPosted: Sat Sep 13, 2014 6:24 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3710
Location: Netherlands
Sorry I didn't notice your question spacebuddy.

Here's how to do it with SSE2 in case you are still interested.
Code:
x.d=1
y.d=-2

!movsd xmm0, [v_x]
!movsd xmm1, [v_y]
!comisd xmm0, xmm1
!ja x_greater_than_y
End
!x_greater_than_y:
Debug "x > y"

or a little bit shorter
Code:
x.d=1
y.d=-2

!movsd xmm0, [v_x]
!comisd xmm0, [v_y]
!ja x_greater_than_y
End
!x_greater_than_y:
Debug "x > y"

_________________
macOS 10.15 Catalina, Windows 10


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye