SlideShare une entreprise Scribd logo
1  sur  31
ASSEMBLY LANGUAGE
Introduction
 Assembly language is a low-level programming language
for a computer or other programmable device specific
to a particular computer architecture in contrast to
most high-level programming languages, which are
generally portable across multiple systems.
 Assembly language is converted into executable
machine code by a utility program referred to as an
assembler like NASM, MASM, etc.
Introduction
 Each personal computer has a microprocessor that
manages the computer's arithmetical, logical, and
control activities.
 Each family of processors has its own set of
instructions for handling various operations such as
getting input from keyboard, displaying information
on screen and performing various other jobs.
 These set of instructions are called 'machine
language instructions'.
Introduction
 A processor understands only machine language
instructions, which are strings of 1's and 0’s.
 However, machine language is too obscure and
complex for using in software development.
 the low-level assembly language is designed for a
specific family of processors that represents various
instructions in symbolic code and a more
understandable form.
Advantages of
Assembly Language
Having an understanding of assembly language makes
one aware of −
 How programs interface with OS, processor, and BIOS;
 How data is represented in memory and other external
devices;
 How the processor accesses and executes instruction;
 How instructions access and process data;
 How a program accesses external devices.
Advantages of
Assembly Language
Other advantages of using assembly language are −
 It requires less memory and execution time;
 It allows hardware-specific complex jobs in an easier
way;
 It is suitable for time-critical jobs;
 It is most suitable for writing interrupt service routines
and other memory resident programs.
Basic Features of PC Hardware
 The main internal hardware of a PC consists of
processor, memory, and registers.
 Registers are processor components that hold data and
address. To execute a program, the system copies it
from the external device into the internal memory.
The processor executes the program instructions.
 The fundamental unit of computer storage is a bit; it
could be ON (1) or OFF (0) and a group of 8 related
bits makes a byte on most of the modern computers.
Basic Features of PC Hardware
The processor supports the following data sizes −
 Word: a 2-byte data item
 Doubleword: a 4-byte (32 bit) data item
 Quadword: an 8-byte (64 bit) data item
 Paragraph: a 16-byte (128 bit) area
 Kilobyte: 1024 bytes
 Megabyte: 1,048,576 bytes
Assembly Language Parts
An assembly program can be divided into three sections −
The data section,
The bss section, and
The text section.
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 syntax for declaring data section is −
section.data
bss section
 The bss section is used for declaring variables.
 The syntax for declaring bss section is −
section.bss
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.
 The syntax for declaring text section is −
section.text global _start_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 −
 ; This program displays a message on screen
or, on the same line along with an instruction, like
−
add eax, ebx ; adds ebx to eax
Assembly Language Statements
Assembly language programs consist of three types of
statements −
 Executable instructions or instructions,
 Assembler directives or pseudo-ops, and
 Macros.
Assembly Language Statements
 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.
Assembly Language Statements
 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.
.
Syntax of Assembly Language
Statements
 Assembly language statements are entered one statement
per line. Each statement follows the following format −
[label] mnemonic [operands] [;comment]
 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.
Syntax of Assembly Language
Statements
Structure of a NASM Program
 NASM is line-based. Most programs consist
of directives followed by one or more sections.
 Lines can have an optional label. Most lines have
an instruction followed by zero or more operands.
 This is the project webpage for the Netwide Assembler
(NASM), an assembler for the x86 CPU architecture portable
to nearly every modern platform, and with code generation
for many platforms old and new
Structure of a NASM Program
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.
Memory Segments
In the light of the above discussion, we can specify
various memory segments as −
 Data segment − It is represented by .data section and
the .bss. The .data section is used to declare the
memory region, where data elements are stored for
the program. This section cannot be expanded after
the data elements are declared, and it remains static
throughout the program.
 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.
Memory Segments
 Code segment − It is represented
by .text section. This defines an area in memory
that stores the instruction codes. This is also a
fixed area.
 Stack − This segment contains data values passed
to functions and procedures within the program.
TASM
 Turbo Assembler (sometimes shortened to
the name of the executable, TASM) is an
assembler for software development
published by Borland in 1989. It runs on and
produces code for 16- or 32-bit x86 MS-DOS
and compatible on Microsoft Windows
MASM
 The Microsoft Macro Assembler (MASM) is an
x86 assembler that uses the Intel syntax for
MS-DOS and Microsoft Windows.
 Beginning with MASM 8.0, there are two
versions of the assembler: One for 16-bit &
32-bit assembly sources, and another for
64-bit sources only.
 Assemblers expect either the original syntax used
in the Intel instruction set documentation - the
Intel syntax - or the so-called AT&T syntax
developed at the AT&T Bell Labs.
 AT&T uses mov src, dest, Intel uses mov dest, src,
amongst other differences.
 Windows assemblers prefer Intel syntax (TASM,
MASM), most Linux/UNIX assemblers use AT&T.
NASM uses a variant of the Intel syntax.
 Assemblers have their own syntax for directives
affecting the assembly process, macros and
comments. These usually differ from assembler to
assembler
QUIZ
______________1. What symbol defines Comments in Assembly Language?
______________2. This section is used to declare the memory region,
where data elements are stored for the program.
______________3. This defines an area in memory that stores the
instruction codes. This is also a fixed area.
______________4. Which part of the assembly language tells the kernel
where the program execution begins?
______________5. Which tells the assembler about the various aspects of
the assembly process. These are non-executable and do not generate
machine language instructions.
______________6. What is the syntax in declaring data section?
______________7. This segment contains data values passed to functions
and procedures within the program.
______________8. What is the fundamental unit of computer storage?
_____9_______10. Advantages of understanding Assembly language
1. Semicolon
2. Data segment
3. Code segment
4. global _start,
5. assembler directives
6. section.data
7. Stack
8. bit
 How programs interface with OS, processor, and BIOS;
 How data is represented in memory and other external devices;
 How the processor accesses and executes instruction;
 How instructions access and process data;
 How a program accesses external devices.

Contenu connexe

Tendances

Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer Architecture
Haris456
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
Ahmed M. Abed
 

Tendances (20)

Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
 
Processor organization & register organization
Processor organization & register organizationProcessor organization & register organization
Processor organization & register organization
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
 
Coa module1
Coa module1Coa module1
Coa module1
 
Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1)
 
15CS44 MP & MC Module 1
15CS44 MP & MC Module 115CS44 MP & MC Module 1
15CS44 MP & MC Module 1
 
Instruction cycle
Instruction cycleInstruction cycle
Instruction cycle
 
Computer registers
Computer registersComputer registers
Computer registers
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
 
Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer Architecture
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
 
Basic Computer Organization and Design
Basic  Computer  Organization  and  DesignBasic  Computer  Organization  and  Design
Basic Computer Organization and Design
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 
Computer registers
Computer registersComputer registers
Computer registers
 
First pass of assembler
First pass of assemblerFirst pass of assembler
First pass of assembler
 
Register introduction
Register introductionRegister introduction
Register introduction
 

Similaire à ASSEMBLY LANGUAGE.pptx

1 Describe different types of Assemblers.Assembly language.docx
 1 Describe different types of Assemblers.Assembly language.docx 1 Describe different types of Assemblers.Assembly language.docx
1 Describe different types of Assemblers.Assembly language.docx
aryan532920
 
System programming note
System programming noteSystem programming note
System programming note
SANTOSH RATH
 
Please send the answers to my email. Mirre06@hotmail.comSomeone se.pdf
Please send the answers to my email. Mirre06@hotmail.comSomeone se.pdfPlease send the answers to my email. Mirre06@hotmail.comSomeone se.pdf
Please send the answers to my email. Mirre06@hotmail.comSomeone se.pdf
ebrahimbadushata00
 

Similaire à ASSEMBLY LANGUAGE.pptx (20)

Introduction to Assembly Language Programming
Introduction to Assembly Language ProgrammingIntroduction to Assembly Language Programming
Introduction to Assembly Language Programming
 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit I
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Cao 2012
Cao 2012Cao 2012
Cao 2012
 
N_Asm Assembly basic syntax (sol)
N_Asm Assembly basic syntax (sol)N_Asm Assembly basic syntax (sol)
N_Asm Assembly basic syntax (sol)
 
SP Solutions -Adi.pdf
SP Solutions -Adi.pdfSP Solutions -Adi.pdf
SP Solutions -Adi.pdf
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdf
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdf
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Assembly
AssemblyAssembly
Assembly
 
1 Describe different types of Assemblers.Assembly language.docx
 1 Describe different types of Assemblers.Assembly language.docx 1 Describe different types of Assemblers.Assembly language.docx
1 Describe different types of Assemblers.Assembly language.docx
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic concepts
 
Chapter1a
Chapter1aChapter1a
Chapter1a
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
 
System programming note
System programming noteSystem programming note
System programming note
 
UNIT 2_ESD.pdf
UNIT 2_ESD.pdfUNIT 2_ESD.pdf
UNIT 2_ESD.pdf
 
CISY 105 Chapter 1
CISY 105 Chapter 1CISY 105 Chapter 1
CISY 105 Chapter 1
 
microprocesser-140306112352-phpapp01.pdf
microprocesser-140306112352-phpapp01.pdfmicroprocesser-140306112352-phpapp01.pdf
microprocesser-140306112352-phpapp01.pdf
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
Please send the answers to my email. Mirre06@hotmail.comSomeone se.pdf
Please send the answers to my email. Mirre06@hotmail.comSomeone se.pdfPlease send the answers to my email. Mirre06@hotmail.comSomeone se.pdf
Please send the answers to my email. Mirre06@hotmail.comSomeone se.pdf
 

Plus de EdFeranil (12)

The Contemporary World (Movement and Sys
The Contemporary World (Movement and SysThe Contemporary World (Movement and Sys
The Contemporary World (Movement and Sys
 
Example quiz on sets laws discrete math
Example quiz on sets laws  discrete mathExample quiz on sets laws  discrete math
Example quiz on sets laws discrete math
 
Mathematical Logic.pptx
Mathematical Logic.pptxMathematical Logic.pptx
Mathematical Logic.pptx
 
Arrays in Reading.pptx
Arrays in Reading.pptxArrays in Reading.pptx
Arrays in Reading.pptx
 
Law and Ethics in Information Security.pptx
Law and Ethics in Information Security.pptxLaw and Ethics in Information Security.pptx
Law and Ethics in Information Security.pptx
 
OOP -interface and objects.pptx
OOP -interface and objects.pptxOOP -interface and objects.pptx
OOP -interface and objects.pptx
 
The Evolution of Computing.pptx
The Evolution of Computing.pptxThe Evolution of Computing.pptx
The Evolution of Computing.pptx
 
Java Basics.pdf
Java Basics.pdfJava Basics.pdf
Java Basics.pdf
 
ERD Activity.pptx
ERD Activity.pptxERD Activity.pptx
ERD Activity.pptx
 
Boolean Expression.pptx
Boolean Expression.pptxBoolean Expression.pptx
Boolean Expression.pptx
 
intro to assembly language.pptx
intro to assembly language.pptxintro to assembly language.pptx
intro to assembly language.pptx
 
lecture7.ppt
lecture7.pptlecture7.ppt
lecture7.ppt
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

ASSEMBLY LANGUAGE.pptx

  • 2.
  • 3. Introduction  Assembly language is a low-level programming language for a computer or other programmable device specific to a particular computer architecture in contrast to most high-level programming languages, which are generally portable across multiple systems.  Assembly language is converted into executable machine code by a utility program referred to as an assembler like NASM, MASM, etc.
  • 4. Introduction  Each personal computer has a microprocessor that manages the computer's arithmetical, logical, and control activities.  Each family of processors has its own set of instructions for handling various operations such as getting input from keyboard, displaying information on screen and performing various other jobs.  These set of instructions are called 'machine language instructions'.
  • 5. Introduction  A processor understands only machine language instructions, which are strings of 1's and 0’s.  However, machine language is too obscure and complex for using in software development.  the low-level assembly language is designed for a specific family of processors that represents various instructions in symbolic code and a more understandable form.
  • 6. Advantages of Assembly Language Having an understanding of assembly language makes one aware of −  How programs interface with OS, processor, and BIOS;  How data is represented in memory and other external devices;  How the processor accesses and executes instruction;  How instructions access and process data;  How a program accesses external devices.
  • 7. Advantages of Assembly Language Other advantages of using assembly language are −  It requires less memory and execution time;  It allows hardware-specific complex jobs in an easier way;  It is suitable for time-critical jobs;  It is most suitable for writing interrupt service routines and other memory resident programs.
  • 8. Basic Features of PC Hardware  The main internal hardware of a PC consists of processor, memory, and registers.  Registers are processor components that hold data and address. To execute a program, the system copies it from the external device into the internal memory. The processor executes the program instructions.  The fundamental unit of computer storage is a bit; it could be ON (1) or OFF (0) and a group of 8 related bits makes a byte on most of the modern computers.
  • 9. Basic Features of PC Hardware The processor supports the following data sizes −  Word: a 2-byte data item  Doubleword: a 4-byte (32 bit) data item  Quadword: an 8-byte (64 bit) data item  Paragraph: a 16-byte (128 bit) area  Kilobyte: 1024 bytes  Megabyte: 1,048,576 bytes
  • 10. Assembly Language Parts An assembly program can be divided into three sections − The data section, The bss section, and The text section.
  • 11. 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 syntax for declaring data section is − section.data
  • 12. bss section  The bss section is used for declaring variables.  The syntax for declaring bss section is − section.bss
  • 13. 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.  The syntax for declaring text section is − section.text global _start_start:
  • 14. 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 or, on the same line along with an instruction, like − add eax, ebx ; adds ebx to eax
  • 15. Assembly Language Statements Assembly language programs consist of three types of statements −  Executable instructions or instructions,  Assembler directives or pseudo-ops, and  Macros.
  • 16. Assembly Language Statements  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.
  • 17. Assembly Language Statements  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. .
  • 18. Syntax of Assembly Language Statements  Assembly language statements are entered one statement per line. Each statement follows the following format − [label] mnemonic [operands] [;comment]  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.
  • 19. Syntax of Assembly Language Statements
  • 20. Structure of a NASM Program  NASM is line-based. Most programs consist of directives followed by one or more sections.  Lines can have an optional label. Most lines have an instruction followed by zero or more operands.  This is the project webpage for the Netwide Assembler (NASM), an assembler for the x86 CPU architecture portable to nearly every modern platform, and with code generation for many platforms old and new
  • 21. Structure of a NASM Program
  • 22. 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.
  • 23. Memory Segments In the light of the above discussion, we can specify various memory segments as −  Data segment − It is represented by .data section and the .bss. The .data section is used to declare the memory region, where data elements are stored for the program. This section cannot be expanded after the data elements are declared, and it remains static throughout the program.  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.
  • 24. Memory Segments  Code segment − It is represented by .text section. This defines an area in memory that stores the instruction codes. This is also a fixed area.  Stack − This segment contains data values passed to functions and procedures within the program.
  • 25. TASM  Turbo Assembler (sometimes shortened to the name of the executable, TASM) is an assembler for software development published by Borland in 1989. It runs on and produces code for 16- or 32-bit x86 MS-DOS and compatible on Microsoft Windows
  • 26. MASM  The Microsoft Macro Assembler (MASM) is an x86 assembler that uses the Intel syntax for MS-DOS and Microsoft Windows.  Beginning with MASM 8.0, there are two versions of the assembler: One for 16-bit & 32-bit assembly sources, and another for 64-bit sources only.
  • 27.  Assemblers expect either the original syntax used in the Intel instruction set documentation - the Intel syntax - or the so-called AT&T syntax developed at the AT&T Bell Labs.  AT&T uses mov src, dest, Intel uses mov dest, src, amongst other differences.
  • 28.  Windows assemblers prefer Intel syntax (TASM, MASM), most Linux/UNIX assemblers use AT&T. NASM uses a variant of the Intel syntax.  Assemblers have their own syntax for directives affecting the assembly process, macros and comments. These usually differ from assembler to assembler
  • 29. QUIZ
  • 30. ______________1. What symbol defines Comments in Assembly Language? ______________2. This section is used to declare the memory region, where data elements are stored for the program. ______________3. This defines an area in memory that stores the instruction codes. This is also a fixed area. ______________4. Which part of the assembly language tells the kernel where the program execution begins? ______________5. Which tells the assembler about the various aspects of the assembly process. These are non-executable and do not generate machine language instructions. ______________6. What is the syntax in declaring data section? ______________7. This segment contains data values passed to functions and procedures within the program. ______________8. What is the fundamental unit of computer storage? _____9_______10. Advantages of understanding Assembly language
  • 31. 1. Semicolon 2. Data segment 3. Code segment 4. global _start, 5. assembler directives 6. section.data 7. Stack 8. bit  How programs interface with OS, processor, and BIOS;  How data is represented in memory and other external devices;  How the processor accesses and executes instruction;  How instructions access and process data;  How a program accesses external devices.