When I try assembling my test.j
jasmin file with the commandline java -jar Jasmin.jar test.j
it generates the test.class
file without any errors. All the code is the same except for the operators and comparisons, all my +
will become -
, the ==
all become !=
and so on and so forth.
My test.j
jasmin file adds 2 numbers and checks if these are equal to 7, if true print something, else print something else. At the end it will always print one line of text.
test.j
file:
.class public test
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 5
.limit locals 3
ldc 5
ldc 3
isub
ldc 7
if_icmpne L1
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "It is not bigger"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
goto LE1
L1:
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "It is bigger"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
LE1:
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "this will always print"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
return
.end method
Assembled test.class
, the 5 - 3 != 7
should be 5 + 3 == 7
here:
public class test {
public static void main(String[] var0) {
if (5 - 3 != 7) {
System.out.println("It is not bigger");
} else {
System.out.println("It is bigger");
}
System.out.println("this will always print");
}
}
The jasmin code you posted contains isub
, which is for subtraction, not addition. The assembler is correct. You are outputting assembly that does not match your intended behavior.