progs/fib.j
author Christian Urban <urbanc@in.tum.de>
Sun, 28 Jul 2019 14:24:46 +0100
changeset 624 8d0af38389bc
parent 617 f7de0915fff2
child 675 d665e7dd66d7
permissions -rw-r--r--
updated to Scala 2.13
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 read()I 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    21
    .limit locals 10 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    22
    .limit stack 10
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    23
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    24
    ldc 0 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    25
    istore 1  ; this will hold our final integer 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    26
Label1: 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    27
    getstatic java/lang/System/in Ljava/io/InputStream; 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    28
    invokevirtual java/io/InputStream/read()I 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    29
    istore 2 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    30
    iload 2 
624
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    31
    ldc 10   ; the newline delimiter 
617
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    32
    isub 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    33
    ifeq Label2 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    34
    iload 2 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    35
    ldc 32   ; the space delimiter 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    36
    isub 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    37
    ifeq Label2
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    38
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    39
    iload 2 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    40
    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
    41
    isub 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    42
    ldc 10 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    43
    iload 1 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    44
    imul 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    45
    iadd 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    46
    istore 1 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    47
    goto Label1 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    48
Label2: 
624
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    49
    ;when we come here we have our integer computed in local variable 1 
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    50
    iload 1 
617
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    51
    ireturn 
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    52
.end method
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 612
diff changeset
    53
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
.method public static main([Ljava/lang/String;)V
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    55
   .limit locals 200
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    56
   .limit stack 200
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
624
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    58
; COMPILED CODE STARTS
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
624
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    60
   ldc 10
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    61
   istore 0
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    62
   ldc 0
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    63
   istore 1
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    64
   ldc 1
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    65
   istore 2
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    66
   ldc 0
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    67
   istore 3
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    68
Loop_begin_0:
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    69
   ldc 0
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    70
   iload 0
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    71
   if_icmpge Loop_end_1
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    72
   iload 2
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    73
   istore 3
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    74
   iload 1
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    75
   iload 2
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    76
   iadd
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    77
   istore 2
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    78
   iload 3
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    79
   istore 1
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    80
   iload 0
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    81
   ldc 1
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    82
   isub
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    83
   istore 0
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    84
   goto Loop_begin_0
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    85
Loop_end_1:
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    86
   iload 1
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    87
   invokestatic fib/fib/write(I)V
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
624
8d0af38389bc updated to Scala 2.13
Christian Urban <urbanc@in.tum.de>
parents: 617
diff changeset
    89
; COMPILED CODE ENDS
600
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    90
   return
d488a3e7b0ec updated
Christian Urban <urbanc@in.tum.de>
parents: 545
diff changeset
    91
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
.end method