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. Python基础教程之第3章 使用字符串

    Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32 Type "copyri ...

  2. 分享一些 WINDOWS 资源站点(备用)

    分享一些 WINDOWS 资源站点(备用) Windows Embedded  http://www.10down.net/windows-embedded.php Windows 7 SP1 Upd ...

  3. ubuntu-通配符

    ubuntu下的通配符主要有三个 1.*  这个是匹配任意一个或多个字符 ab1.txt ab2.txt ab3.txt abc.txt 执行命令以及结果如下 zhangshuli@zhangshul ...

  4. C#异步编程的实现方式(4)——Task任务

    最基本的是知道怎么启动一个Task. 1.Task类构造函数 使用Task类的构造函数.实例化Task对象时,任务不会立即运行,而是指定Created状态.接着调用Task类的Start()方法来启动 ...

  5. Express简介、安装

    Express 基于Node.js平台,快速.开放.极简的web开发框架,是目前最流行的基于Node.js的web开发框架,它提供一系列强大的功能,比如: 路由控制 参数获取 send和sendFil ...

  6. Activity启动模式的深入分析

    网上关于Activity启动模式的文章许多.可是看起来都千篇一律,看完之后我们都能理解这4种启动模式.只是官方api对singleTask这个启动模式解释有些争议,导致我事实上并没有真正理解这几种模式 ...

  7. amazeui学习笔记二(进阶开发5)--Web 组件开发规范Rules

    amazeui学习笔记二(进阶开发5)--Web 组件开发规范Rules 一.总结 1.见名知意:见那些class名字知意,见函数名知意,见文件名知意 例如(HISTORY.md Web 组件更新历史 ...

  8. 学习笔记:Vue——组件和Prop

    前言:这一篇是关于组件基础.组件注册.Prop等内容. 1.组件基础 01.组件是可复用的Vue实例 02.组件中的data选项必须是一个函数 03.一个组件默认可以有任意数量的prop 任何值都可以 ...

  9. Excel数据比对-批量数据比对

    1.导出现场的Excel收费规则2.有专门的代码写的测试收费规则的工具(开发自己开发的)3.在这个工具上选择,导出的收费规则Excel,点击导出按钮(导出按钮里面有计算每一列的计费结果4.Excel里 ...

  10. fatfs输出目录

    利用fatfs文件系统, 如何输出SD卡根目录下的各个文件夹名字呢? 程序如下: u8 Dirname_i; u8 Dirname_j; DIR dir; //读取txt里的目录用,还是要把fatfs ...