CC S01E06

Dec. 11, 2013, 8 p.m.

Jasmin

http://jasmin.sourceforge.net

Примеры

Conditionals

.class public calc4
.super java/lang/Object

.method public <init>()V
    aload_0
    invokenonvirtual java/lang/Object/<init>()V
    return
.end method

.method public static main([Ljava/lang/String;)V
    .limit stack 5
    .limit locals 7

    ; create input reader
    new java/io/InputStreamReader
    dup
    getstatic   java/lang/System/in Ljava/io/InputStream;
    invokenonvirtual    java/io/InputStreamReader.<init>(Ljava/io/InputStream;)V
    astore_1
    new java/io/BufferedReader
    dup
    aload_1
    invokenonvirtual    java/io/BufferedReader.<init>(Ljava/io/Reader;)V
    astore_2

    ; push System.out onto the stack
    getstatic java/lang/System/out Ljava/io/PrintStream;

    ; input
    aload_2
    invokevirtual   java/io/BufferedReader.readLine()Ljava/lang/String;
    invokestatic    java/lang/Double.parseDouble(Ljava/lang/String;)D
    dstore 3

    ; input
    aload_2
    invokevirtual   java/io/BufferedReader.readLine()Ljava/lang/String;
    invokestatic    java/lang/Double.parseDouble(Ljava/lang/String;)D
    dstore 5

    dload 5
    dload 3

    dcmpl
    ifne label1
    ; then

    dload 5
    dload 3
    dmul

    goto label2
    ; else
label1:

    dload 5
    dload 3
    ddiv

label2:

    invokevirtual java/io/PrintStream/println(D)V

    return
.end method
comments powered by Disqus