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
learning asm
Re: learning asm
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.
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.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
-
- Enthusiast
- Posts: 346
- Joined: Thu Jul 02, 2009 5:42 am
Re: learning asm
Thanks Wilbert
I got this working now, but how would I use SSE2 instructions for this?
I got this working now, but how would I use SSE2 instructions for this?
Re: learning asm
Sorry I didn't notice your question spacebuddy.
Here's how to do it with SSE2 in case you are still interested.
or a little bit shorter
Here's how to do it with SSE2 in case you are still interested.
Code: Select all
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"
Code: Select all
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"
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)