progs/fib.j
changeset 624 8d0af38389bc
parent 617 f7de0915fff2
child 675 d665e7dd66d7
--- a/progs/fib.j	Sun Jul 28 01:00:41 2019 +0100
+++ b/progs/fib.j	Sun Jul 28 14:24:46 2019 +0100
@@ -17,28 +17,18 @@
     return 
 .end method
 
-.method public static writes(Ljava/lang/String;)V
-    .limit stack 2
-    .limit locals 1
-    getstatic java/lang/System/out Ljava/io/PrintStream;
-    aload 0
-    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
-    return
-.end method
-
 .method public static read()I 
     .limit locals 10 
     .limit stack 10
 
     ldc 0 
     istore 1  ; this will hold our final integer 
-
 Label1: 
     getstatic java/lang/System/in Ljava/io/InputStream; 
     invokevirtual java/io/InputStream/read()I 
     istore 2 
     iload 2 
-    ldc 10  ; the newline delimiter 
+    ldc 10   ; the newline delimiter 
     isub 
     ifeq Label2 
     iload 2 
@@ -54,11 +44,10 @@
     imul 
     iadd 
     istore 1 
-    goto Label2
     goto Label1 
-
 Label2: 
-    iload 1 ; when we come here we have our integer computed in local variable 1 
+    ;when we come here we have our integer computed in local variable 1 
+    iload 1 
     ireturn 
 .end method
 
@@ -66,40 +55,38 @@
    .limit locals 200
    .limit stack 200
 
-ldc 10
-istore 0
-ldc 0
-istore 1
-ldc 1
-istore 2
-ldc 0
-istore 3
-
-Loop_begin_0:
+; COMPILED CODE STARTS
 
-ldc 0
-iload 0
-if_icmpge Loop_end_1
-iload 2
-istore 3
-iload 1
-iload 2
-iadd
-istore 2
-iload 3
-istore 1
-iload 0
-ldc 1
-isub
-istore 0
-goto Loop_begin_0
+   ldc 10
+   istore 0
+   ldc 0
+   istore 1
+   ldc 1
+   istore 2
+   ldc 0
+   istore 3
+Loop_begin_0:
+   ldc 0
+   iload 0
+   if_icmpge Loop_end_1
+   iload 2
+   istore 3
+   iload 1
+   iload 2
+   iadd
+   istore 2
+   iload 3
+   istore 1
+   iload 0
+   ldc 1
+   isub
+   istore 0
+   goto Loop_begin_0
+Loop_end_1:
+   iload 1
+   invokestatic fib/fib/write(I)V
 
-Loop_end_1:
-
-iload 1
-invokestatic fib/fib/write(I)V
-
-
+; COMPILED CODE ENDS
    return
 
 .end method