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?
Asked
Active
Viewed 867 times
0

Frederick
- 183
- 1
- 5
-
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). – Jerry Coffin Apr 05 '12 at 08: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 05 '12 at 09:15
-
Do you want to write a small assembler, or do you need to have an assembler in your program? – Apr 05 '12 at 09:59
-
@Thorbjørn I need the assembler inside my program. – Frederick Apr 05 '12 at 11:22
1 Answers
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

Abyx
- 1,439
- 4
- 14
- 20
-
-
-
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 05 '12 at 17:13