An assembly program can be divided into three sections −
The data section is used for declaring initialized data or constants. This data does not change at runtime. you can declare various constant values, file names, or buffer size, etc., in this section.
The syntax for declaring data section is –
The bss section is used for declaring variables. The syntax for declaring bss section is −
The text section is used for keeping the actual code. This section must start with the declaration global _start, which tells the kernel in which the program execution begins.
The syntax for declaring text section is –
Assembly language comment begins with a semicolon (;). It may contain any printable character including blank. It can appear on a line by itself, like –
or, on the same line along with an instruction, like –
Assembly language programs consist of three types of statements −
The executable instructions or simply instructions tell the processor what to do. every 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.
Macros are basically a text substitution mechanism.
Assembly language statements are entered one statement per line. each declaration follows the following format
The fields in the square brackets are optional. A basic instruction has two parts, the primary one is the name of the instruction (or the mnemonic), that is to be executed, and the second one are the operands or the parameters of the command.
Following are some examples of typical assembly language statements –
The following assembly language code displays the string 'Hello World' on the screen –
When the above code is compiled and executed, it produces the following result –
Make sure you have set the path of nasm and ld binaries on your path surroundings variable. Now, take the following steps for compiling and linking the above program −
If you have done everything correctly, it will display 'hello, world!' at the screen.
Assembly Programming Related Interview Questions
|C++ Interview Questions||C Interview Questions|
|Embedded Systems Interview Questions||Linux Embedded systems Interview Questions|
|PLC/Microcontrollers/Microprocessors Interview Questions||Microprocessor 8085 Interview Questions|
|Microprocessor 8086 Interview Questions||Embedded C Interview Questions|
Assembly Programming Related Practice Tests
|C++ Practice Tests||C Practice Tests|
|Embedded Systems Practice Tests||Linux Embedded systems Practice Tests|
|PLC/Microcontrollers/Microprocessors Practice Tests|
Assembly Programming Tutorial
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.