Reputation: 13
Is it possible to write a Java program (I do not mind if it relies on external libraries) that can compile x86 .asm (Assembly language) files? If it is, how would I go about doing this (which libraries would I need to use and how would I go about doing it)?
I have researched about Java and Assembly assembling, but could not find any relevant results. Do I have to use an already made assembler, like nasm?
Upvotes: 1
Views: 2004
Reputation: 18521
Is it possible to write a Java program ... that can compile .asm ... files?
You can use (nearly) any programming language which is capable of reading text files and writing binary files.
So you can use Java for this - at least theoretically.
If it is, how would I go about doing this ... ?
I have researched about Java and Assembly assembling ...
Unfortunately assemblers and compilers are typically not written in Java.
With a high probability you'll have to develop all functions you need from the scratch!
Do I have to use an already made assembler, like nasm?
The question here is why you want to have the assembler in Java.
You can write an assembler in Java but this will be a lot of work.
If you want to include the assembler in a Java program that you will sell commercially it might be necessary to write your own assembler because licensing does not allow you to ship your product together with "nasm".
If you want to write an assembler just for practicing (because you want to get experience in compiler development) it would also make sense to spent 100 hours and more for this.
In all other cases I can imagine it does not make sense to spent one month in developing a software that can be downloaded freely from the internet.
Upvotes: 2