?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. /*-------------------------------------------------------------------------
  2.    _fsrshift.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_rshift_a
  41. fs_rshift_a:
  42.         jz      00020$
  43.         mov     r0, a
  44.         add     a, exp_a        // adjust exponent
  45.         jnc     00001$
  46.         mov     a, #255         // don't roll over
  47. 00001$:
  48.         mov     exp_a, a
  49. #ifdef FLOAT_SHIFT_SPEEDUP
  50.         mov     a, r0
  51.         add     a, #248
  52.         jnc     00003$
  53.         xch     a, r4
  54.         xch     a, r3
  55.         xch     a, r2
  56.         mov     r1, a
  57.         clr     a
  58.         xch     a, r4
  59.         //mov   r1, ar2         // avoid dependence on register bank
  60.         //mov   r2, ar3
  61.         //mov   r3, ar4
  62.         //mov   r4, #0
  63.         add     a, #248
  64.         jnc     00003$
  65.         xch     a, r3
  66.         xch     a, r2
  67.         mov     r1, a
  68.         clr     a
  69.         xch     a, r3
  70.         //mov   r1, ar2
  71.         //mov   r2, ar3
  72.         //mov   r3, #0
  73.         add     a, #248
  74.         jnc     00003$
  75.         xch     a, r2
  76.         mov     r1, a
  77.         clr     a
  78.         xch     a, r2
  79.         //mov   r1, ar2
  80.         //mov   r2, #0
  81.         add     a, #248
  82.         jnc     00003$
  83.         mov     r1, #0
  84.         ret
  85. 00003$:
  86.         add     a, #8
  87.         jz      00020$
  88.         mov     r0, a
  89. #endif
  90. 00005$:
  91.         clr     c
  92.         mov     a, r4
  93.         rrc     a
  94.         mov     r4, a
  95.         mov     a, r3
  96.         rrc     a
  97.         mov     r3, a
  98.         mov     a, r2
  99.         rrc     a
  100.         mov     r2, a
  101.         mov     a, r1
  102.         rrc     a
  103.         mov     r1, a
  104.         djnz    r0, 00005$
  105. 00020$:
  106.         ret
  107.         __endasm;
  108. }
  109.  
  110. #endif
  111.