Anonymous user
Opcode syntax: Difference between revisions
added inteltoatt script
[unchecked revision] | [unchecked revision] |
m (fixed a typo) |
(added inteltoatt script) |
||
Line 61:
Additionally, the cpp and m4 macro preprocessors are often used for macro handling.
== Converting small snippets of code from Intel syntax to AT&T ==
You can use the following script to convert short snippets of code (one liners) from Intel syntax to AT&T syntax:
<source lang="bash">#!/bin/bash
set -e
# Usage:
#
# ./inteltoatt [16|32|64] "mov eax, eax \n xor ecx, edx"
#
case "$1" in
16|32|64)
bits="$1"
shift ;;
*)
bits="32" ;;
esac
code="$1"
nasm="$(mktemp)"
obj="$(mktemp)"
objdump="$(mktemp)"
case "$bits" in
16) m="i8086" ;;
32) m="i386" ;;
64) m="i386:x86-64" ;;
esac
echo -e "BITS $bits\n$code" > "$nasm"
nasm "$nasm" -o "$obj"
objdump -D -b binary -m $m -Maddr${bits},data${bits} "$obj" > "$objdump"
lineno="$(egrep -m 1 -n '<\.data>\:$' "$objdump" | cut -d':' -f1)"
lineno=$((lineno+1))
tail -n +$lineno "$objdump"
</source>
== Sources ==
|