Last change
on this file since 444 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
762 bytes
|
Line | |
---|
1 | |
---|
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 | |
---|
Note: See
TracBrowser
for help on using the repository browser.