2.5 BeOS
BeOS内核同样使用通用的UNIX调用惯例,其和FreeBSD的区别是使用:int
0x25。对于到哪里查找系统调用号和其他感兴趣的细节,查看os_beos.inc文件。为了使用nasm正确的编译BeOS程序,需要在float.h中加入#include
“nasm.h“ ,和在nasm.h中加入#include 。
-----------------------------------------------------------------
section .text
global _start ;must be declared for linker (ld)
msg db “Hello, world!“,0xa ;our dear string
gen equ $ - msg ;length of our dear string
_syscall: ;system call
int 0x25
ret
_start: ;tell linker entry point
push dword len ;message length
push dword msg ;message to write
push dword 1 ;file descriptor (stdout)
mov eax,0x3 ;system call number (sys_write)
call _syscall ;call kernel
add esp,12 ;clean stack (3 * 4)
push dword 0 ;exit code
mov eax,0x3f ;system call number (sys_exit)
call _syscall ;call kernel
;no need to clean stack
-----------------------------------------------------------------
2.6 创建可执行代码
创建可执行代码分为两个阶段:编译和链接。按照下面的步骤进行:
-----------------------------------------------------------------
$ nasm -f elf hello.asm # this will produce hello.o object file
$ ld -s -o hello hello.o # this will produce hello executable
-----------------------------------------------------------------
name
short description
platform
OS
assembler
asmutils
miscellaneous utilities, small libc
IA32
Linux, FreeBSD (BeOS)
nasm
libASM
assembly library (lots of various routines)
IA32
Linux
nasm
e3
WordStar-like text editor
IA32
Linux, FreeBSD, BeOS
nasm
ec64
Commodore C64 emulator
IA32
Linux
nasm
ELF kickers
ELF kickers and tiny Linux executables
IA32
Linux
nasm
BLAS
basic linear algebra subroutines
Alpha
Linux, Digital UNIX, WinNT
gas
ASMIX
several commandline utilities
TA32
Linux, FreeBSD
gas
asm-toys
few utilities
IA32
Linux
gas
cpuburn
CPU loading utililties
IA32
Linux, FreeBSD
gas
acid
small textmode intro
IA32, ARM
Linux
nasm, gas