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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
467
32737bad7489 fix list/tag interference
kono
parents: 427
diff changeset
1 int printf(const char *format, ...);
32737bad7489 fix list/tag interference
kono
parents: 427
diff changeset
2
800
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
3 extern unsigned long strlen(const char *s);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
4
170
6e0f67b7d200 test files
kono
parents:
diff changeset
5
575
a4445cb1aa91 Example filex.
kono
parents: 491
diff changeset
6 void
170
6e0f67b7d200 test files
kono
parents:
diff changeset
7 arg1(int a1,int a2,int a3,int a4)
6e0f67b7d200 test files
kono
parents:
diff changeset
8 {
800
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
9 printf("#0008:%d %d %d %d\n",a1,a2,a3,a4);
170
6e0f67b7d200 test files
kono
parents:
diff changeset
10 }
6e0f67b7d200 test files
kono
parents:
diff changeset
11
575
a4445cb1aa91 Example filex.
kono
parents: 491
diff changeset
12 void
170
6e0f67b7d200 test files
kono
parents:
diff changeset
13 arg0(int a1,int a2,int a3,int a4)
6e0f67b7d200 test files
kono
parents:
diff changeset
14 {
6e0f67b7d200 test files
kono
parents:
diff changeset
15 arg1(0,1,2,3);
800
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
16 printf("#0015:%d %d %d %d\n",a1,a2,a3,a4);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
17 }
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
18
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
19
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
20 static int gcd(int i0,int j0)
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
21 {
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
22 register int k,i=i0,j=j0;
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
23 if (i<j) { k=i; i=j; j=k;}
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
24 for(;;) {
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
25 if ((k=i%j)==0) return j;
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
26 i = j; j = k;
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
27 }
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
28 }
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
29
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
30 static int test_register()
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
31 {
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
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
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
34
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
35 f = gcd(a,b);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
36 e = gcd(c,d);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
37 f = gcd(a,f);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
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
6e0f67b7d200 test files
kono
parents:
diff changeset
41 }
800
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
42
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
43 static char *float_one_lib[] = {
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
44 " .literal8",
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
45 " .align 3",
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
46 "__float_one:",
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
47 " .long 0",
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
48 " .long 1072693248",
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
49 0
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
50 };
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
51
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
52 static int float_one_lib_used = 1;
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
53
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
54 static void
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
55 emit_lib(char *p[])
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
56 {
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
57 while(*p) {
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
58 printf("#0057:%s\n",*p++);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
59 }
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
60 }
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
61
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
62 void
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
63 code_closing()
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
64 {
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
65 if (float_one_lib_used) emit_lib(float_one_lib);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
66 }
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
67
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
68 void
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
69 return_value()
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
70 {
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
71 printf("#0070:%ld\n",strlen("test"));
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
72 int ia =3, ib = 4;
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
73 printf("#0072:%d\n", ia*ib >ib? ia*3 : ia/4);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
74 float fa =3, fb = 4;
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
75 printf("#0074:%f\n", fa*fb >fb? fa*3 : fa/4);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
76 double ga =3, gb = 4;
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
77 printf("#0076:%g\n", ga*gb >gb? ga*3 : ga/4);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
78 long long la =3, lb = 4;
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
79 printf("#0078:%lld\n", la*lb >lb? la*3 : la/4);
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
80 }
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
81
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
82
575
a4445cb1aa91 Example filex.
kono
parents: 491
diff changeset
83 int
170
6e0f67b7d200 test files
kono
parents:
diff changeset
84 main()
6e0f67b7d200 test files
kono
parents:
diff changeset
85 {
6e0f67b7d200 test files
kono
parents:
diff changeset
86 arg0(0,1,2,3);
800
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
87 test_register();
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
88 code_closing();
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
89 return_value();
172
096559f07a70 some check
kono
parents: 170
diff changeset
90 return 0;
170
6e0f67b7d200 test files
kono
parents:
diff changeset
91 }
800
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
92
c3957d127e17 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
93