2

I'm trying to implement branching in my jasmin byte code program but whatever I try I always get a syntax error on the branching. The code should check if the 2 numbers are equal and if true print "true" else jump to the end label and quit program.

I have used the official jasmin instructions page as example.

Error:

test.j:13: Warning - Syntax error.
if_icmpeg L1
             ^
test.j:15: JAS Error: Missing arguments for instruction goto.
L
 ^
test.j: Found 2 errors

Jasmin byte code file:

.class public test
.super java/lang/Object

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

getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 5
ldc 3
isub
ldc 7
if_icmpeg L1
goto LE1
L1:
ldc "true"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
LE1:
return
.end method

1 Answers1

3

You have a typo. It should be if_icmpeq, not if_icmpeg.

On a side note, have you considered trying the Krakatau assembler? I believe it would give a more useful error message in this situation.

Antimony
  • 37,781
  • 10
  • 100
  • 107
  • Thanks that was it, stupid that I didn't see that. I'm using this for a school project and unfortiontly we have to use the default(?) assembler –  May 04 '20 at 20:34
  • 2
    @Sten there is no default assembler in Java. Any assembler is a 3rd party product. The choice for Jasmin is arbitrary and, given that this tool has not been updated for a decade, questionable. – Holger May 05 '20 at 07:24