How to programming amd64-based assembler with 64-bit FreeBSD?
like this i386-style code:
;hello world FreeBSD-i386 can run.
SYSCALL_EXIT EQU 1
SYSCALL_WRITE EQU 4
STDOUT EQU 1
section .data
hello db 'Hello, world!', 0Ah
hbytes equ $-hello
section .text
global _start
_start:
push dword hbytes
push dword hello
push dword STDOUT
mov eax,SYSCALL_WRITE
call kernel
.exit:
push dword 0
mov eax,SYSCALL_EXIT
call kernel
kernel:
int 80h
ret
Here is how I run it:
sh:nasm -f elf hello.asm -o hello.o
sh:ld -melf_i386_fbsd -s -o hello hello.o
sh:./hello
hello world1
The result is correct
sh:nasm -f elf64 hello.asm -o hello64.o
sh:ld hello64.o -o hello64
sh:./hello64
tty stdout failed! no output!