简体   繁体   English

为什么 Jasmin 不喜欢这个汇编代码?

[英]Why doesn't Jasmin like this assembly code?

I am reading the programming for the Java Virtual Machine by Joshua Engel, and I tried typing in one of the examples in the book.我正在阅读 Joshua Engel 编写的 Java 虚拟机的编程,并尝试输入书中的一个示例。 I understand that the book uses Oolong, and I am using Jasmin, however for such a simple example, and because the syntax of Oolong and Jasmin are so similar, I don't see why this doesn't work.我知道这本书使用了乌龙,而我使用的是 Jasmin,但是对于这样一个简单的示例,并且由于 Oolong 和 Jasmin 的语法非常相似,我不明白为什么这不起作用。 As a side note, I haven't been able to find anything about the difference in syntax between Oolong and Jasmin.作为旁注,我无法找到有关 Oolong 和 Jasmin 之间语法差异的任何信息。 Could anyone point me towards a resource like this?谁能指出我这样的资源?

Here's the code, exactly as it is in the book:这是代码,与书中的完全一样:

.class Test
.method static run()I
    bipush 9
    bipush 6
    imul

    ireturn
.end method

And when I run Jasmin on this, I get the following errors:当我对此运行 Jasmin 时,出现以下错误:

Test.j:2: Warning - Syntax error.
.method
        ^
Test.j:2: Error - Couldn't repair and continue parse.
.method 
        ^

So what is it that I'm doing wrong?那么我做错了什么?

Jasmin requires .super keyword after .class . Jasmin 在.class之后需要.super关键字。

The following code should compile fine:以下代码应该可以正常编译:

.class Test
.super java/lang/Object
.method static run()I
    bipush 9
    bipush 6
    imul

    ireturn
.end method

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM