学习操作系统:汇编与C语言,以及汇编指令的调试

 Text.asm


message: dd 'Hello'
messageLen equ $ - message

section .text

;导出函数
global getMessage

;函数定义--getMessage
getMessage:
	push 	rbp
	mov 	rbp, rsp
	mov 	rax, message
	leave
	ret

TextMain.c 

#include <stdio.h>
#include <stdlib.h>

extern char* getMessage();


int main(int argc, char* argv[])
{
	
	char *str1_Msg3 = getMessage();
	printf("str1_Msg3=%s\n", str1_Msg3);
	return 0;
}

 makefile


MFL : TextMain.o Text.o 
	gcc -o MFL add.o test.o
add.o: 
	nasm -f elf64 Text.asm
test.o: 
	gcc -c TextMain.c
clean:
	rm Text Text.o TextMain.o

猜你喜欢

转载自blog.csdn.net/jinold/article/details/86697561
今日推荐