汇编代码中的C代码结构

  1. 先研究全局量
编译器vs2015 , x86 , release编译。
#include "stdafx.h"

int x = 100;

const int y = 0xff;

char * str1 = "str1 globle";
const char* str2 = "str2 globle";

int a = x;

int main()
{
	int z = x + y;
	int m = 0x55;
	int n = 0x44;
	int l = m + n;
	printf("%d", l);
	printf("%d", z);
	a = x*m + n*y + a;
	printf(str1);
	printf(str2);
    return 0;
}

.text:00401000 ; int __cdecl main()
.text:00401000 _main           proc near               ; CODE XREF: __scrt_common_main_seh+F4p
.text:00401000                 push    99h
.text:00401005                 push    offset _Format  ; "%d"
.text:0040100A                 call    _printf
.text:0040100F                 push    163h
.text:00401014                 push    offset _Format  ; "%d"
.text:00401019                 call    _printf
.text:0040101E                 add     ?a@@3HA, 64F0h  ; int a
.text:00401028                 push    offset aStr1Globle ; "str1 globle"
.text:0040102D                 call    _printf
.text:00401032                 push    offset aStr2Globle ; "str2 globle"
.text:00401037                 call    _printf
.text:0040103C                 add     esp, 18h
.text:0040103F                 xor     eax, eax
.text:00401041                 retn
.text:00401041 _main           endp
全局变量位于数据节
.data:00403018 ?a@@3HA         dd 64h                  ; DATA XREF: _main+1Ew
全局常量位于只读数据节
.rdata:004020F8 ; char aStr1Globle[]
.rdata:004020F8 aStr1Globle     db 'str1 globle',0      ; DATA XREF: _main+28o
.rdata:004020F8                                         ; .rdata:char * str1o
.rdata:00402104 ; char aStr2Globle[]
.rdata:00402104 aStr2Globle     db 'str2 globle',0      ; DATA XREF: _main+32o
.rdata:00402104                                         ; .rdata:char const * const str2o
.rdata:00402110 ; char Format[]
.rdata:00402110 _Format         db '%d',0               ; DATA XREF: _main+5o
其他常量或者变量之所以没有显示出来,是因为编译器直接将它们优化掉了。



  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值