Calling system services (int 80h) under BSD-class systems is a bit different from calling them on Linux systems:
CALLing a procedure with
int 80hfollowed by
To be clear, here's an example:
; printing text: mov eax, 4 mov ebx, 1 mov ecx, text mov edx, text_len int 80h
; printing text: mov eax, 4 push dword text_len push dword text push dword 1 call kernel add esp, 12 ... ... kernel: int 80h ret
Of course, the same procedure
kernel can be used for more than one system call.
If you're getting
Operation not permitted messages while trying to
run your programs, add a new section to your program:
section .note.openbsd.ident align=4 dd 8 dd 4 dd 1 db 'OpenBSD', 0 dd 0
Now your program can be assembled and linked normally, using LD. Thanks goes to 'Fr3m3n' for reporting this method.
Another solution is to use the GCC compiler instead of LD:
gcc -o program program.o.
The entry function of the program (the place where your program starts) must now
be named main, not _start! This method has a drawback:
some special files will be added to your program, making it larger.