1
/* -*- Mode: Asm -*- */
3
modf.S is part of FPlib V 0.3.0 ported to avr-as
4
for copyright and details see readme.fplib
6
*----------------------------------------------------------------------------------------
8
* A = modf(A,&B) *B = integral part of A
9
* A = fractional part of A
20
RCALL _U(__fp_split1) ; clears rAE
25
MOV YL,rPL ; pointer to double
29
CLR rB0 ; preset zero integral part
31
TST rA3 ; if zero return zero for *int and mantissa
33
CPI rA3,0x7F ; Exp < 0x7F -> arg < 1.0 -> no integer part
37
MOV rTI0,rA3 ; keep temporarily
38
RCALL _U(__fp_merge) ; rT0 must not be cleared : rAE=0 no rounding anyway
44
CPI rTI0,0x96 ; rA3 >= 0x96 -> no fractional part
47
RCALL _U(__floatsisf) ;
54
ST Y+,rA3 ; A = integer part
56
SUBI rA3,0x80 ; A = -int(x)
72
ST Y+,rB3 ; no fractional part
76
RJMP _U(__fp_merge) ; rT0 must not be cleared : rAE=0 no rounding anyway