惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
PCI Perspectives
PCI Perspectives
Webroot Blog
Webroot Blog
罗磊的独立博客
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
Last Week in AI
Last Week in AI
美团技术团队
Help Net Security
Help Net Security
The Hacker News
The Hacker News
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
The Register - Security
The Register - Security
IT之家
IT之家
WordPress大学
WordPress大学
Jina AI
Jina AI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Help Net Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
NISL@THU
NISL@THU
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
B
Blog
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
T
The Exploit Database - CXSecurity.com
S
Security Affairs
小众软件
小众软件
Hacker News: Ask HN
Hacker News: Ask HN
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
W
WeLiveSecurity
A
Arctic Wolf
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence

博客园 - 子风

Android相关转载帖子 c++ 函数的工作原理 VS2005配置开发ARM c++ 虚析构函数的思考 arm-linux-g++ 下交叉编译libxml2 (转)Eclipse代码提示功能设置(Java & C/C++) linux下面eclipse的c++配置 VS2008 配置boost 用VS.NET2008打包程序遇到不可恢复的生成错误的解决方案 推荐一个原型的设计软件 Mockups For Desktop Grid++Report——推模式下填充子报表 c# 对象的创建过程 Failure sending mail - 子风 XP下IIS错误:Server Application Error css总结 asp.net缓存-数据依赖缓存 - 子风 - 博客园 .net 测试工具 .net 发送Email 利用7z来分卷压缩文件
C和C++的存储模式
子风 · 2012-06-12 · via 博客园 - 子风

测试环境:winxp  TC2.0   VC++6.0

#include <stdio.h>

int main(int argc, char *argv[])
{
    
    int i = 0x1234;
    int j = 0x5678;
    printf("i = %x \n",i);
    printf("j = %x \n",j);
    printf("main = %x",main);
    scanf(&i,&j);
    return 0;
}

对应的汇编代码:

var_i= byte ptr -4
var_j= word ptr -2
argc= word ptr  4
argv= dword ptr  6
envp= dword ptr  0Ah

push    bp
mov     bp, sp
sub     sp, 4
mov     word ptr [bp+var_i], 1234h
mov     [bp+var_j], 5678h
push    word ptr [bp+var_i]
mov     ax, 194h

从上面的汇编代码可以看出,在C中先定义的变量,在栈中的地址是比较低的,后定义的变量栈中地址高。

在VC6.0中

    

int a = 0x12345678;
    int b = 0x1234;

汇编代码

6:        int i = 0x1234;
00401028   mov         dword ptr [ebp-4],1234h
7:        int j = 0x5678;
0040102F   mov         dword ptr [ebp-8],5678h

mov     [ebp+var_24], 12345678h ; a
mov     [ebp+var_28], 1234h ; b

结论:在VC6.0里面C++和C中,先申请的变量地址高,后申请的地址低,类似于先申请的先入栈,后申请的后入栈。

这个貌似和编译器有关。

学习,积累中......