?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. /*-------------------------------------------------------------------------
  2.    _fsnormalize.c - Floating point library in optimized assembly for 8051
  3.  
  4.    Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
  5.  
  6.    This library is free software; you can redistribute it and/or modify it
  7.    under the terms of the GNU General Public License as published by the
  8.    Free Software Foundation; either version 2, or (at your option) any
  9.    later version.
  10.  
  11.    This library is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with this library; see the file COPYING. If not, write to the
  18.    Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  19.    MA 02110-1301, USA.
  20.  
  21.    As a special exception, if you link this library with other files,
  22.    some of which are compiled with SDCC, to produce an executable,
  23.    this library does not by itself cause the resulting executable to
  24.    be covered by the GNU General Public License. This exception does
  25.    not however invalidate any other reasons why the executable file
  26.    might be covered by the GNU General Public License.
  27. -------------------------------------------------------------------------*/
  28.  
  29.  
  30.  
  31. #define __SDCC_FLOAT_LIB
  32. #include <float.h>
  33.  
  34.  
  35. #ifdef FLOAT_ASM_MCS51
  36.  
  37. static void dummy(void) __naked
  38. {
  39.         __asm
  40.         .globl  fs_normalize_a
  41. fs_normalize_a:
  42. #ifdef FLOAT_SHIFT_SPEEDUP
  43.         mov     r0, #4
  44.         mov     a, r4
  45. 00001$:
  46.         jnz     00003$
  47.         mov     a, exp_a
  48.         add     a, #248
  49.         jnc     00002;denormalized
  50.         mov     exp_a, a
  51.         clr     a
  52.         xch     a, r1
  53.         xch     a, r2
  54.         xch     a, r3
  55.         mov     r4, a
  56.         //mov   r4, ar3
  57.         //mov   r3, ar2
  58.         //mov   r2, ar1
  59.         //mov   r1, #0
  60.         djnz    r0, 00001$
  61.         ret
  62. #endif
  63. 00002$:
  64.         mov     a, r4
  65. 00003$:
  66.         mov     r0, #32
  67.         inc     exp_a
  68. 00004$:
  69.         jb      acc.7, 00006$
  70.         djnz    exp_a, 00005$
  71.         ret                     ;denormalized
  72. 00005$:
  73.         clr     c
  74.         mov     a, r1
  75.         rlc     a
  76.         mov     r1, a
  77.         mov     a, r2
  78.         rlc     a
  79.         mov     r2, a
  80.         mov     a, r3
  81.         rlc     a
  82.         mov     r3, a
  83.         mov     a, r4
  84.         rlc     a
  85.         mov     r4, a
  86.         djnz    r0, 00004$
  87. 00006$:
  88.         dec     exp_a
  89.         ret
  90.         __endasm;
  91. }
  92.  
  93. #endif
  94.