-8

I have to do a program to school in Assembler but we did just a few basic things. Is it possible to write code in Java and convert it to Assembler?

closed as off-topic by gnat, Jörg W Mittag, candied_orange, maple_shaft May 16 '17 at 18:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking for assistance in explaining, writing or debugging code are off-topic here. These can be asked on Stack Overflow if they include the desired behavior, a specific problem or error, and the shortest code necessary to reproduce it in the question (see Minimal, Complete, and Verifiable Example)." – gnat, Jörg W Mittag, candied_orange, maple_shaft
If this question can be reworded to fit the rules in the help center, please edit the question.

3

Yes you can. While normally Java is compiled to bytecode executed by JVM, there are compilers that output native code. For example, gcc has Java front-end, the gcj, so you can use that along with -s option (which emits assembly output instead of machine code).

Having said that, don't expect to fool anyone. Your teacher will instantly recognise that your code has not been written by you.

  • Thank you very much! I know it probably wouldn't look exactly the same but my teacher really don't care. He didn't teach us anything except add and sub and he doesn't even know a lot of stuff when you ask him. He just want to see that our program works. – jankova0013 May 16 '17 at 12:19
  • 6
    I mean, unless your teacher totally don't care, it will be instantly recognizable as machine-generated code. – el.pescado May 16 '17 at 12:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.