First, you need to install a assembler. I use NASM, which is very easy to install in Linux.
Nasmhttp: // www. NASM. US/pub/NASM/releasebuilds/
After downloading the file, decompress it and enter the directory to find the configure file. Next, I believe that anyone familiar with Linux will know what to do.
Enter./configure. After the command is executed, you will find that a MAKEFILE file is generated in the directory. This is the make command to compile NASM.
Enter root and enter make install to install NASM. If your machine does not have GCC, you can install GCC and search for it by yourself. Because GCC has been installed here, I will not talk about it here.
Next, you can compile the helloworld assembly code. Here I refer to the sample code on Wikipedia.
section .data msg db ‘Hello, world!‘,0xA len equ $-msg section .text global _start _start: mov edx,len mov ecx,msg mov ebx,1 mov eax,4 int 0x80 mov ebx,0 mov eax,1 int 0x80
Then save the edited file. It does not matter if the initial suffix is used. The suffix is only displayed in Linux. After saving it, enter the NASM-F elf32 file name, after the command is executed
A file named. O is generated, and after the input LD file name. O-o file name is completed, the executable file we normally use is generated.
At this time, the input./file name will show Hello world.