Opcode syntax: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
added inteltoatt script |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 13:
*'''Escapes:''' Special characters are written as C-style escapes (\n, \", \#, \\, ...).
*'''Comments:''' Either C-style ( /* ... */ ) or shell style (# ...).
*'''Directive syntax:''' Directives begin with a period (".align 4" to align on a
*'''Strings:''' Defined using special directives, .ascii (or .asciz for a zero-terminated string). Example: msg: .ascii "Hello, World!\n"
*'''Current location address:''' Indicated by a period (".", equivalent to Intel syntax "$").
Line 35:
The AT&T syntax format for macros:
<syntaxhighlight lang="asm">
.macro <name> <args>
<operations>
.endm
</syntaxhighlight>
Example:
<syntaxhighlight lang="asm">
.macro write string
movw string, %si
call printstr
.endm
</syntaxhighlight>
This would be equivalent to the NASM macro:
<syntaxhighlight lang="asm">
%macro write 1
mov si, %1
call printstr
%endmacro
</syntaxhighlight>
Additionally, the cpp and
== 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:
<
set -e
Line 100:
tail -n +$lineno "$objdump"
</syntaxhighlight>
== Sources ==▼
=== External Links ===
*[http://www.delorie.com/djgpp/v2faq/faq17_1.html DJGPP AT&T Assembly Tutorial]
*[http://asm.sourceforge.net//howto/Assembly-HOWTO.html Linux Assembly HOWTO]
*[https://savannah.nongnu.org/projects/gas-user/ GAS/AS End User Help Project]
▲*[http://savannah.nongnu.org/projects/pgubook/ Programming from the Ground Up]
[[Category:Assembly]]
|