repo.or.cz
/
sdcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
struct / union in initializer, RFE #901.
[sdcc.git]
/
sdcc
/
device
/
lib
/
mos6502
/
_srslonglong.c
blob
01d38ca169a24f86755645bb82342075b4808c44
1
#include <stdint.h>
2
3
#ifdef __SDCC_LONGLONG
4
5
long long
_srslonglong
(
long long
l
,
char
s
)
6
{
7
8
uint8_t
*
const
b
= (
uint8_t
*)(&
l
);
9
unsigned char
shift
,
t1
,
t2
,
sign
;
10
signed char
zb
,
i
;
11
12
sign
=
b
[
7
]&
0x80
;
13
14
zb
=
s
>>
3
;
15
if
(
zb
) {
16
i
=
0
;
17
for
(;
i
<(
8
-
zb
);
i
++) {
18
b
[
i
]=
b
[
zb
+
i
];
19
}
20
for
(;
i
<
8
;
i
++)
21
b
[
i
]=
sign
?
0xff
:
0x00
;
22
}
23
24
shift
=
s
&
0x7
;
25
while
(
shift
--) {
26
t2
=
sign
;
27
for
(
i
=
7
-
zb
;
i
>=
0
;
i
--) {
28
t1
=
b
[
i
]&
1
;
29
b
[
i
]=(
b
[
i
]>>
1
)|
t2
;
30
t2
=
t1
?
0x80
:
0
;
31
}
32
}
33
34
return
(
l
);
35
}
36
37
#endif