progs/loops.j
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 15 Aug 2020 14:18:37 +0100
changeset 743 6acabeecdf75
parent 710 183663740fb7
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 loops.loops
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 static write(I)V 
710
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
     6
    .limit locals 1 
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
     7
    .limit stack 2 
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
    getstatic java/lang/System/out Ljava/io/PrintStream; 
710
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
     9
    iload 0
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    10
    i2c       ; Int => Char
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    11
    invokevirtual java/io/PrintStream/print(C)V   ; println(I)V => print(C)V    
207
f824e1331fc6 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    12
    return 
f824e1331fc6 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    13
.end method
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
.method public static main([Ljava/lang/String;)V
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
   .limit locals 200
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
   .limit stack 200
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
710
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    19
; COMPILED CODE STARTS   
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
710
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    21
   ldc 200000
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    22
   istore 0 		; start
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    23
   iload 0
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    24
   istore 1 		; x1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    25
   iload 0
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    26
   istore 2 		; x2
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    27
   iload 0
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    28
   istore 3 		; x3
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    29
Loop_begin_90:
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    30
   ldc 0
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    31
   iload 1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    32
   if_icmpge Loop_end_91
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    33
Loop_begin_92:
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    34
   ldc 0
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    35
   iload 2
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    36
   if_icmpge Loop_end_93
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    37
Loop_begin_94:
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    38
   ldc 0
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    39
   iload 3
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    40
   if_icmpge Loop_end_95
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    41
   iload 3
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    42
   ldc 1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    43
   isub
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    44
   istore 3 		; x3
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    45
   ;; test start
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    46
   bipush 1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    47
   bipush 1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    48
   bipush 1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    49
   bipush 1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    50
   pop
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    51
   pop
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    52
   pop
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    53
   pop
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    54
   ;; test end
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    55
   goto Loop_begin_94
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    56
Loop_end_95:
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    57
   iload 0
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    58
   istore 3 		; x3
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    59
   iload 2
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    60
   ldc 1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    61
   isub
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    62
   istore 2 		; x2
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    63
   goto Loop_begin_92
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    64
Loop_end_93:
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    65
   iload 0
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    66
   istore 2 		; x2
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    67
   iload 1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    68
   ldc 1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    69
   isub
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    70
   istore 1 		; x1
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    71
   goto Loop_begin_90
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    72
Loop_end_91:
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
710
183663740fb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 207
diff changeset
    74
; COMPILED CODE ENDS
93
4794759139ea better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
   return
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
.end method