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!”就没问题了

最新文章

  1. Linux命令dos2unix 从windows转换到linux --- nuix2dos从linux转换到windows
  2. 在 Windows 10 中启用 Windows Photo Viewer
  3. 新年PR交期回写,展望期由14天改为30天,FP_PR2SAP ;转单量改为100W;FP_PR2SAP_MOD_NEW
  4. Java 第13章 带参数的方法
  5. c++ const用法小结
  6. Mac OS X中MacPorts的安装使用备忘
  7. 表单,css
  8. Hibernate 性能优化之懒加载
  9. div中央
  10. HDU 2209 翻纸牌游戏(DFS)
  11. CSS前端开发学习总结、一
  12. linkin大话设计模式--门面模式
  13. 机器学习基石:02 Learning to Answer Yes/No
  14. d3.csv()后获取的数据不是数组,而是对象
  15. IDEA+API && SPI
  16. python S2-45 漏洞利用工具
  17. 迷你音乐播放器v1.0正式上线!
  18. grafana-simple-json-datasource 用于连接各种grafana不支持的数据源
  19. 解决jenkins下使用HTML Publisher插件后查看html报告显示不正常
  20. 吴裕雄 数据挖掘与分析案例实战(8)——Logistic回归分类模型

热门文章

  1. CountDownLatch、CyclicBarrier和Semaphore使用
  2. springboot数据库主从方案
  3. 使用vitamio长时间播放崩溃的另类处理
  4. Android 网络通信框架Volley(二)
  5. 6 个 K8s 日志系统建设中的典型问题,你遇到过几个?
  6. hbase数据备份或者容灾方案
  7. 定义一个Person类,其中包括:1.定义属性:姓名、年龄、民族作为成员变量。定义静态成员变量:人数2.定义构造方法:对成员变量进行初始化。3.定义多个方法:分别显示相应的属性值,例如getName(){System.out.print("名称="+name+";"); }4.定义一个方法“成长”:实现年龄的增加,每执行一次年龄增加1
  8. Phpstudy被暴存在隐藏后门-检查方法
  9. 树莓派3安装ros
  10. Python实战练习_贪吃蛇 (pygame的初次使用)