progs/fib.j
changeset 624 8d0af38389bc
parent 617 f7de0915fff2
child 675 d665e7dd66d7
equal deleted inserted replaced
623:47a299e7010f 624:8d0af38389bc
    15     iload 0
    15     iload 0
    16     invokevirtual java/io/PrintStream/println(I)V 
    16     invokevirtual java/io/PrintStream/println(I)V 
    17     return 
    17     return 
    18 .end method
    18 .end method
    19 
    19 
    20 .method public static writes(Ljava/lang/String;)V
       
    21     .limit stack 2
       
    22     .limit locals 1
       
    23     getstatic java/lang/System/out Ljava/io/PrintStream;
       
    24     aload 0
       
    25     invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
       
    26     return
       
    27 .end method
       
    28 
       
    29 .method public static read()I 
    20 .method public static read()I 
    30     .limit locals 10 
    21     .limit locals 10 
    31     .limit stack 10
    22     .limit stack 10
    32 
    23 
    33     ldc 0 
    24     ldc 0 
    34     istore 1  ; this will hold our final integer 
    25     istore 1  ; this will hold our final integer 
    35 
       
    36 Label1: 
    26 Label1: 
    37     getstatic java/lang/System/in Ljava/io/InputStream; 
    27     getstatic java/lang/System/in Ljava/io/InputStream; 
    38     invokevirtual java/io/InputStream/read()I 
    28     invokevirtual java/io/InputStream/read()I 
    39     istore 2 
    29     istore 2 
    40     iload 2 
    30     iload 2 
    41     ldc 10  ; the newline delimiter 
    31     ldc 10   ; the newline delimiter 
    42     isub 
    32     isub 
    43     ifeq Label2 
    33     ifeq Label2 
    44     iload 2 
    34     iload 2 
    45     ldc 32   ; the space delimiter 
    35     ldc 32   ; the space delimiter 
    46     isub 
    36     isub 
    52     ldc 10 
    42     ldc 10 
    53     iload 1 
    43     iload 1 
    54     imul 
    44     imul 
    55     iadd 
    45     iadd 
    56     istore 1 
    46     istore 1 
    57     goto Label2
       
    58     goto Label1 
    47     goto Label1 
    59 
       
    60 Label2: 
    48 Label2: 
    61     iload 1 ; when we come here we have our integer computed in local variable 1 
    49     ;when we come here we have our integer computed in local variable 1 
       
    50     iload 1 
    62     ireturn 
    51     ireturn 
    63 .end method
    52 .end method
    64 
    53 
    65 .method public static main([Ljava/lang/String;)V
    54 .method public static main([Ljava/lang/String;)V
    66    .limit locals 200
    55    .limit locals 200
    67    .limit stack 200
    56    .limit stack 200
    68 
    57 
    69 ldc 10
    58 ; COMPILED CODE STARTS
    70 istore 0
       
    71 ldc 0
       
    72 istore 1
       
    73 ldc 1
       
    74 istore 2
       
    75 ldc 0
       
    76 istore 3
       
    77 
    59 
       
    60    ldc 10
       
    61    istore 0
       
    62    ldc 0
       
    63    istore 1
       
    64    ldc 1
       
    65    istore 2
       
    66    ldc 0
       
    67    istore 3
    78 Loop_begin_0:
    68 Loop_begin_0:
       
    69    ldc 0
       
    70    iload 0
       
    71    if_icmpge Loop_end_1
       
    72    iload 2
       
    73    istore 3
       
    74    iload 1
       
    75    iload 2
       
    76    iadd
       
    77    istore 2
       
    78    iload 3
       
    79    istore 1
       
    80    iload 0
       
    81    ldc 1
       
    82    isub
       
    83    istore 0
       
    84    goto Loop_begin_0
       
    85 Loop_end_1:
       
    86    iload 1
       
    87    invokestatic fib/fib/write(I)V
    79 
    88 
    80 ldc 0
    89 ; COMPILED CODE ENDS
    81 iload 0
       
    82 if_icmpge Loop_end_1
       
    83 iload 2
       
    84 istore 3
       
    85 iload 1
       
    86 iload 2
       
    87 iadd
       
    88 istore 2
       
    89 iload 3
       
    90 istore 1
       
    91 iload 0
       
    92 ldc 1
       
    93 isub
       
    94 istore 0
       
    95 goto Loop_begin_0
       
    96 
       
    97 Loop_end_1:
       
    98 
       
    99 iload 1
       
   100 invokestatic fib/fib/write(I)V
       
   101 
       
   102 
       
   103    return
    90    return
   104 
    91 
   105 .end method
    92 .end method