Java バイトコードを書き、Jasmin を使用してアセンブルしようとしています。
サブルーチンについて理解しようとしていますが、プログラムの実行時に次のエラー メッセージが表示される理由がわかりません。
>java -jar jasmin.jar test.j
Generated: test.class
>java test
Exception in thread "main" java.lang.VerifyError: (class: test,
method: main signature: ([Ljava/lang/String;)V)
Cannot load return address from register 0
Could not find the main class: test. Program will exit.
test.j のバイトコードは次のとおりです。
.class public test
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 6
.limit locals 5
jsr a ;Jump to subroutine 'a', pushing return address on operand stack
return ;Exit the program
a:
astore_0 ;Store the return address in variable 0
aload_0 ;Save the address onto the stack as address will be overwritten in 'b'
jsr b ;Jump to subroutine 'b', pushing return address on operand stack
astore_0 ;Store the address that was on the stack back into variable 0
ret 0 ;Return to just after "jsr a"
b:
astore_0 ;Store return address in variable 0
ret 0 ;Return to address stored in 0 (ie back to just after the jump in 'a')
.end method
単一のサブルーチンへのジャンプには問題はありませんでしたが、サブルーチン内からサブルーチンにジャンプするときに何か問題が発生しているようです。
なぜこれが失敗するのかについての洞察は大歓迎です!