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 doubleword32-bit boundary, ".word 0x1234" is the equivalent of "DW 1234h").
*'''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">
<code>
.macro <name> <args>
<operations>
.endm
</syntaxhighlight>
</code>
 
Example:
 
<syntaxhighlight lang="asm">
<pre>
.macro write string
movw string, %si
call printstr
.endm
</syntaxhighlight>
</pre>
 
This would be equivalent to the NASM macro:
 
<syntaxhighlight lang="asm">
<pre>
%macro write 1
mov si, %1
call printstr
%endmacro
</syntaxhighlight>
</pre>
 
Additionally, the cpp and m4[[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:
<sourcesyntaxhighlight lang="bash">#!/bin/bash
set -e
 
Line 100:
 
tail -n +$lineno "$objdump"
</syntaxhighlight>
</source>
 
== Sources ==
 
== SourcesSee Also ==
=== 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]
*[httphttps://savannah.nongnu.org/projects/pgubook/ Programming from the Ground Up]
*[http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_chapter/as_toc.html Using as]
*[http://savannah.nongnu.org/projects/pgubook/ Programming from the Ground Up]
 
[[Category:Assembly]]