Mercurial > hg > CbC > old > device
annotate test/regargs.c @ 935:7672a37e7545 default tip
Raspbery PI ARM support begin
author | kono |
---|---|
date | Sat, 24 Dec 2016 03:02:57 +0000 |
parents | c55337499f96 |
children |
rev | line source |
---|---|
467 | 1 int printf(const char *format, ...); |
2 | |
800 | 3 extern unsigned long strlen(const char *s); |
4 | |
170 | 5 |
575 | 6 void |
170 | 7 arg1(int a1,int a2,int a3,int a4) |
8 { | |
800 | 9 printf("#0008:%d %d %d %d\n",a1,a2,a3,a4); |
170 | 10 } |
11 | |
575 | 12 void |
170 | 13 arg0(int a1,int a2,int a3,int a4) |
14 { | |
15 arg1(0,1,2,3); | |
800 | 16 printf("#0015:%d %d %d %d\n",a1,a2,a3,a4); |
17 } | |
18 | |
19 | |
20 static int gcd(int i0,int j0) | |
21 { | |
22 register int k,i=i0,j=j0; | |
23 if (i<j) { k=i; i=j; j=k;} | |
24 for(;;) { | |
25 if ((k=i%j)==0) return j; | |
26 i = j; j = k; | |
27 } | |
28 } | |
29 | |
30 static int test_register() | |
31 { | |
32 register int a=122,b=22,c=34,d=44,e=5,f; | |
868
c55337499f96
remove warnings and error from test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
800
diff
changeset
|
33 printf("#0032: %d %d %d %d %d\n",a,b,c,d,e); |
800 | 34 |
35 f = gcd(a,b); | |
36 e = gcd(c,d); | |
37 f = gcd(a,f); | |
38 e = gcd(a,e); | |
868
c55337499f96
remove warnings and error from test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
800
diff
changeset
|
39 printf("#0038: %d %d %d %d %d\n",a,b,c,d,e); |
c55337499f96
remove warnings and error from test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
800
diff
changeset
|
40 return 0; |
170 | 41 } |
800 | 42 |
43 static char *float_one_lib[] = { | |
44 " .literal8", | |
45 " .align 3", | |
46 "__float_one:", | |
47 " .long 0", | |
48 " .long 1072693248", | |
49 0 | |
50 }; | |
51 | |
52 static int float_one_lib_used = 1; | |
53 | |
54 static void | |
55 emit_lib(char *p[]) | |
56 { | |
57 while(*p) { | |
58 printf("#0057:%s\n",*p++); | |
59 } | |
60 } | |
61 | |
62 void | |
63 code_closing() | |
64 { | |
65 if (float_one_lib_used) emit_lib(float_one_lib); | |
66 } | |
67 | |
68 void | |
69 return_value() | |
70 { | |
71 printf("#0070:%ld\n",strlen("test")); | |
72 int ia =3, ib = 4; | |
73 printf("#0072:%d\n", ia*ib >ib? ia*3 : ia/4); | |
74 float fa =3, fb = 4; | |
75 printf("#0074:%f\n", fa*fb >fb? fa*3 : fa/4); | |
76 double ga =3, gb = 4; | |
77 printf("#0076:%g\n", ga*gb >gb? ga*3 : ga/4); | |
78 long long la =3, lb = 4; | |
79 printf("#0078:%lld\n", la*lb >lb? la*3 : la/4); | |
80 } | |
81 | |
82 | |
575 | 83 int |
170 | 84 main() |
85 { | |
86 arg0(0,1,2,3); | |
800 | 87 test_register(); |
88 code_closing(); | |
89 return_value(); | |
172 | 90 return 0; |
170 | 91 } |
800 | 92 |
93 |