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

推荐订阅源

V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Latest news
Latest news
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
L
Lohrmann on Cybersecurity
aimingoo的专栏
aimingoo的专栏
B
Blog
T
Threat Research - Cisco Blogs
罗磊的独立博客
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
P
Palo Alto Networks Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
T
Tor Project blog
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
Recorded Future
Recorded Future
D
DataBreaches.Net
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
B
Blog RSS Feed
Scott Helme
Scott Helme
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
A
Arctic Wolf
Help Net Security
Help Net Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Schneier on Security
Hacker News: Ask HN
Hacker News: Ask HN
N
Netflix TechBlog - Medium
L
LangChain Blog
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
M
MIT News - Artificial intelligence
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
W
WeLiveSecurity

博客园 - shootingstars

硬件相关概念 我的Function C的可变参数 C++概念网摘 Mifare 串行读取协议 韦根协议 学习C的可变参数 如何移植Java的类中的super到C++代码中 编译原理学习 关于标准库中的ptr_fun/binary_function/bind1st/bind2nd 使用python编写每日构建工具 boost::regex学习(5) - shootingstars - 博客园 boost::regex学习(4) - shootingstars - 博客园 boost::regex学习(3) boost::regex学习(2) 《世界大战》《变形金刚》观后感 boost::regex学习(1) boost::algorithm学习 五种迭代器
关于汇编程序调用各种C函数的例子
shootingstars · 2008-07-22 · via 博客园 - shootingstars

int _stdcall s_addint(int i, int j)
{
    printf(
"i = %d\n",i);
    printf(
"j = %d\n",j);
    
return i+j;
}


int __cdecl  c_addint(int i, int j)
{
    printf(
"i = %d\n",i);
    printf(
"j = %d\n",j);
    
return i+j;
}


int _fastcall  f_addint(int i, int j, int k)
{
    printf(
"i = %d\n",i);
    printf(
"j = %d\n",j);
    printf(
"k = %d\n",k);
    
return i+j+k;
}


int _tmain(int argc, _TCHAR* argv[])
{
    
int num;

    
// 汇编调用_stdcall函数
    
// 参数由右至左压栈
    
// 调用返回时,堆栈由被调函数调整
    
// 返回值在EAX中
    _asm
    
{
        push 
2
        push 
1
        call s_addint
        mov  num,eax
    }


    printf(
"num = %d\n",num);

    
// 汇编调用__cdecl函数
    
// 参数由右至左压栈
    
// 调用返回时,堆栈由调用者调整
    
// 返回值在EAX中
    _asm
    
{
        push 
4
        push 
3
        call c_addint
        mov  num,eax
        add esp,
4*2
    }


    printf(
"num = %d\n",num);

    
// 汇编调用_fastcall函数
    
// 函数的第一个和第二个DWORD参数(或者尺寸更小的)通过ecx和edx传递,其他参数通过从右向左的顺序压栈
    
// 调用返回时,堆栈由被调函数调整
    
// 返回值在EAX中
    _asm
    
{
        mov ecx,
5
        mov edx,
6
        push 
7
        call f_addint
        mov  num,eax
    }


    printf(
"num = %d\n",num);
    
    
return 0;

}

以上代码通过VC8编译