1
/* -*- Mode: Asm -*- */
3
ceil.S is part of FPlib V 0.3.0 ported to avr-as
4
for copyright and details see readme.fplib
6
*----------------------------------------------------------------------------------------
10
* gr��ter ganzzahliger Wert, der nicht kleiner als arg ist
11
* f�r X > 4B 7F FF FF : X = X (Zahlen haben keinen Bruchteil mehr)
13
* X == (float)(long)X X = X (Zahlen hat keinen Bruchteil)
14
* X != (float)(long)X X = (float)(long)X+1 (Zahlen hat einen Bruchteil)
18
* comments on ceil & floor
19
* 1.0 = 7F:80 00 00 00 ->
20
* denormalize to LSB of mantissa == 1.0
22
* 2.0 = 80:80 00 00 00 ->
34
RCALL _U(__fp_split1) ; split up in sign : exp : fraction : fraction extention
35
; x T R19 R18:rSI0:R16: R1
36
CPI rA3,0x7F ; Exp >= 0x7F -> arg >= 1.0
38
BRTS _ceil_01 ; |arg| < 1.0 -> ceil = / 1.0 f�r X > 0.0
39
TST rA3 ; \ 0.0 f�r X <= 0.0
50
ROR rA1 ; shift out fractional bits to the right
51
ROR rA0 ; until mantissa is a normalized unsigned
52
adc rAE,rT1c ; rAE cleard by fp_split1, rT1c = __zero_reg__
55
_ceil_100: ; |arg| >= 1.0
60
BRTS _ceil_300 ; LSB now is exactely 1 or greater
61
TST rAE ; any bit shiftet out? if LSB > 1 then rAE is zero
63
SUBI rA0,0xFF ; else next bigger value
67
CLR rAE ; rT0 must not be cleared : rAE=0 no rounding anyway