两个汇编文件的调用1.asm 12345678910111213141516171819202122section .bssresb 2*32section file1data ; 自定义数据段,未使用“传统”的.datastrHello db "Hello, World", 0AhSTRLEN equ $-strHellosection file1text ; 自定义的代码段,未使用”传统“的.textextern print ; 声明此函数在别的文件中 ; 告诉编译器在编译文件时,找不到此符号也没关系,在链接时会找到 global _start ; 连接器把_start作为程序的入口 _start: push STRLEN ; 传入参数,字符长度 push strHello ; 传入参数,待打印的字符串 call print ; 此函数定义在2.asm中 ; 返回系统 mov ebx, 0; 返回值4 mov eax, 1; 系统调用号1:sys_exit int 0x80 ; 系统调用 2.asm 1234567891011121314151617181920section .textmov eax, 0x10jmp $section file2data ; 自定义数据段file2var db 3section file2text ; 自定义代码段global print ; 导出print供其他模块使用print: mov edx, [esp+8] ; 字符串长度 mov ecx, [esp+4] ; 字符串 mov ebx, 1 mov eax, 4 ; sys_write int 0x80 ; 系统调用 ret 编译、连接、执行: 12345nasm -f elf 1.asm -o 1.onasm -f elf 2.asm -o 2.old 1.o 2.o -o 12 -m elf_i386./12Hello, World