In IDAPython, you can obtain the corresponding opcodes for a assembly instruction using the Assemble(ea, line) function.Here is an example using a PE-file / x86 processor type:Python>Assemble(FirstSeg(), 'asdf')Invalid mnemonic -> OK(False, 'Assembler failed: asdf')As we can see, the Assemble call returns False and prints a error message for a invalid mnemonic when using an incorrect assembly instruction like asdf.With a valid assembly instruction, the correct opcode is returned:Python>Assemble(FirstSeg(), 'ret')(True, '\xc3')Here is the same function using a PPC-ELF/ppc processor type:Python>Assemble(FirstSeg(), 'asdf')(True, '\x00')As we can see, no error message is printed and a \x00 is returned as resulting opcode.The valid sc instruction and any other valid ppc instructions return the same (wrong) value of \x00:Python>Assemble(FirstSeg(), 'sc')(True, '\x00')How can I get IDAPython's Assemble(ea, line) to return the proper opcodes when using a PPC-ELF/ppc processor type? This is the trace the the function takes:Assemble(ea, line)_Assemble(ea, line)idaapi.AssembleLine(ea, cs, ip, use32, line)And a usage example of Assemble(), if it wasn't clear:https://code.google.com/p/idapython/source/browse/trunk/Scripts/FindInstructions.py
How to get opcodes for assembly using ppc processor (IDAPython)
ida;assembly;idapython