汇编学习之nasm编译器下载使用
生活随笔
收集整理的这篇文章主要介绍了
汇编学习之nasm编译器下载使用
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
我是在centos7虚拟机上面进行试验学习,所以对应的结果和输入都是命令行的输入输出。
使用wegt命令下载压缩包,解压
tar -xvzf nasm-2.14.tar.gz切换到对应目录并编译安装
cd nasm-2.14 ./configure make 编译 make install 安装编译安装过程中会出现很多warning,一开始也是很紧张,不过暂时还没发现有什么不好的现象,主要是说c99不支持之类的警告信息
2. 测试nasm编译器
直接就当前目录进行编程
直接照抄网上大神的一篇hello,world的汇编测试代码
section .data ;section declaration msg db "Hello, world!",0xA ;our dear string len equ $ - msg ;length of our dear string section .text ;section declaration;we must export the entry point to the ELF linker orglobal _start ;loader. They conventionally recognize _start as their;entry point. Use ld -e foo to override the default. _start: ;write our string to stdoutmov eax,4 ;system call number (sys_write)mov ebx,1 ;first argument: file handle (stdout)mov ecx,msg ;second argument: pointer to message to writemov edx,len ;third argument: message lengthint 0x80 ;call kernel ;and exitmov eax,1 ;system call number (sys_exit)xor ebx,ebx ;first syscall argument: exit codeint 0x80 ;call kernel编译
nasm -f elf64 hello.s -o hello.o链接
ld -s hello.o -o hello.out最后运行hello.out就行,输出结果如下:
[root@jack nasm-2.14]# ./hello.out Hello, world!至此nasm编译器的学习和使用算是拉开了序幕。
补:win10下64位系统官网下载
这个直接点进去下载就可以了,下载后的使用也是黑窗口的样式的。
总结
以上是生活随笔为你收集整理的汇编学习之nasm编译器下载使用的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 《断弦》感想
- 下一篇: 网上书店订单流程c语言源代码,网上书店的