Hello! I was looking for a simple assembly code, a `Hello world' for example, which runs on NetBSD, written and compiled with nasm. I tried a code to print the CPU vendor string through cpuid: the entire code is copied after the text of this e-mail. It works on FreeBSD. On NetBSD 9.0 I built it with
nasm -f elf64 -o testcpu.o testcpu.s ld -s -o testcpu testcpu.o This gives no error, however the file can not execute. If I try to run the file, I obtain: /bin/sh: Cannot execute ELF binary ./testcpu The only example I found is https://wiki.netbsd.org/examples/netbsd_assembly/ However, it is quite confusing and it is for i386, while I would like to use amd64. I can't understand if the error is due to a bad linking or building, or if the code itself has some wrong instruction. Is there a NetBSD nasm amd64 example? Or some hints that I should follow? Bye! Rocky Here is my code, that is the contents of file testcpu.s: section .bss buff resb 12 section .text global _start _start: mov eax, 0 cpuid mov dword [buff+0], ebx mov dword [buff+4], edx mov dword [buff+8], ecx mov rax, 4 mov rdi, 1 mov rsi, buff mov rdx, 12 syscall mov rax, 1 mov rbx, 0 syscall