float to fixed point
f2lf(float s,long* d,long* p)
{
long temp;
unsigned char count;
_asm {
mov eax,s
shl eax,1
mov ebx,eax
mov cl,24
shr ebx,cl
mov count,bl
mov cl,8
shl eax,cl
stc
rcr eax,1
shr eax,1
mov temp,eax
}
*p = count-125;
*d = temp;
if (sfixed point to float
lf2f(long s, long p, float* d)
{
unsigned char count;
float temp;
long lw;
p = p + 125;
count = p;
lw = abs(s);
_asm {
mov bl,count
mov eax,lw
shl eax,1
shl eax,1
shr ebx,1
rcr eax,1
shr ebx,1
rcr eax,1
shr ebx,1
rcr eax,1
shr ebx,1
rcr eax,1
shr ebx,1
rcr eax,1
shr ebx,1
rcr eax,1
shr ebx,1
rcr eax,1
shr ebx,1
rcr eax,1
mov ecx,s
add ecx,0
jns step1
stc
step1:
rcr eax,1
mov temp,eax
}
*d = temp;
}
- Jan 09 Mon 2006 22:23
float跟fixed point的轉換
close
全站熱搜
留言列表