author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Fri, 29 Nov 2013 09:01:08 +0000 | |
changeset 211 | deece8c6cf3a |
parent 208 | bd5a8a6b3871 |
child 323 | 4ce07c4abdb4 |
permissions | -rw-r--r-- |
93
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
|
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
.class public fib.fib |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
.super java/lang/Object |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
.method public <init>()V |
211
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
6 |
aload_0 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
7 |
invokenonvirtual java/lang/Object/<init>()V |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
8 |
return |
93
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
.end method |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
|
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
.method public static write(I)V |
211
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
12 |
.limit locals 5 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
13 |
.limit stack 5 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
14 |
iload 0 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
15 |
getstatic java/lang/System/out Ljava/io/PrintStream; |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
16 |
swap |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
17 |
invokevirtual java/io/PrintStream/println(I)V |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
18 |
return |
93
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
.end method |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
|
207
f824e1331fc6
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
21 |
.method public static writes(Ljava/lang/String;)V |
211
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
22 |
.limit stack 2 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
23 |
.limit locals 2 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
24 |
getstatic java/lang/System/out Ljava/io/PrintStream; |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
25 |
aload 0 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
26 |
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
27 |
return |
207
f824e1331fc6
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
28 |
.end method |
f824e1331fc6
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
29 |
|
211
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
30 |
.method public static read()I |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
31 |
.limit locals 10 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
32 |
.limit stack 10 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
33 |
|
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
34 |
ldc 0 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
35 |
istore 1 ; this will hold our final integer |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
36 |
Label1: |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
37 |
getstatic java/lang/System/in Ljava/io/InputStream; |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
38 |
invokevirtual java/io/InputStream/read()I |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
39 |
istore 2 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
40 |
iload 2 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
41 |
ldc 10 ; the newline delimiter |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
42 |
isub |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
43 |
ifeq Label2 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
44 |
iload 2 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
45 |
ldc 32 ; the space delimiter |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
46 |
isub |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
47 |
ifeq Label2 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
48 |
|
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
49 |
iload 2 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
50 |
ldc 48 ; we have our digit in ASCII, have to subtract it from 48 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
51 |
isub |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
52 |
ldc 10 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
53 |
iload 1 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
54 |
imul |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
55 |
iadd |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
56 |
istore 1 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
57 |
goto Label1 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
58 |
Label2: |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
59 |
;when we come here we have our integer computed in Local Variable 1 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
60 |
iload 1 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
61 |
ireturn |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
62 |
.end method |
207
f824e1331fc6
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
63 |
|
93
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
64 |
.method public static main([Ljava/lang/String;)V |
211
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
65 |
.limit locals 200 |
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
66 |
.limit stack 200 |
93
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
|
208
bd5a8a6b3871
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
207
diff
changeset
|
68 |
ldc "Fib" |
bd5a8a6b3871
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
207
diff
changeset
|
69 |
invokestatic fib/fib/writes(Ljava/lang/String;)V |
211
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
70 |
invokestatic fib/fib/read()I |
93
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
71 |
istore 0 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
ldc 0 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
73 |
istore 1 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
74 |
ldc 1 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
75 |
istore 2 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
76 |
|
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
77 |
Loop_begin_0: |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
78 |
|
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
79 |
ldc 0 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
80 |
iload 0 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
81 |
if_icmpge Loop_end_1 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
82 |
iload 2 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
83 |
istore 3 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
84 |
iload 1 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
iload 2 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
86 |
iadd |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
87 |
istore 2 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
88 |
iload 3 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
istore 1 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
90 |
iload 0 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
91 |
ldc 1 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
92 |
isub |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
istore 0 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
94 |
goto Loop_begin_0 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
|
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
96 |
Loop_end_1: |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
97 |
|
207
f824e1331fc6
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
98 |
ldc "Result" |
f824e1331fc6
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
99 |
invokestatic fib/fib/writes(Ljava/lang/String;)V |
93
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
100 |
iload 2 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
101 |
invokestatic fib/fib/write(I)V |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
102 |
|
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
103 |
|
211
deece8c6cf3a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
104 |
return |
93
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
105 |
|
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
106 |
.end method |