《《Inline Assembly in GCC Vs VC++》.pdf
文本预览下载声明
Inline Assembly in GCC Vs VC++
Inline Assembly in GCC Vs VC++
IInnlliinnee AAsssseemmbbllyy iinn GGCCCC VVss VVCC++++
Gurvinder Singh
Gurvinder Singh
By GGuurrvviinnddeerr SSiinngghh, 20 Oct 2003
� Introduction
�
�
�� 介绍
Inline gcc gcc
Inline gcc gcc
IInnlliinnee Assembly is different in VC++ and ggcccc. VC uses Intel syntax while ggcccc
uses ATT syntax. Here we define the difference in syntax of ATT and Intels
assembly.
VC++和gcc 的内联汇编是不同的。VC 使用intel 汇编语法格式,
而gcc 使用ATT 语法格式。这里我们简略说说这两种语法格式的
不同。
� Source and Destination Ordering
� 原操作数和目标操作数的位置顺序
In ATT syntax the source is always on the left, and the destination is always
on the right which is opposite of the Intels syntax.
在ATT中,原操作数始终在左边,目标操作数始终在右边。而intel
格式中恰恰相反(即原操作数始终在右边,目标操作数始终在左边);
ATT Intel
ATT Intel
AATTTT IInntteell
Move ebx to eax movl %ebx, %eax mov eax, ebx
Move 100 to ebx Movl $100, %ebx Mov ebx, 100
� Prefixes/Suffixes for register naming and Immediate Values
� 寄存器以及立即数的前缀和后缀
Register names are prefixed with % in ATT while in Intel syntax they are
referenced as is. In ATT syntax $ is prefixed to all the immediate values while
no prefix is required in Intels format. In Intel syntax hexadecimal or binary
immediate data are suffixed with h and b respectively. Also if the first
hexadecimal digit is a letter then a 0 prefixes the value.
在ATT 格式中,寄存器必须加上前缀%,而intel 的没有这个
要求。在ATT 中格式,立即数必须加上前缀$,而intel 的没有
这个要求。在intel 格式中,十六进制和二进制格式的立即数会分别
h b
以 和 为后缀,如果十六进制数的第一位数字是字母的话,号必须
0
加上 前缀。
In ATT the
显示全部