-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.j
More file actions
341 lines (259 loc) · 6.13 KB
/
Copy pathsample.j
File metadata and controls
341 lines (259 loc) · 6.13 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
.class public sample
.super java/lang/Object
; inta,b,c
.field private static a I
.field private static b I
.field private static c I
; decd,e
.field private static d F
.field private static e F
; boolf,g
.field private static f Z
.field private static g Z
; intans
.field private static ans I
; intnum1
.field private static num1 I
; intnum2
.field private static num2 I
.field private static _runTimer LRunTimer;
.field private static _standardIn LPascalTextIn;
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.limit locals 1
.limit stack 1
.end method
.method public static main([Ljava/lang/String;)V
new RunTimer
dup
invokenonvirtual RunTimer/<init>()V
putstatic sample/_runTimer LRunTimer;
new PascalTextIn
dup
invokenonvirtual PascalTextIn/<init>()V
putstatic sample/_standardIn LPascalTextIn;
goto End_sum
L_sum:
astore_1
; ans=0
ldc 0
putstatic sample/ans I
; for(2x){ans=num1+num2;}
.var 0 is i I from Label_0 to Label_1
bipush 2
istore_0
Label_0:
iload_0
bipush 0
if_icmple Label_1
; ans=num1+num2
getstatic sample/num1 I
getstatic sample/num2 I
iadd
putstatic sample/ans I
iinc 0 -1
goto Label_0
Label_1:
getstatic sample/ans I
ret 1
End_sum:
; print("\nStart Sample.\n\n")
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "\nStart Sample.\n\n"
ldc 0
anewarray java/lang/Object
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
; a=1
ldc 1
putstatic sample/a I
; d=2.3
ldc 2.3
putstatic sample/d F
; e=2.0
ldc 2.0
putstatic sample/e F
; e=d*e
getstatic sample/d F
getstatic sample/e F
fmul
putstatic sample/e F
; f=false
ldc "false"
invokestatic java/lang/Boolean.parseBoolean(Ljava/lang/String;)Z
putstatic sample/f Z
; g=true
ldc "true"
invokestatic java/lang/Boolean.parseBoolean(Ljava/lang/String;)Z
putstatic sample/g Z
; a=1+2
ldc 1
ldc 2
iadd
putstatic sample/a I
; b=a+1
getstatic sample/a I
ldc 1
iadd
putstatic sample/b I
; c=b+a
getstatic sample/b I
getstatic sample/a I
iadd
putstatic sample/c I
; ifa==b,{print("a == b\n");}else{print("a =/= b\n");b=1+b*3;}
getstatic sample/a I
getstatic sample/b I
if_icmpeq Label_2
goto Label_3
Label_2:
; print("a == b\n")
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "a == b\n"
ldc 0
anewarray java/lang/Object
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
goto Label_4
Label_3:
; print("a =/= b\n")
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "a =/= b\n"
ldc 0
anewarray java/lang/Object
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
; b=1+b*3
ldc 1
getstatic sample/b I
ldc 3
imul
iadd
putstatic sample/b I
Label_4:
; print("\nhello")
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "\nhello"
ldc 0
anewarray java/lang/Object
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
; print("\na = %d , b = %d, c = %d\n",a,b,c)
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "\na = %d , b = %d, c = %d\n"
ldc 3
anewarray java/lang/Object
dup
ldc 0
getstatic sample/a I
invokestatic java/lang/Integer.valueOf(I)Ljava/lang/Integer;
aastore
dup
ldc 1
getstatic sample/b I
invokestatic java/lang/Integer.valueOf(I)Ljava/lang/Integer;
aastore
dup
ldc 2
getstatic sample/c I
invokestatic java/lang/Integer.valueOf(I)Ljava/lang/Integer;
aastore
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
; print("d = %f, e = %f\n",d,e)
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "d = %f, e = %f\n"
ldc 2
anewarray java/lang/Object
dup
ldc 0
getstatic sample/d F
invokestatic java/lang/Float.valueOf(F)Ljava/lang/Float;
aastore
dup
ldc 1
getstatic sample/e F
invokestatic java/lang/Float.valueOf(F)Ljava/lang/Float;
aastore
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
; print("f = %b, g = %b\n",f,g)
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "f = %b, g = %b\n"
ldc 2
anewarray java/lang/Object
dup
ldc 0
getstatic sample/f Z
invokestatic java/lang/Boolean.valueOf(Z)Ljava/lang/Boolean;
aastore
dup
ldc 1
getstatic sample/g Z
invokestatic java/lang/Boolean.valueOf(Z)Ljava/lang/Boolean;
aastore
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
; if"milk tea"is not"coffee",{print("\nmilk tea is not coffee\n\n");}
ldc 10
ldc 8
if_icmpne Label_5
goto Label_6
Label_5:
; print("\nmilk tea is not coffee\n\n")
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "\nmilk tea is not coffee\n\n"
ldc 0
anewarray java/lang/Object
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
Label_6:
; for(3x){print("peanut butter oreos\n");}
.var 0 is i I from Label_7 to Label_8
bipush 3
istore_0
Label_7:
iload_0
bipush 0
if_icmple Label_8
; print("peanut butter oreos\n")
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "peanut butter oreos\n"
ldc 0
anewarray java/lang/Object
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
iinc 0 -1
goto Label_7
Label_8:
; print("\nsum(a,b) = %d\n",sum(3,4))
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "\nsum(a,b) = %d\n"
ldc 1
anewarray java/lang/Object
dup
ldc 0
ldc 3
putstatic sample/num1 I
ldc 4
putstatic sample/num2 I
jsr L_sum
invokestatic java/lang/Integer.valueOf(I)Ljava/lang/Integer;
aastore
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
; print("\nEnd Sample.")
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "\nEnd Sample."
ldc 0
anewarray java/lang/Object
invokevirtual java/io/PrintStream.printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
getstatic sample/_runTimer LRunTimer;
invokevirtual RunTimer.printElapsedTime()V
return
.limit locals 16
.limit stack 16
.end method