progs/fib.j
author Christian Urban <urbanc@in.tum.de>
Sat, 29 Dec 2018 10:30:27 +0000
changeset 617 f7de0915fff2
parent 612 7a12053567d4
child 624 8d0af38389bc
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
     6
   aload_0
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
     7
   invokenonvirtual java/lang/Object/<init>()V
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
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
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    11
.method public static write(I)V 
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    12
    .limit locals 1 
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    13
    .limit stack 2 
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    14
    getstatic java/lang/System/out Ljava/io/PrintStream; 
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    15
    iload 0
617
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    16
    invokevirtual java/io/PrintStream/println(I)V 
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    17
    return 
207
f824e1331fc6 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    18
.end method
f824e1331fc6 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    19
617
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    20
.method public static writes(Ljava/lang/String;)V
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    21
    .limit stack 2
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    22
    .limit locals 1
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    23
    getstatic java/lang/System/out Ljava/io/PrintStream;
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    24
    aload 0
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    25
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    26
    return
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    27
.end method
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    28
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    29
.method public static read()I 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    30
    .limit locals 10 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    31
    .limit stack 10
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    32
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    33
    ldc 0 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    34
    istore 1  ; this will hold our final integer 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    35
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    36
Label1: 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    37
    getstatic java/lang/System/in Ljava/io/InputStream; 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    38
    invokevirtual java/io/InputStream/read()I 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    39
    istore 2 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    40
    iload 2 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    41
    ldc 10  ; the newline delimiter 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    42
    isub 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    43
    ifeq Label2 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    44
    iload 2 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    45
    ldc 32   ; the space delimiter 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    46
    isub 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    47
    ifeq Label2
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    48
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    49
    iload 2 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    50
    ldc 48   ; we have our digit in ASCII, have to subtract it from 48 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    51
    isub 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    52
    ldc 10 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    53
    iload 1 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    54
    imul 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    55
    iadd 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    56
    istore 1 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    57
    goto Label2
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    58
    goto Label1 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    59
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    60
Label2: 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    61
    iload 1 ; when we come here we have our integer computed in local variable 1 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    62
    ireturn 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    63
.end method
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    64
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
.method public static main([Ljava/lang/String;)V
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    66
   .limit locals 200
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    67
   .limit stack 200
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
    69
ldc 10
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    70
istore 0
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    71
ldc 0
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    72
istore 1
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    73
ldc 1
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    74
istore 2
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    75
ldc 0
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    76
istore 3
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
    78
Loop_begin_0:
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    80
ldc 0
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    81
iload 0
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
    82
if_icmpge Loop_end_1
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    83
iload 2
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    84
istore 3
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    85
iload 1
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    86
iload 2
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    87
iadd
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    88
istore 2
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    89
iload 3
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    90
istore 1
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    91
iload 0
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    92
ldc 1
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    93
isub
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    94
istore 0
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
    95
goto Loop_begin_0
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
609
e33545bb2eba updated
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
    97
Loop_end_1:
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    99
iload 1
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
   100
invokestatic fib/fib/write(I)V
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
   103
   return
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
   104
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
.end method