OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [config/] [scarts16/] [divdi.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
unsigned long long __divdi3(unsigned long long a, unsigned long long b)
2
{
3
  long long result;
4
  long long t;
5
  int sign;
6
 
7
  if (b == 0)
8
    return a;
9
  if (a == 0)
10
    return a;
11
 
12
  sign = (a ^ b) >> 48;
13
 
14
  if (a < 0)
15
    a = -a;
16
  if (b < 0)
17
    b = -b;
18
 
19
  t = b;
20
  while ((long long)b > 0)
21
    b <<= 1;
22
 
23
  result = 0;
24
  while (b >= t)
25
    {
26
      result <<= 1;
27
      if (b <= a)
28
        {
29
          a -= b;
30
          result += 1;
31
        }
32
      b >>= 1;
33
    }
34
 
35
  if (sign < 0)
36
    result = -result;
37
 
38
  return result;
39
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.