i think this will be of interest, i started with this procedure:
Code: Select all
Procedure Sign_(*x.double) ;returns -1 if x<0, 0 if x=0, 1 if x>0, 2 if fperror
! mov edx,[esp]
! fld qword [edx]
! ftst
! fnstsw ax
! sahf
! jp fperror
! je fpequals
! jb x_isless_y
! ja x_isgreater_y
!fperror:
! mov eax,2
! jmp Fsign_end
!fpequals:
! mov eax,0
! jmp Fsign_end
!x_isless_y:
! mov eax,-1
! jmp Fsign_end
!x_isgreater_y:
! mov eax,1
!Fsign_end:
ProcedureReturn
EndProcedure
Code: Select all
Procedure Sign_(*x.double) ;returns -1 if x<0, 0 if x=0, 1 if x>0
;by Paul Dixon
! mov edx,[esp]
! fld qword [edx]
! ftst
! fstsw ax
! mov al,ah
! shr al,6
! xor ah,1
! xor ah,al
! shl ah,1
! Or al,ah
! And eax,3
! dec eax
ProcedureReturn
EndProcedure


