Assembly - Basic Syntax
Assembly - Basic Syntax
section.data
section.bss
section.text
global _start
https://www.tutorialspoint.com/assembly_programming/assembly_basic_syntax.htm 1/4
6/15/24, 3:47 PM Assembly - Basic Syntax
_start:
Comments
Assembly language comment begins with a semicolon (;). It may contain any
printable character including blank. It can appear on a line by itself, like −
The executable instructions or simply instructions tell the processor what to do.
Each instruction consists of an operation code (opcode). Each executable
instruction generates one machine language instruction.
The assembler directives or pseudo-ops tell the assembler about the various
aspects of the assembly process. These are non-executable and do not generate
machine language instructions.
https://www.tutorialspoint.com/assembly_programming/assembly_basic_syntax.htm 2/4
6/15/24, 3:47 PM Assembly - Basic Syntax
The fields in the square brackets are optional. A basic instruction has two parts, the
first one is the name of the instruction (or the mnemonic), which is to be executed,
and the second are the operands or the parameters of the command.
section .data
https://www.tutorialspoint.com/assembly_programming/assembly_basic_syntax.htm 3/4
6/15/24, 3:47 PM Assembly - Basic Syntax
When the above code is compiled and executed, it produces the following result −
Hello, world!
Type the above code using a text editor and save it as hello.asm.
Make sure that you are in the same directory as where you saved hello.asm.
If there is any error, you will be prompted about that at this stage. Otherwise,
an object file of your program named hello.o will be created.
To link the object file and create an executable file named hello, type ld -m
elf_i386 -s -o hello hello.o
Execute the program by typing ./hello
If you have done everything correctly, it will display 'Hello, world!' on the screen.
https://www.tutorialspoint.com/assembly_programming/assembly_basic_syntax.htm 4/4