سؤال

I'm writing some methods in C that must run very efficiently, so I'd like to manually edit some of the assembly code that is automatically generated. I know how to read the assembly code using gdb or "objdump -d myfile.o", but can anyone tell me how to edit this code? (Will probably just be minor tweaks.)

هل كانت مفيدة؟

المحلول 2

Sure. It's called "inline assembly", and most compilers support it.

Here's an example using GCC:

نصائح أخرى

gcc have -S switch, which stops compilation on after assembly generation phase. Then you cound edit resulting file and manually call assembly (with gas, for example)

There's no way you can do it. Compiler generates code directly, there is no assembler involved; assembly listing is an aux product that can be generated, can be not. You can take asm listing and assemble it yourself, however.

If you want to improve efficiency of your code, the best way to follow is, as stated before, inline asm; or write an assembly proc, make an object file and link it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top