0

In putty I am attempting to create a Jasmin program that, when assembled and ran as a Java program, will output the integer "431". When I attempt to assemble the program the console says there is a syntax error on line 11. I am having trouble figuring out what it is. Here is my code:

.class public Lab3_JasminExample
.super java/lang/Object

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

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

        getstatic  java/lang/System/out Ljava/io/PrintStream;

        sipush 431

        invokevirtual java/io/PrintStream/println(I)V
        return
.end method

Line 11 would be ".limit stack 10" and I can't see what is wrong with how I wrote that. What am I doing incorrectly?

Margaret Bloom
  • 41,768
  • 5
  • 78
  • 124
Darien Springer
  • 467
  • 8
  • 17

1 Answers1

4

Errors may be reported on a line but be triggered by previous (or following!) lines, so always look around the offending line.

My Jasmin (version 2.4) correctly reports the error on line 10

a.j:10: Warning - Syntax error.
.method public static main ([Ljava.lang.String;)V
                                                  ^

This is a silly mistake really: there is space between the method name (main) and its descriptor (([Ljava.lang.String;)V)

Line 10 should be .method public static main([Ljava.lang.String;)V

Margaret Bloom
  • 41,768
  • 5
  • 78
  • 124