progs/fib.j
changeset 373 b018234c9126
parent 323 4ce07c4abdb4
child 471 9476086849ad
equal deleted inserted replaced
372:d6af4b1239de 373:b018234c9126
     7    invokenonvirtual java/lang/Object/<init>()V
     7    invokenonvirtual java/lang/Object/<init>()V
     8    return
     8    return
     9 .end method
     9 .end method
    10 
    10 
    11 .method public static write(I)V 
    11 .method public static write(I)V 
    12     .limit locals 5 
    12     .limit locals 1 
    13     .limit stack 5 
    13     .limit stack 2 
    14     iload 0 
       
    15     getstatic java/lang/System/out Ljava/io/PrintStream; 
    14     getstatic java/lang/System/out Ljava/io/PrintStream; 
    16     swap 
    15     iload 0
    17     invokevirtual java/io/PrintStream/println(I)V 
    16     invokevirtual java/io/PrintStream/println(I)V 
    18     return 
    17     return 
    19 .end method
    18 .end method
    20 
    19 
    21 .method public static read()I 
    20 .method public static read()I 
    22       .limit locals 10 
    21     .limit locals 10 
    23       .limit stack 10
    22     .limit stack 10
    24 
    23 
    25       ldc 0 
    24     ldc 0 
    26       istore 1  ; this will hold our final integer 
    25     istore 1  ; this will hold our final integer 
    27 Label1: 
    26 Label1: 
    28       getstatic java/lang/System/in Ljava/io/InputStream; 
    27     getstatic java/lang/System/in Ljava/io/InputStream; 
    29       invokevirtual java/io/InputStream/read()I 
    28     invokevirtual java/io/InputStream/read()I 
    30       istore 2 
    29     istore 2 
    31       iload 2 
    30     iload 2 
    32       ldc 10   ; the newline delimiter 
    31     ldc 10   ; the newline delimiter 
    33       isub 
    32     isub 
    34       ifeq Label2 
    33     ifeq Label2 
    35       iload 2 
    34     iload 2 
    36       ldc 32   ; the space delimiter 
    35     ldc 32   ; the space delimiter 
    37       isub 
    36     isub 
    38       ifeq Label2
    37     ifeq Label2
    39 
    38 
    40       iload 2 
    39     iload 2 
    41       ldc 48   ; we have our digit in ASCII, have to subtract it from 48 
    40     ldc 48   ; we have our digit in ASCII, have to subtract it from 48 
    42       isub 
    41     isub 
    43       ldc 10 
    42     ldc 10 
    44       iload 1 
    43     iload 1 
    45       imul 
    44     imul 
    46       iadd 
    45     iadd 
    47       istore 1 
    46     istore 1 
    48       goto Label1 
    47     goto Label1 
    49 Label2: 
    48 Label2: 
    50       ;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 
    51       iload 1 
    50     iload 1 
    52       ireturn 
    51     ireturn 
    53 .end method
    52 .end method
    54 
       
    55 
    53 
    56 .method public static main([Ljava/lang/String;)V
    54 .method public static main([Ljava/lang/String;)V
    57    .limit locals 200
    55    .limit locals 200
    58    .limit stack 200
    56    .limit stack 200
    59 
    57 
    85 istore 0
    83 istore 0
    86 goto Loop_begin_0
    84 goto Loop_begin_0
    87 
    85 
    88 Loop_end_1:
    86 Loop_end_1:
    89 
    87 
    90 iload 2
    88 iload 1
    91 invokestatic fib/fib/write(I)V
    89 invokestatic fib/fib/write(I)V
    92 
    90 
    93 
    91 
    94    return
    92    return
    95 
    93