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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [machine/] [h8500/] [mulsi3.c] - Blame information for rev 262

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
 
2
typedef union {
3
  struct {
4
  unsigned int msw;
5
  unsigned int lsw;
6
} s;
7
  long v;
8
} u;
9
 
10
long __mulsi3(u a, u b)
11
{
12
  int s;
13
  long pp1;
14
  long pp2;
15
  long r;
16
 
17
  if (a.s.msw == 0 &&
18
      b.s.msw == 0)
19
    {
20
      return (long)a.s.lsw * b.s.lsw;
21
    }
22
 
23
  s = 0;
24
  if (a.v < 0)
25
    {
26
      s = 1;
27
      a.v = - a.v;
28
    }
29
  if (b.v < 0)
30
    {
31
      s = 1-s;
32
      b.v = - b.v;
33
    }
34
 
35
  pp1 = (long)a.s.lsw * b.s.lsw ;
36
  pp2 = (long)a.s.lsw * b.s.msw + (long)a.s.msw * b.s.lsw;
37
 
38
  pp1 += pp2 << 16;
39
 
40
  if (s)
41
    {
42
      pp1 = -pp1;
43
    }
44
  return pp1;
45
}
46
long __mulpsi3(long a, long b)
47
{
48
 return a*b;
49
}
50
 
51
 
52
short
53
__mulhi3(short a, short b)
54
{
55
  int r;
56
 
57
  r = 0;
58
  while (a)
59
    {
60
      if (a & 1)
61
        {
62
          r += b;
63
 
64
        }
65
      b<<=1;
66
      a>>=1;
67
 
68
    }
69
  return r;
70
}
71
 
72
 

powered by: WebSVN 2.1.0

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