0

I'm trying to do the following: take a single IA32 instruction in the Intel syntax (such as ADD EAX, EBX) and produce the corresponding machine code for this instruction. Is there some small library, preferably open source, that can do this for me?

4
  • You could probably extract that part from, say, NASM, and turn it into a library -- but I don't know of one that's already built to do exactly that (and it's not clear how it would work in some cases, such as jmp instructions, which normally need a series of instructions so the assembler can compute the offset to the target). Apr 5, 2012 at 8:14
  • Jerry, for JMPs I'd like to be able to specify the target address and the resulting object code should imply include the address verbatim.
    – Frederick
    Apr 5, 2012 at 9:15
  • Do you want to write a small assembler, or do you need to have an assembler in your program?
    – user1249
    Apr 5, 2012 at 9:59
  • @Thorbjørn I need the assembler inside my program.
    – Frederick
    Apr 5, 2012 at 11:22

1 Answer 1

1

You can do it with FASM.
There is a sample GUI application distributed with FASM DLL
Or, you can use Python interpreter, with Python binding for FASM DLL

3
  • Is there a version for linux too, Abyx?
    – Frederick
    Apr 5, 2012 at 11:21
  • @Frederick, DLL? You can try Wine.
    – Abyx
    Apr 5, 2012 at 12:24
  • I guess I could use Wine if nothing else works. But I think I should try and hack NASM into a library first. Thanks anyway :)
    – Frederick
    Apr 5, 2012 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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