I know it's an old thread but why make a new thread of the same subject?
for 32-bit change rax to eax
btw in the procedure PBfrac the result is not returned unless assigned to a variable
Code: Select all
ImportC ""
floor.d( doubleValue.d)
ceil.d( doubleValue.d)
trunc.d( doubleValue.d)
EndImport
Procedure.i PBfloor(x.d)
EnableASM
movsd xmm0,[p.v_x]
!roundsd xmm0, xmm0, 9
!cvttsd2si rax, xmm0
DisableASM
ProcedureReturn
EndProcedure
Procedure.i PBceil(x.d)
EnableASM
movsd xmm0,[p.v_x]
!roundsd xmm0, xmm0, 10
!cvttsd2si rax, xmm0
DisableASM
ProcedureReturn
EndProcedure
Procedure.i PBtrunc(x.d)
EnableASM
movsd xmm0,[p.v_x]
!cvttsd2si rax, xmm0
DisableASM
ProcedureReturn
EndProcedure
Procedure.d PBfrac(x.d)
frc.d
EnableASM
movsd xmm0,[p.v_x]
!cvttsd2si rax, xmm0
!cvtsi2sd xmm1,rax
!subsd xmm0,xmm1
movsd [p.v_frc],xmm0
DisableASM
ProcedureReturn frc
EndProcedure
i.i
x.d=4
y.d=0.1
Debug "PBfloor CRTfloor PBceil CRTceil PBtrunc CRTtrunc PBfrac"
For i=1 To 12
s.s="("+StrD(PBfloor(x),4)+" , "+StrD(floor(x),4)+"), ("+StrD(PBceil(x),4)+" , "+StrD(ceil(x),4)
s+"), ("+StrD(PBtrunc(x),4)+" , "+StrD(trunc(x),4)+") "+StrD(PBfrac(x),15)
Debug s
x+y
Next
x=-4
Debug "PBfloor CRTfloor PBceil CRTceil PBtrunc CRTtrunc PBfrac"
For i=1 To 12
s.s="("+StrD(PBfloor(x),4)+" , "+StrD(floor(x),4)+"), ("+StrD(PBceil(x),4)+" , "+StrD(ceil(x),4)
s+"), ("+StrD(PBtrunc(x),4)+" , "+StrD(trunc(x),4)+") "+StrD(PBfrac(x),15)
Debug s
x-y
Next