0

I am trying to merge the Java assembly code (using Jasmin (an assembler interface in java)) with standard Java code.Like this

public class SomeClass{

  public void testPrinting(){

            System.out.println("Hello World");

  } 

  .method public myMethod()V

    //Some work

  .end method

}

Is this possible?

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
zaree
  • 641
  • 2
  • 6
  • 15
  • With C/C++ using assembly is used to improve performance. However with Java the byte code is for a virtual machine and the JVM is very sensitively tuned for the sort of structures the compiler produces. I would not be surprised if hand written byte code would be slower. ;) – Peter Lawrey May 03 '11 at 08:57
  • @Peter Lawrey what if i try to write some routine (that follow the Jasmin)that accept some list of parameters and also some methods name and then push it on stack and then run it(remember that method is belong to some .class file written with standered java)Is this be possibel ??? – zaree May 03 '11 at 10:49
  • You can do that in Java with one line. Can you give me an example of some thing you can't do in Java? – Peter Lawrey May 03 '11 at 11:00

2 Answers2

2

You could make a class using Jasmin and use it in any java project. Mixing java and "assembly" code in the same class doesn't seem to be easy to implement, but you could call some code from an "assembly-source" class in a standard java class.

class StandardJava {

    public void myMethod() { 
         Assembly.someMethod();
    }

}
ymajoros
  • 2,454
  • 3
  • 34
  • 60
0

You would need to write your own preprocessor. This would be difficult, especially if the Jasmin code references members defined in Java and the Java code references members defined with Jasmin code. I think you're best off writing some Java, disassembling it, and merging that with your Jasmin code.

Daniel Lubarov
  • 7,796
  • 1
  • 37
  • 56