GAS Syntax

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

时间: 2024-07-30 10:18:39

GAS Syntax的相关文章

Yasm 1.3.0 Release Notes

http://yasm.tortall.net/releases/Release1.3.0.html Target Audience Welcome to the 1.3.0 release of the Yasm Modular Assembler. Its target audience includes people who want to: use a mature NASM-syntax x86 and AMD64 assembler that can target Win32, Wi

YASM User Manual

This document is the user manual for the Yasm assembler. It is intended as both an introduction and a general-purpose reference for all Yasm users. 1.?Introduction Yasm is a BSD-licensed assembler that is designed from the ground up to allow for mult

程序的机器级表示 (2)

3.6.5 循环 据说大多数汇编器会根据do-while循环来产生代码, 所以其他循环可能会先转化为do-while形式再编译成机器代码, 所以我们首先介绍do-while循环... 1. do-while 循环 do-while的通用形式如图所示 : loop: body-statement t = test-expr; if(t) goto loop; 这里给出一个实际的例子 : 2. while循环 while循环有多种翻译方法, gcc使用了的是 先用if 进行检测第一次循环, 这样就将

error C2143: syntax error : missing ';' before '{'

这是我在实现哈夫曼树的时候,遇到的错误,具体为什么我也不清楚!!!因为这是我用学校实验室的电脑编译出现的错误(用的软件是VC6.0,贼老的版本!!!),我自己的是Code Blocks(没有出错)??? 代码如下: for ( i = 1; i <= n; i++ ) { huffNode HT[i](w[i],0,0,0);//初始化前n个节点(构造哈夫曼树的原始节点) } 然后,就有错了(-_-!) error C2057: expected constant expression erro

[C++]LeetCode: 119 Gas Station

题目: There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with

Gas Station

There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an e

LeetCode: Gas Station 解题报告

Gas Station There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journ

Python Special Syntax 8: 序列化与反序列化--&gt;华丽丽的叫 pickle(泡菜?!)

直接上代码吧 #-*-coding:utf-8 import os if os.path.exists('d:\\cpickle.data'): os.remove('d:\\cpickle.data') import cPickle as P shoplist=['apple','banana','pear'] P.dump(shoplist,file('d:\\cpickle.data','w')) f=file('d:\\cpickle.data') while True: content

Laravel 5.4 migrate报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `us ers_email_unique`(`email`))

Laravel 5.4 migrate报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `us     ers_email_unique`(`email`)) public function up() { Schema::create('users', function (Blu