Ubuntu安装NASM和简单的使用教程
2024-09-01 11:32:58
1. 安装
sudo apt-get install nasm
这样nasm就安装好了,终端输入命令:
nasm -version
输出版本信息就说明安装成功
2. 使用
创建"hello.asm"文件:
touch hello.asm
gedit hello.asm
在文件中输入下面的汇编代码
section .data
hello: db 'Hello world!',10 ; 'Hello world!' plus a linefeed character
helloLen: equ $-hello ; Length of the 'Hello world!' string
; (I'll explain soon)
section .text
global _start
_start:
mov eax,4 ; The system call for write (sys_write)
mov ebx,1 ; File descriptor 1 - standard output
mov ecx,hello ; Put the offset of hello in ecx
mov edx,helloLen ; helloLen is a constant, so we don't need to say
; mov edx,[helloLen] to get it's actual value
int 80h ; Call the kernel
mov eax,1 ; The system call for exit (sys_exit)
mov ebx,0 ; Exit with return code of 0 (no error)
int 80h
保存后退出。
编译
nasm -f elf64 hello.asm
如果是32位系统就把elf64
改为elf32
链接
ld -s -o hello hello.o
运行
./hello
终端输出“Hello,world!”就没问题了
最新文章
- Linux命令dos2unix 从windows转换到linux --- nuix2dos从linux转换到windows
- 在 Windows 10 中启用 Windows Photo Viewer
- 新年PR交期回写,展望期由14天改为30天,FP_PR2SAP ;转单量改为100W;FP_PR2SAP_MOD_NEW
- Java 第13章 带参数的方法
- c++ const用法小结
- Mac OS X中MacPorts的安装使用备忘
- 表单,css
- Hibernate 性能优化之懒加载
- div中央
- HDU 2209 翻纸牌游戏(DFS)
- CSS前端开发学习总结、一
- linkin大话设计模式--门面模式
- 机器学习基石:02 Learning to Answer Yes/No
- d3.csv()后获取的数据不是数组,而是对象
- IDEA+API &;&; SPI
- python S2-45 漏洞利用工具
- 迷你音乐播放器v1.0正式上线!
- grafana-simple-json-datasource 用于连接各种grafana不支持的数据源
- 解决jenkins下使用HTML Publisher插件后查看html报告显示不正常
- 吴裕雄 数据挖掘与分析案例实战(8)——Logistic回归分类模型
热门文章
- CountDownLatch、CyclicBarrier和Semaphore使用
- springboot数据库主从方案
- 使用vitamio长时间播放崩溃的另类处理
- Android 网络通信框架Volley(二)
- 6 个 K8s 日志系统建设中的典型问题,你遇到过几个?
- hbase数据备份或者容灾方案
- 定义一个Person类,其中包括:1.定义属性:姓名、年龄、民族作为成员变量。定义静态成员变量:人数2.定义构造方法:对成员变量进行初始化。3.定义多个方法:分别显示相应的属性值,例如getName(){System.out.print(";名称=";+name+";;";); }4.定义一个方法“成长”:实现年龄的增加,每执行一次年龄增加1
- Phpstudy被暴存在隐藏后门-检查方法
- 树莓派3安装ros
- Python实战练习_贪吃蛇 (pygame的初次使用)