1 |
1 |
2 .class public fib.fib |
2 .class public fib.fib |
3 .super java/lang/Object |
3 .super java/lang/Object |
4 |
4 |
5 .method public <init>()V |
5 .method public <init>()V |
6 aload_0 |
6 aload_0 |
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 print(Ljava/lang/String;)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 aload 0 |
14 getstatic java/lang/System/out Ljava/io/PrintStream; |
15 getstatic java/lang/System/out Ljava/io/PrintStream; |
15 iload 0 |
16 swap |
16 invokevirtual java/io/PrintStream/println(I)V |
17 invokevirtual java/io/PrintStream/print(Ljava/lang/String;)V |
17 return |
18 return |
|
19 .end method |
18 .end method |
20 |
19 |
21 .method public static write(I)V |
20 .method public static read()I |
22 .limit locals 1 |
21 .limit locals 10 |
23 .limit stack 2 |
|
24 getstatic java/lang/System/out Ljava/io/PrintStream; |
|
25 iload 0 |
|
26 invokevirtual java/io/PrintStream/println(I)V |
|
27 return |
|
28 .end method |
|
29 |
|
30 .method public static read()I |
|
31 .limit locals 10 |
|
32 .limit stack 10 |
22 .limit stack 10 |
33 |
23 |
34 ldc 0 |
24 ldc 0 |
35 istore 1 ; this will hold our final integer |
25 istore 1 ; this will hold our final integer |
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 |
47 ifeq Label2 |
37 ifeq Label2 |
48 |
38 |
49 iload 2 |
39 iload 2 |
50 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 |
51 isub |
41 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 Label1 |
47 goto Label1 |
58 Label2: |
48 Label2: |
59 ;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 |
60 iload 1 |
50 iload 1 |
61 ireturn |
51 ireturn |
62 .end method |
52 .end method |
63 |
53 |
64 .method public static main([Ljava/lang/String;)V |
54 .method public static main([Ljava/lang/String;)V |
65 .limit locals 200 |
55 .limit locals 200 |
66 .limit stack 200 |
56 .limit stack 200 |
67 |
57 |
68 ldc "Fib" |
58 invokestatic fib/fib/read()I |
69 invokestatic fib/fib/print(Ljava/lang/String;)V |
59 istore 0 |
70 invokestatic fib/fib/read()I |
60 ldc 0 |
71 istore 0 |
61 istore 1 |
72 ldc 0 |
62 ldc 1 |
73 istore 1 |
63 istore 2 |
74 ldc 1 |
64 ldc 0 |
75 istore 2 |
65 istore 3 |
76 |
66 |
77 Loop_start_1: |
67 Loop_begin_2: |
78 |
68 |
79 iload 0 |
69 ldc 0 |
80 ldc 0 |
70 iload 0 |
81 if_icmple Loop_end_0 |
71 if_icmpge Loop_end_3 |
|
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_2 |
82 |
85 |
83 iload 2 |
86 Loop_end_3: |
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 |
87 |
96 goto Loop_start_1 |
88 iload 1 |
|
89 invokestatic fib/fib/write(I)V |
97 |
90 |
98 Loop_end_0: |
|
99 |
91 |
100 ldc "Result" |
92 return |
101 invokestatic fib/fib/print(Ljava/lang/String;)V |
|
102 iload 2 |
|
103 invokestatic fib/fib/write(I)V |
|
104 |
93 |
105 return |
|
106 .end method |
94 .end method |