A note for *BSD users

Calling system services (int 80h) under BSD-class systems is a bit different from calling them on Linux systems:

  1. function number is passed in EAX
  2. parameters are put on the stack from right to left (from the end)
  3. the system call is made by CALLing a procedure with int 80h followed by RET

To be clear, here's an example:
Linux:

	; printing text:

        	mov     eax, 4
		mov     ebx, 1
		mov     ecx, text
		mov     edx, text_len
		int     80h

BSD:

	; 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.



On-line contents (access key 2)
Helpers for people with disabilities (access key 0)