diff test/regargs.c @ 800:c3957d127e17

minor fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 24 Nov 2010 10:50:18 +0900
parents a4445cb1aa91
children c55337499f96
line wrap: on
line diff
--- a/test/regargs.c	Tue Nov 23 23:05:08 2010 +0900
+++ b/test/regargs.c	Wed Nov 24 10:50:18 2010 +0900
@@ -1,21 +1,93 @@
 int printf(const char *format, ...);
 
+extern  unsigned long strlen(const char *s);
+
 
 void
 arg1(int a1,int a2,int a3,int a4)
 {
-    printf("#0006:%d %d %d %d\n",a1,a2,a3,a4);
+    printf("#0008:%d %d %d %d\n",a1,a2,a3,a4);
 }
 
 void
 arg0(int a1,int a2,int a3,int a4)
 {
     arg1(0,1,2,3);
-    printf("#0013:%d %d %d %d\n",a1,a2,a3,a4);
+    printf("#0015:%d %d %d %d\n",a1,a2,a3,a4);
+}
+
+
+static int gcd(int i0,int j0)
+{
+    register int k,i=i0,j=j0;
+    if (i<j) { k=i; i=j; j=k;}
+    for(;;) {
+        if ((k=i%j)==0) return j;
+        i = j; j = k;
+    }
+}
+
+static int test_register()
+{
+    register int a=122,b=22,c=34,d=44,e=5,f;
+    printf("#0032: %d %d %d %d %d\n",a,b,c,d,e,f);
+
+    f = gcd(a,b);
+    e = gcd(c,d);
+    f = gcd(a,f);
+    e = gcd(a,e);
+    printf("#0038: %d %d %d %d %d\n",a,b,c,d,e,f);
+    
 }
+
+static char *float_one_lib[] = {
+  "        .literal8",
+"        .align 3",
+"__float_one:",
+"        .long   0",
+"        .long   1072693248",
+        0
+};
+
+static int float_one_lib_used = 1;
+
+static void
+emit_lib(char *p[])
+{
+  while(*p) {
+    printf("#0057:%s\n",*p++);
+  }
+}
+
+void
+code_closing()
+{
+  if (float_one_lib_used) emit_lib(float_one_lib);
+}
+
+void
+return_value()
+{
+    printf("#0070:%ld\n",strlen("test"));
+    int ia =3, ib = 4;
+    printf("#0072:%d\n", ia*ib >ib? ia*3 : ia/4);
+    float fa =3, fb = 4;
+    printf("#0074:%f\n", fa*fb >fb? fa*3 : fa/4);
+    double ga =3, gb = 4;
+    printf("#0076:%g\n", ga*gb >gb? ga*3 : ga/4);
+    long long la =3, lb = 4;
+    printf("#0078:%lld\n", la*lb >lb? la*3 : la/4);
+}
+
+
 int
 main()
 {
     arg0(0,1,2,3);
+    test_register();
+    code_closing();
+    return_value();
     return 0;
 }
+
+