Chinaunix首页 | 论坛 | 博客
  • 博客访问: 400095
  • 博文数量: 103
  • 博客积分: 3073
  • 博客等级: 中校
  • 技术积分: 1078
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-23 15:04
文章分类

全部博文(103)

文章存档

2012年(13)

2011年(76)

2010年(14)

分类: LINUX

2010-11-29 15:42:42



学习asm 的一个参考网站:


9.13.3 AT&T Syntax versus Intel Syntax

as now supports assembly using Intel assembler syntax. .intel_syntax selects Intel mode, and .att_syntax switches back to the usual AT&T mode for compatibility with the output of gcc. Either of these directives may have an optional argument, prefix, or noprefix specifying whether registers require a `%' prefix. AT&T System V/386 assembler syntax is quite different from Intel syntax. We mention these differences because almost all 80386 documents use Intel syntax. Notable differences between the two syntaxes are:

  • AT&T immediate operands are preceded by `$'; Intel immediate operands are undelimited (Intel `push 4' is AT&T `pushl $4'). AT&T register operands are preceded by `%'; Intel register operands are undelimited. AT&T absolute (as opposed to PC relative) jump/call operands are prefixed by `*'; they are undelimited in Intel syntax.

  • AT&T and Intel syntax use the opposite order for source and destination operands. Intel `add eax, 4' is `addl $4, %eax'. The `source, dest' convention is maintained for compatibility with previous Unix assemblers. Note that `bound', `invlpga', and instructions with 2 immediate operands, such as the `enter' instruction, do not have reversed order. .

  • In AT&T syntax the size of memory operands is determined from the last character of the instruction mnemonic. Mnemonic suffixes of `b', `w', `l' and `q' specify byte (8-bit), word (16-bit), long (32-bit) and quadruple word (64-bit) memory references. Intel syntax accomplishes this by prefixing memory operands (not the instruction mnemonics) with `byte ptr', `word ptr', `dword ptr' and `qword ptr'. Thus, Intel `mov al, byte ptr foo' is `movb foo, %al' in AT&T syntax.

  • Immediate form long jumps and calls are `lcall/ljmp $section, $offset' in AT&T syntax; the Intel syntax is `call/jmp far section:offset'. Also, the far return instruction is `lret $stack-adjust' in AT&T syntax; Intel syntax is `ret far stack-adjust'.

  • The AT&T assembler does not provide support for multiple section programs. Unix style systems expect all programs to be single sections.

阅读(866) | 评论(0) | 转发(0) |
0

上一篇:segmentation fault

下一篇:putty psftp 的用法

给主人留下些什么吧!~~