?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. /*-------------------------------------------------------------------------
  2.    _logexpf.c
  3.  
  4.    Copyright (C) 2005, Paul Stoffregen
  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. #define __SDCC_MATH_LIB
  30. #include <math.h>
  31.  
  32.  
  33. #ifdef MATH_ASM_MCS51
  34.  
  35. // This code is shared by both logf() and expf(), so it goes in this
  36. // separate file to allow the linker to include it when either
  37. // function is needed, but only 1 copy when both are used.
  38.  
  39. void _fs_cordic_rshift_r765_unsigned(void) __naked
  40. {
  41.         __asm
  42.         ar2 = 0x02
  43.         ar3 = 0x03
  44.         ar4 = 0x04
  45.         ar5 = 0x05
  46.         ar6 = 0x06
  47.         ar7 = 0x07
  48.         ar0 = 0x00
  49.         ar1 = 0x01
  50.  
  51.         add     a, #248
  52.         jnc     00003$
  53.         mov     b, r5
  54.         mov     r5, ar6
  55.         mov     r6, ar7
  56.         mov     r7, #0
  57.         add     a, #248
  58.         jnc     00003$
  59.         mov     b, r5
  60.         mov     r5, ar6
  61.         mov     r6, #0
  62.         add     a, #248
  63.         jnc     00003$
  64.         mov     b, r5
  65.         mov     r5, #0
  66.         add     a, #248
  67.         jnc     00003$
  68.         mov     b, #0
  69.         ret
  70. 00003$:
  71.         add     a, #8
  72.         jz      00030$
  73.         push    ar0
  74.         mov     r0, a
  75. 00010$:
  76.         clr     c
  77.         mov     a, r7
  78.         rrc     a
  79.         mov     r7, a
  80.         mov     a, r6
  81.         rrc     a
  82.         mov     r6, a
  83.         mov     a, r5
  84.         rrc     a
  85.         mov     r5, a
  86.         mov     a, b
  87.         rrc     a
  88.         mov     b, a
  89.         djnz    r0, 00010$
  90.         pop     ar0
  91. 00030$:
  92.         ret
  93.         __endasm;
  94. }
  95.  
  96. __code unsigned char _fs_natural_log_table[] = {
  97. 0xFF, 0x42, 0x2E, 0x16,         // 0.693147180560
  98. 0xF6, 0x91, 0xF9, 0x0C,         // 0.405465108108
  99. 0xF2, 0xFD, 0x23, 0x07,         // 0.223143551314
  100. 0xEE, 0xE0, 0xC4, 0x03,         // 0.117783035656
  101. 0x0C, 0xA3, 0xF0, 0x01,         // 0.060624621816
  102. 0xD8, 0x14, 0xFC, 0x00,         // 0.030771658667
  103. 0xA3, 0x02, 0x7F, 0x00,         // 0.015504186536
  104. 0x55, 0xC0, 0x3F, 0x00,         // 0.007782140442
  105. 0x0B, 0xF0, 0x1F, 0x00,         // 0.003898640416
  106. 0x01, 0xFC, 0x0F, 0x00,         // 0.001951220131
  107. 0x00, 0xFF, 0x07, 0x00,         // 0.000976085973
  108. 0xC0, 0xFF, 0x03, 0x00,         // 0.000488162080
  109. 0xF0, 0xFF, 0x01, 0x00,         // 0.000244110828
  110. 0xFC, 0xFF, 0x00, 0x00,         // 0.000122062863
  111. 0xFF, 0x7F, 0x00, 0x00,         // 0.000061033294
  112. 0x00, 0x40, 0x00, 0x00,         // 0.000030517112
  113. 0x00, 0x20, 0x00, 0x00,         // 0.000015258673
  114. 0x00, 0x10, 0x00, 0x00,         // 0.000007629365
  115. 0x00, 0x08, 0x00, 0x00,         // 0.000003814690
  116. 0x00, 0x04, 0x00, 0x00,         // 0.000001907347
  117. 0x00, 0x02, 0x00, 0x00,         // 0.000000953674
  118. 0x00, 0x01, 0x00, 0x00,         // 0.000000476837
  119. 0x80, 0x00, 0x00, 0x00,         // 0.000000238419
  120. 0x40, 0x00, 0x00, 0x00,         // 0.000000119209
  121. 0x20, 0x00, 0x00, 0x00,         // 0.000000059605
  122. 0x10, 0x00, 0x00, 0x00,         // 0.000000029802
  123. 0x08, 0x00, 0x00, 0x00,         // 0.000000014901
  124. 0x04, 0x00, 0x00, 0x00,         // 0.000000007451
  125. 0x02, 0x00, 0x00, 0x00,         // 0.000000003725
  126. 0x01, 0x00, 0x00, 0x00          // 0.000000001863
  127. };
  128.  
  129. #endif
  130.