内联汇编

1. msdn

// InlineAssembler_Calling_C_Functions_in_Inline_Assembly.cpp
// processor: x86
#include <stdio.h>

char format[] = "%s %s\n";
char hello[] = "Hello";
char world[] = "world";
int main( void )
{
   __asm
   {
      mov  eax, offset world
      push eax
      mov  eax, offset hello
      push eax
      mov  eax, offset format
      push eax
      call printf
      //clean up the stack so that main can exit cleanly
      //use the unused register ebx to do the cleanup
      pop  ebx
      pop  ebx
      pop  ebx
   }
}

printf( format, hello, world );

2. 自己

char format[] = "%d\n%d\n"; // 当这个写在main函数里面时,提示不正确的操作数类型。
                            // error C2415: 不正确的操作数类型
                            // offset 指令详解见《汇编指令》
main()
{
    char format1[]="haha";
    char* format2 = "%d\n%d";---全局
    char format3[] = "%d\n%d";
    __asm
    {
        push 4
        push 3
        mov edx ,0x2
        mov ecx,0x1
        call Test_fastcall; 
// 
//      
        push 4
        push 3
        mov  eax, offset format // lea eax,[format3]  
                                // mov eax,[format2]
        push eax
        call printf
        add esp,0xC
    }   
    float FNum = 11.75f;
    printf(format2,3,4);
    printf("\n0x%p\n0x%p",format2,format3);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值