2
C版:理解ATT彙編語言
int arith(int x, int y, int z)
{
int t1 = x+y;
int t2 = z*48;
int t3 = t1 & 0xFFFF;
int t4 = t2 * t3;
return t4;
}
ATT大會相同程序的版本:
X在的%ebp + 8,Y在的%ebp + 12,Z在的%ebp + 16
movl 16(ebp), %eax
leal (%eax, %eax, 2), %eax
sall $4, %eax // t2 = z* 48... This is where I get confused
movl 12(%ebp), %edx
addl 8(%ebp), %edx
andl $65535, %edx
imull %edx, %eax
我明白除了左移之外,它在程序的所有位置上所做的一切。
我認爲它會左移4次。這是爲什麼?
謝謝!
編輯:我也明白,我在困惑的部分是相當於C版本的Z * 48的一部分。
我不理解的是,左移4次如何等於z * 48。
左移4位基本上乘以16。 – 2013-02-16 22:29:16