source: trunk/libs/newlib/src/newlib/libc/machine/h8500/cmpsi.c @ 444

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: 1.6 KB
Line 
1
2union u
3{
4  struct 
5    {
6      short int msw;
7      unsigned short lsw;
8    } w;
9  long l;
10};
11
12union us
13{
14  struct 
15    {
16      short int msw;
17      unsigned short lsw;
18    } w;
19  long l;
20};
21
22int
23__cmpsi2(long arga,
24         short int msw_b, unsigned short int lsw_b)
25{
26  union u u;
27  u.l = arga;
28
29  if (u.w.msw != msw_b)
30    {
31      if (u.w.msw < msw_b) return 0;
32      return 2;
33    }
34  if (u.w.lsw != lsw_b) 
35    {
36      if (u.w.lsw < lsw_b) return 0;
37      return 2;
38    }
39  return 1;
40}
41
42
43int
44__ucmpsi2(unsigned long arga,
45         unsigned short int msw_b, unsigned short int lsw_b)
46{
47  union us u;
48  u.l = arga;
49
50  if (u.w.msw != msw_b)
51    {
52      if (u.w.msw < msw_b) return 0;
53      return 2;
54    }
55  if (u.w.lsw != lsw_b) 
56    {
57      if (u.w.lsw < lsw_b) return 0;
58      return 2;
59    }
60  return 1;
61}
62
63
64union pu
65{
66  struct {
67    char ignore;
68    signed char msb;
69    unsigned short lsw;
70  } w;
71  long l;
72};
73
74union pun
75{
76  struct {
77    char ignore;
78    unsigned char msb;
79    unsigned short lsw;
80  } w;
81  long l;
82};
83
84
85int
86__cmppsi2(long arga, long argb)
87{
88  union pu a;
89  union pu b;
90  a.l = arga;
91  b.l = argb;
92
93  if (a.w.msb != b.w.msb)
94    {
95      if (a.w.msb < b.w.msb) return 0;
96      return 2;
97    }
98  if (a.w.lsw != b.w.lsw)
99    {
100      if (a.w.lsw < b.w.lsw) return 0;
101      return 2;
102    }
103  return 1;
104}
105
106
107int
108__ucmppsi2(long arga, long argb)
109{
110  union pun a;
111  union pun b;
112  a.l = arga;
113  b.l = argb;
114
115  if (a.w.msb != b.w.msb)
116    {
117      if (a.w.msb < b.w.msb) return 0;
118      return 2;
119    }
120  if (a.w.lsw != b.w.lsw)
121    {
122      if (a.w.lsw < b.w.lsw) return 0;
123      return 2;
124    }
125  return 1;
126}
Note: See TracBrowser for help on using the repository browser.