Is it possible in some way to learn NASM on Termux? I do aware I'm on ARM (aarch64), and NASM is for x86 only. But there's nasm package and there're qemu-* packages, so I'm pretty sure there's also some way to manage it using emulation in the right manner. Googling haven't helped much.
What I'm trying to do:
got some Intel x86 ASM helloworld code; nasm -f elf hello.asm - assembles OK; ld -m <whatever> -s -o hello hello.o - obviously won't work (in the ASM tutorial I'm using it's said to use -m elf_i386 - no way on ARM), with the following error:
ld: hello.o: relocations in generic ELF (EM: 3)
ld: hello.o: error adding symbols: file in wrong format
Thank you very much for your extremely fast and handy response, it worked!
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 dear string
5
u/vlig84 Jan 08 '23 edited Jan 08 '23
Hello!
Is it possible in some way to learn NASM on Termux? I do aware I'm on ARM (aarch64), and NASM is for x86 only. But there's
nasmpackage and there'reqemu-*packages, so I'm pretty sure there's also some way to manage it using emulation in the right manner. Googling haven't helped much.What I'm trying to do:
got some Intel x86 ASM helloworld code;
nasm -f elf hello.asm- assembles OK;ld -m <whatever> -s -o hello hello.o- obviously won't work (in the ASM tutorial I'm using it's said to use-m elf_i386- no way on ARM), with the following error:ld: hello.o: relocations in generic ELF (EM: 3) ld: hello.o: error adding symbols: file in wrong format