GAS or GNU as syntax is a different form of syntax for assembly language files, known also as AT&T syntax after the original style. It is commonly used by other versions of GAS for other architectures (i.e. non-x86). This guide is not a complete reference, but merely an overview.

Differences

GAS syntax can appear foreign to someone who is familiar with Intel syntax.

  1. Registers are prefixed by a % sign, thus eax becomes %eax
  2. Operands are reversed, so mov eax, ecx (move ecx into eax) becomes movl %ecx, %eax. Note the "l". This is discussed in item 4.
  3. Constants are prefixed with a "$", so mov eax, 50 becomes movl $50, %eax. Constants are decimal by default; hexadecimal constants are additionally prefixed with 0x, e.g. "$0x50".
  4. Opcodes do not have implied sizes nor does it specify the size as a separate word. For example, a 32 bit move with Intel syntax requires the "dword" specifier when it is ambigious, while GAS syntax uses suffixes. See below.
  5. Memory references through register are in the form of "displacement(base register, offset register, scalar)". Thus the memory reference [eax + 4 + edx*2] is written as 4(%eax, %edx, 2). Note that parentheses are used, NOT square brackets.
  6. Symbol names require a "$" to load the address, and no prefix to access contents. Thus the Intel/NASM syntax memory reference mov dword eax, [symbol] is the same movl symbol, %eax. To load the address of "symbol", then Intel/NASM syntax uses mov eax, symbol, while GAS uses movl $symbol, %eax.

Integer Suffixes

  • b -- 8 bit byte. Ex: movb $0x40, %al, move constant 0x40 into register al.
  • w -- 16 bit word. Ex: movw %ax, %bx, move register ax into bx.
  • l -- 32 bit long. Ex: movl %ecx, %eax, move register ecx into eax
  • q -- 64 bit quadword. Ex: (64 bit programs only) movq %rax, %rdx, move register rax into rdx

Floating Point (x87) Suffixes

  • s -- Short (single precision, 32 bits). Ex: flds (%eax), load 32 bit "float" from memory.
  • l -- Long (64 bits). Ex: fldl (%eax), load 64 bit "double" from memory.
  • t -- Ten-byte (80 bits). Ex: fldt (%eax), load 80 bit "long double" from memory.

SRC=https://github.com/yasm/yasm/wiki/GasSyntax

GAS Syntax的更多相关文章

  1. [Fw] assembly code in gas syntax

    Address operand syntax There are up to 4 parameters of an address operand that are presented in the ...

  2. NASM mode for Emacs

    NASM mode for Emacs   Quick post for those Emacs users out there.   The common assembler used on GNU ...

  3. Ubuntu Desktop 编译 ffmpeg (简略的写写)

    关于ffmpeg FFmpeg是一個自由軟體,可以執行音訊和視訊多種格式的錄影.轉檔.串流功能,包含了libavcodec——這是一個用於多個專案中音訊和視訊的解碼器函式庫,以及libavformat ...

  4. Yasm 1.3.0 Release Notes

    Yasm 1.3.0 Release Notes http://yasm.tortall.net/releases/Release1.3.0.html Target Audience Welcome ...

  5. YASM User Manual

    This document is the user manual for the Yasm assembler. It is intended as both an introduction and ...

  6. 如何在Open Live Writer(OLW)中使用precode代码高亮Syntax Highlighter

    早先Microsotf的Windows Live Writer(WLW)现在已经开源了,并且更名为Open Live Writer,但是现在Windows Live Writer还是可以现在,Open ...

  7. Linix登录报"/etc/profile: line 11: syntax error near unexpected token `$'{\r''"

    同事反馈他在一测试服务器(CentOS Linux release 7.2.1511)上修改了/etc/profile文件后,使用source命令不能生效,让我帮忙看看,结果使用SecureCRT一登 ...

  8. [LeetCode] Gas Station 加油站问题

    There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You ...

  9. 获取文件的缩略图Thumbnail和通过 AQS - Advanced Query Syntax 搜索本地文件

    演示如何获取文件的缩略图 FileSystem/ThumbnailAccess.xaml <Page x:Class="XamlDemo.FileSystem.ThumbnailAcc ...

随机推荐

  1. deep-in-es6(三)

    模板字符串:反撇号(`)包起来的内容. eg: var str = `assassin`; console.log(str); 模板占位符:${};可达到数据的渲染,在占位符中可以是表达式,运算符,函 ...

  2. newgrp---将当前登录用户临时加入到已有的组中

    Linux中的newgrp命令主要是将当前登录用户临时加入到已有的组中,用法如下: [linuxidc@localhost etc]$ newgrp grptest 上面命令的含义是将用户linuxi ...

  3. Linux网络编程--字节序

    1 .谈到字节序,那么会有朋友问什么是字节序 非常easy:[比如一个16位的整数.由2个字节组成,8位为一字节,有的系统会将高字节放在内存低的地址上,有的则将低字节放在内存高的地址上,所以存在字节序 ...

  4. Android学习笔记进阶21之设置壁纸

    别忘记在ApplicationManifest.xml 中加上权限的设置. <uses-permission Android:name = "android.permission.SE ...

  5. opencv之SURF图像匹配

    1.概述 前面介绍模板匹配的时候已经提到模板匹配时一种基于灰度的匹配方法,而基于特征的匹配方法有FAST.SIFT.SURF等.上面两篇文章已经介绍过使用Surf算法进行特征点检測以及使用暴力匹配(B ...

  6. Android RecyclerView嵌套RecyclerView

    原理 RecyclerView嵌套RecyclerView的条目,项目中可能会经常有这样的需求,但是我们将子条目设置为RecyclerView之后,却显示不出来.自己试了很久,终于找到了原因:必须先设 ...

  7. CSS笔记--选择器

    CSS笔记--选择器 mate的使用 <meta charset="UTF-8"> <title>Document</title> <me ...

  8. redhat6.5安装10201解决办法

    rpm --import /etc/pki/rpm-gpg/RPM*yum install -y  --skip-broken compat-libstdc++* elfutils-libelf* g ...

  9. invalid syntax 无效语法

    python用的是spyder编译器, 再出现上一行少了个括号的时候. 在下一行显示有错误.

  10. Django环境搭建(一)

    搭建Django环境之前先搭建python运行环境 需要了解: 解释器(编译器): 计算机不能直接理解任何除机器语言外的其他语言,所以程序员必须要把自己写的语言翻译成机器语言,而将其他语言翻译成机器语 ...