过年也学习,看汇编、C、C++都怎么玩!

 这里面最容易迷惑的可能要算void _Z6my_funv(void);函数了,看到下面的命令后,相信就没什么问题了。

百度网盘下载地址:

https://pan.baidu.com/s/1_-IznMWL3z1CROziiD6mCw

//test87.c
#include <stdio.h>

void chstr(void);
void _Z6my_funv(void);

#define RENAME(name) _Z7##name##v(void);

void RENAME(my_fun1);

typedef struct My_struct {
	char a;
}My_struct;

#define Test(x) test##x
#define MyStr(str) #str
#define Mtest(type, name) type my##name
#define DD(name, type) type##name
#define DDD(type, name) type##name##_abc 

void test0(void) {
	printf("I am test0\n");
}


char s[] = "NEWCONST";
char const *str = s;

int main(void) {
	printf("All is starting here.\n");
	test0();
	Test(0)();
	printf(MyStr(Hello!));
	Mtest(int, 1);
	my1 = 15;
	printf("%x\n", &my1);
	printf("value name is %d\n", my1);
	DD(_struct, My) aaa;
	int DDD(int, val);
	_Z6my_funv();
	printf("\n");
	printf("%x\n", str);
	chstr();
	printf("%s\n", str);
	printf("%x\n", str);
	_Z7my_fun1v();	
}
//test86.cpp
#include <iostream>
using namespace std;

//extern "C" {
extern char s[];

void my_fun(void) {
	int aaa = 0xffff;
//	cin >> aaa;
	cout <<endl;
	cout << aaa;
	cout <<endl;
	cout << s;
}

void my_fun1(void) {
	cout << "I am my_fun1";
	cout <<endl;
	cout << s;
}

//}
#test85.s
.globl _chstr
.extern _str, _s

_chstr: #void chstr(void);
	pushl %ebx
	pushl %eax
	lea _str, %ebx
	addl $2, (%ebx)
	movl (%ebx), %eax
	movb $'I', (%eax)
	popl %eax
	popl %ebx
	ret
	

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_39410618

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值