How to generate a nasm compilable assembly code from c source code on Linux?

Viewed 17929

Test platform is 32 bit Linux.

Basically, I know gcc can be used to generate both Intel and At&T style assembly code, but it seems that you can not directly use nasm/tasm to compile the Intel style assembly code gcc generated.

I am conducting a project analysis asm code on both windows and Linux platform, so I am thinking if they can be both compiled by platform independent assembler like nasm\yasm, I could have a much easier time...

So my question is how to generate a nasm compilable assembly code from c source code on Linux?

3 Answers

Heres a way to do it without objconv

ndisasm -u <(objdump -j .text -d main.o | cut -d: -f2 | cut -d$'\t' -f 2 | perl -ne 'next if /file/; s/\s+//g; print' | xxd -r -p)
Related