Assembly Language Basics
Assembly Language Basics
1. RPM file – copy RPM file in Home. On terminal > rpm –ivh nasm-2.10.09-
3.x86_64.rpm
2. check nasm is installed or not > whereis nasm it will show the path if alrea
dy installed. Otherwise go to www.nasm.us
Download the the topmost directory Download the Linux source archive nasm-
X.XX.ta.gz
>cd nasm<version>
>./configure. This shell script will find the best C compiler to use and set up
Makefiles accordingly.
The data section,
The bss section, and
The text section.
The data Section
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 bss Section
The bss section is used for declaring variables. The syntax for declaring bss
section is −
section.bss
The text section
The text section is used for keeping the actual code. This section must
begin with the declaration global _start, which tells the kernel where the
program execution begins.
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
−
; This program displays a message on screen
Macros.
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.
Execution steps:
nasm –f elf64 hello.asm //-f for create file format, elf64 executable
linkable file format
ld –o hello hello.o // To link the object file and create an executable file
named hello
Memory Segments
A segmented memory model divides the system memory into groups of
independent segments referenced by pointers located in the segment
registers. Each segment is used to contain a specific type of data. One
segment is used to contain instruction codes, another segment stores the
data elements, and a third segment keeps the program stack.
The .bss section is also a static memory section that contains buffers for data to
be declared later in the program. This buffer memory is zero-filled.