cat /etc/redhat-release
看到操作系统的版本是CentOS Linux release 7.6.1810 (Core)
,uname -r
可以看到内核版本是3.10.0-957.21.3.el7.x86_64
,gcc --version
可以看到版本是4.8.5
。
下载yasm
http://yasm.tortall.net/Download.html是yasm官网,https://github.com/yasm/yasm/是yasm的git仓库。wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
下载源码。tar -xf yasm-1.3.0.tar.gz
解压yasm源码。cd yasm-1.3.0
进入源码目录。
编译并安装
./configure
进行配置make
进行编译。
完成如下:make install
安装。
安装完成如下:yasm --version
要是正常如下显示版本号的话,那就是安装成功了。
代码测试
代码如下:
section .data EXIT_SUCCESS equ 0 SYS_exit equ 60 stringDisplaying db "Hello",10,0 displayingLength equ 6section .bss section .text global _start _start: mov rax,1 mov rdi,1 mov rsi,stringDisplaying mov rdx,displayingLength syscall mov rax,SYS_exit mov rdi,EXIT_SUCCESS syscall
上边的代码使用编辑器保存成helloWithYasm.asm
,yasm -felf64 -g dwarf2 helloWithYasm.asm -o helloWithYasm.o
进行汇编,ld helloWithYasm.o -o helloWithYasm
进行链接,./helloWithYasm
执行。
本文链接:https://hqyman.cn/post/8247.html 非本站原创文章欢迎转载,原创文章需保留本站地址!