Ubuntu 22.04源码安装yasm 1.3.0

sudo lsb_release -r看到操作系统的版本是22.04sudo uname -r可以看到内核版本是5.15.0-86-genericsudo gcc --version可以看到版本是11.2.0sudo make --version可以看到版本是GNU Make 4.3

下载yasm

http://yasm.tortall.net/Download.html是yasm官网,https://github.com/yasm/yasm/是yasm的git仓库。
sudo wget -c http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz下载yasm源码。

sudo tar -xf yasm-1.3.0.tar.gz解压yasm源码。

cd yasm-1.3.0进入源码目录。

编译并安装

sudo ./configure进行配置

完成之后如下:

sudo make进行编译。

完成如下:

sudo make install安装。

yasm --version可以看到输出的内容如下:

shell 复制代码
yasm 1.3.0
Compiled on Nov  9 2023.
Copyright (c) 2001-2014 Peter Johnson and other Yasm developers.
Run yasm --license for licensing overview and summary.

代码测试

代码如下:

c 复制代码
section .data
        stringToShow db "Hello",10,0
section .bss
section .text
    global _start
    _start:
        mov rax,1
        mov rdi,1
        mov rsi,stringToShow
        mov rdx,6
        syscall
        mov rax,60
        mov rdi,0
        syscall

上边的代码使用编辑器保存成helloInYasm.asmsudo yasm -felf64 -g dwarf2 helloInYasm.asm -o helloInYasm.o进行汇编,sudo ld helloInYasm.o -o helloInYasm进行链接,sudo ./helloInYasm执行输出Hello

相关推荐
Sokach10159 小时前
Linux Shell 脚本从零到能用:一个新手的一天学习总结
linux
AlfredZhao1 天前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
zzzzzz3102 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode2 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
A小辣椒4 天前
TShark:Wireshark CLI 功能
linux
A小辣椒4 天前
TShark:基础知识
linux
AlfredZhao4 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao5 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334665 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
猪脚踏浪5 天前
linux 拷贝文件或目录到指定的位置
linux