Skip to content

NASM on Termux #3173

Closed Answered by vlig
vlig asked this question in Q&A
Jan 7, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

The answer is: use ld.lld instead of ld.
So the full chain is:

$ nasm -f elf hello.asm
$ ld.lld -m elf_i386 -s -o hello hello.o
$ qemu-i386 hello
Hello, world!

The ASM source itself:

section .text
   global _start     ;must be declared for linker (ld)
     
_start:             ;tells linker entry point
   mov  edx,len     ;message lenght
   mov  ecx,msg     ;message to write
   mov  ebx,1       ;file descriptor (stdout)
   mov  eax,4       ;system call number (sys_write)
   int  0x80        ;call kernel
     
   mov  eax,1       ;system call number (sys_exit)
   int  0x80        ;call kernel
 
section .data
msg db 'Hello, world!', 0xa  ;our dear string
len equ $ - msg     ;lenght of our …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@im-Albania
Comment options

Answer selected by vlig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants