1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
| ; Jassmin assembly code
; MiniC v. 1.0
.class public fibonacci
.super java/lang/Object
.method static <clinit>()V
.limit stack 1
.limit locals 0
return
.end method
.method public <init>()V
.limit stack 1
.limit locals 1
.var 0 is this Lfibonacci; from Label0 to Label1
Label0:
aload_0
invokespecial java/lang/Object/<init>()V
Label1:
return
.end method
.method public fibonacci(I)I
Label0:
; IfStmt, line 14
iload_1
iconst_0
if_icmpeq Label2
iconst_0
goto Label3
Label2:
iconst_1
Label3:
ifeq Label4
; AssignStmt, line 10
iconst_0
istore_2
goto Label5
Label4:
; IfStmt, line 14
iload_1
iconst_1
if_icmpeq Label6
iconst_0
goto Label7
Label6:
iconst_1
Label7:
ifeq Label8
; AssignStmt, line 12
iconst_1
istore_2
goto Label9
Label8:
; AssignStmt, line 14
; CallExpr
; "this"-pointer is the first ActualParam with instance methods:
aload_0
; ActualParam
iload_1
iconst_1
isub
invokevirtual fibonacci/fibonacci(I)I
; CallExpr
; "this"-pointer is the first ActualParam with instance methods:
aload_0
; ActualParam
iload_1
iconst_2
isub
invokevirtual fibonacci/fibonacci(I)I
iadd
istore_2
Label9:
Label5:
; ReturnStmt, line 15
iload_2
ireturn
Label1:
.limit locals 3
.limit stack 150
.end method
.method public static main([Ljava/lang/String;)V
Label0:
new fibonacci
dup
invokespecial fibonacci/<init>()V
astore_1
; ForStmt, line 20
; AssignExpr
iconst_0
istore_2
Label2:
iload_2
bipush 20
if_icmple Label4
iconst_0
goto Label5
Label4:
iconst_1
Label5:
ifeq Label3
; CallStmt, line 21
; CallExpr
; ActualParam
ldc "Fibonacci number "
invokestatic lang/System/putString(Ljava/lang/String;)V
; CallStmt, line 22
; CallExpr
; ActualParam
iload_2
invokestatic lang/System/putInt(I)V
; CallStmt, line 23
; CallExpr
; ActualParam
ldc ": "
invokestatic lang/System/putString(Ljava/lang/String;)V
; CallStmt, line 24
; CallExpr
; ActualParam
; CallExpr
; "this"-pointer is the first ActualParam with instance methods:
aload_1
; ActualParam
iload_2
invokevirtual fibonacci/fibonacci(I)I
invokestatic lang/System/putInt(I)V
; CallStmt, line 25
; CallExpr
invokestatic lang/System/putLn()V
; AssignExpr
iload_2
iconst_1
iadd
istore_2
goto Label2
Label3:
Label1:
return
.limit locals 3
.limit stack 150
.end method
|