blob: 9dd1f427d00057793037a31d3bdd64f05ba88064 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/* { dg-do run } */
/* { dg-options { -fno-peephole2 } } */
#include <stdlib.h>
typedef __UINT16_TYPE__ uint16_t;
typedef __INT16_TYPE__ int16_t;
typedef __UINT8_TYPE__ uint8_t;
uint8_t __attribute__((noinline,noclone))
fun_inc (uint8_t c0)
{
register uint8_t c asm ("r15") = c0;
/* Force target value into R15 (lower register) */
asm ("" : "+l" (c));
c++;
if (c >= 0x80)
c = 0;
asm ("" : "+l" (c));
return c;
}
uint8_t __attribute__((noinline,noclone))
fun_dec (uint8_t c0)
{
register uint8_t c asm ("r15") = c0;
/* Force target value into R15 (lower register) */
asm ("" : "+l" (c));
c--;
if (c < 0x80)
c = 0;
asm ("" : "+l" (c));
return c;
}
uint8_t __attribute__((noinline,noclone))
fun_neg (uint8_t c0)
{
register uint8_t c asm ("r15") = c0;
c = -c;
if (c >= 0x80)
c = 0;
return c;
}
uint16_t __attribute__((noinline,noclone))
fun_adiw (uint16_t c0)
{
register uint16_t c asm ("r24") = c0;
/* Force target value into R24 (for ADIW) */
asm ("" : "+r" (c));
c += 2;
if (c >= 0x8000)
c = 0;
asm ("" : "+r" (c));
return c;
}
int main()
{
if (fun_inc (0x7f) != 0)
abort();
if (fun_neg (0x80) != 0)
abort();
if (fun_adiw (0x7ffe) != 0)
abort();
exit (0);
return 0;
}
|