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
/
support
/
regression
/
tests
/
bug-2708.c
blob
c6a136d43f041a3ef5f30f06a81c6c0142fb2aee
1
/* bug-2708.c
2
The STM8 peephole optimizer didn't like indirect addressing modes in inline asm.
3
*/
4
5
#include <testfwk.h>
6
#include <stdint.h>
7
8
#ifdef __SDCC
9
#pragma std_c99
10
#endif
11
12
uint8_t
*
cp
;
13
14
void
f1
(
void
)
15
{
16
*
cp
>>=
1
;
17
}
18
19
#ifdef __SDCC_stm8
20
21
void
f2
(
void
)
22
{
23
24
__asm
25
srl
[
_cp
]
26
__endasm
;
27
}
28
29
void
f3
(
void
)
30
{
31
__asm
32
ldw y
,
_cp
33
srl
(
y
)
34
__endasm
;
35
}
36
37
void
f4
(
void
)
38
{
39
__asm
40
ld a
, [
_cp
]
41
srl a
42
ld
[
_cp
],
a
43
__endasm
;
44
}
45
46
void
f5
(
void
)
47
{
48
__asm
49
clrw x
50
srl
([
_cp
],
x
)
51
__endasm
;
52
}
53
54
#else
55
56
#define f2 f1
57
#define f3 f1
58
#define f4 f1
59
#define f5 f1
60
61
#endif
62
63
64
void
testBug
(
void
)
65
{
66
uint8_t
c
;
67
cp
= &
c
;
68
69
c
=
0xaa
;
70
f1
();
71
ASSERT
(
c
==
0x55
);
72
73
c
=
0xaa
;
74
f2
();
75
ASSERT
(
c
==
0x55
);
76
77
c
=
0xaa
;
78
f3
();
79
ASSERT
(
c
==
0x55
);
80
81
c
=
0xaa
;
82
f4
();
83
ASSERT
(
c
==
0x55
);
84
85
c
=
0xaa
;
86
f5
();
87
ASSERT
(
c
==
0x55
);
88
}
89