linux 汇编

nasm的语法和大学教材上8086的汇编伪指令有些差别,指令都是一样的。


编辑器就是普通的编辑器,vim,emacs,gedit,kate
源文件类型为ascii码的plain text

编译用gcc或者nasm,前者编译AT&T汇编,后者编译intel汇编
8086的教材上一般都是用intel,不过区别不大,可以相互转化

链接就是ld,属于gcc工具集



例子:

hello.asm 源代码如下:

*************************************************************
section .text
global main
main:
mov eax,4 ;   4号调用
mov ebx,1 ;   ebx送1表示输出
mov ecx,msge ; 字符串的首地址送入ecx
mov edx,14 ;  字符串的长度送入edx
int 80h ;    输出字串
mov eax,1 ;   1号调用
int 80h ;    结束 
msge:
db "Hello world!",0ah,0dh
*************************************************************

把上面的代码保存为hello.asm,并且把该文件放在解压后的nasm的目录中,并进入目录执行如下命令:

nasm -f elf64(elf32) hello.asm                  (注意这里使用elf64还是elf32要看操作系统的位数来决定)

gcc -o hello hello.o

./hello

如果输出了hello wrod 则说明安装成功了。

参考:


http://blog.csdn.net/lhf_tiger/article/details/8883240
http://bbs.chinaunix.net/thread-2263561-1-1.html

原文地址:https://www.cnblogs.com/little-snake/p/4607145.html