|
|
发表于 2005-12-23 15:22:51
|
显示全部楼层
asm
gcc -v
>gcc -v
Reading specs from C:/MinGW/bin/../lib/gcc-lib/mingw32/3.2.3/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c++,f77,objc --disable-win32-registry --disable-shared --enable-sjlj-exceptions
Thread model: win32
gcc version 3.2.3 (mingw special 20030504-1)
>Exit code: 0
gcc -S x.c
>gcc -S x.c
>Exit code: 0
cat x.s
>cat x.s
.file "x.c"
.globl _i
.data
.align 4
_i:
.long 2
.text
.globl _x
.def _x; .scl 2; .type 32; .endef
_x:
pushl %ebp
movl %esp, %ebp
incl _i
incl _i
movl _i, %eax
addl _i, %eax
incl _i
addl %eax, _i
movl _i, %eax
popl %ebp
ret
>Exit code: 0
cat x.c
>cat x.c
/** x.c**/
int i =2;
int x(){
i = (++i) + (++i) + (++i);
return i;
}
>Exit code: 0
Please see below ASM code of the (++i) + (++i) + (++i);
/**i =2 **/
incl _i ;i = i + 1 = 3
incl _i ;i = i + 1 = 4
movl _i, %eax ;eax= i = 4
addl _i, %eax ;eax = eax + i = 4 + 4 = 8
incl _i ;i = i + 1 = 5
addl %eax, _i ;i = eax + i = 8 + 5 = 13
see attachment of the source code |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|