Assemble with NASM, disassemble with objdump -d
to get the AT&T syntax version of any single instruction.
Or use Agner Fog's objconv
to disassemble to a .S
file with GAS AT&T syntax you can actually assemble directly. (it puts labels on branch targets). It still doesn't really handle converting data, though, mostly code I think.
BTW, with GAS you can use .intel_syntax noprefix
, but it's MASM-style not NASM, so mov eax, symbol
is a load, not a mov
-immediate of the address. (You'd need mov eax, OFFSET symbol
in GAS .intel_syntax
).
See https://stackoverflow.com/tags/intel-syntax/info for more about the differences between NASM and MASM.
mov [ebx], al
and mov %al, (%ebx)
are the same instruction: a one-byte store of al
using the ebx
alone as the address. If that segfaulted, then that instruction alone isn't the problem. Either other instructions are wrong, or you have a different kind of problem. Perhaps you assembled your GAS code as 64-bit? Assembling 32-bit binaries on a 64-bit system (GNU toolchain).