Solved Assembly 32 bits hello world

hello
my program does not display the message the program runs normally without error but nothing is displayed.

Code:
$ more hello-asm-32.asm
section .data
msg: db 'Hello World!', 10
len: equ $-msg

global environ
environ:
global __progname
__progname:

section .text
global _start
_start:
mov eax, 4
mov ebx, 1
;mov edx, len
mov edx, 13
mov ecx, msg
;syscall
;int 80h
int 0x80

;Exiting
mov eax, 1
mov ebx, 0
;syscall
;int 80h
int 0x80

nasm -f elf32 hello-asm-32.asm

ld -m elf_i386_fbsd -o hello -s hello-asm-32.o

Thanks for your help
Didier
 
Do have a look on FreeBSD's calling convention. The code you shared would work under Linux ABI (and using brandelf -t Linux hello). Assuming you want to run it without it you need to pass arguments on stack and call "kernel" or align stack with additional dummy push, such as:

Code:
section .data
        msg: db 'Hello World!', 10
        len: equ $-msg

section .text
global _start
_start:
        push len
        push msg
        push 1
        mov eax, 4
        push eax        ; dummy push
        int 0x80

        mov eax,1
        push 42
        push eax        ; dummy push
        int 0x80
When learning how this program works I suggest you drop the "-s" (don't strip) and actually use -g with nasm to have debugging symbols in binary. Then you can use gdb and look what is the program doing. Also truss(1) is very handy tool as you can trace the syscalls and see if you're passing correct arguments:
Code:
$ truss ./hello
Hello World!
write(1,"Hello World!\n",13)             = 13 (0xd)
exit(0x2a)
process exit, rval = 42
 
Top