SlideShare a Scribd company logo
ASSEMBLY LANGUAGE
Assembly language
Assembly language
 Slightly higher-level language
 Readability of instructions is better than machine
language
 One-to-one correspondence with machine language
instructions
Assemblers translate assembly to machine code
Compilers translate high-level programs to machine code
Translating Languages
English: D is assigned the sum of A times B plus 10.
High-Level Language: D = A * B + 10
Intel Assembly Language:
mov eax, A
mul B
add eax, 10
mov D, eax
Intel Machine Language:
A1 00404000
F7 25 00404004
83 C0 0A
A3 00404008
A statement in a high-level language is translated
typically into several machine-level instructions
Flags
The FLAGs register is the status register in Intel x86 microprocessors that
contains the current state of the processor.
 Types of flags ?
 Carry flag
 Zero flag
 Parity flag
 Over flow flag
 Sign flag
Registers
 General registers,
 Control registers, and
 Segment registers.
The general registers are further divided into the following groups −
 Data registers,
 Pointer registers, and
 Index registers.
Data Registers
 AX is the primary accumulator; it is used in input/output and most arithmetic
instructions. For example, in multiplication operation, one operand is stored in
EAX or AX or AL register according to the size of the operand.
 BX is known as the base register, as it could be used in indexed addressing.
 CX is known as the count register, as the ECX, CX registers store the loop count
in iterative operations.
 DX is known as the data register. It is also used in input/output operations. It is
also used with AX register along with DX for multiply and divide operations
involving large values
C++ To Assembly Example
int num1=5;
int num2=6;
If (num1>=num2)
mov ax, 5
mov bx, 6
cmp ax, bx
Type of Addressing
 Direct Addressing
 Indirect Addressing
Direct Addressing
Direct addressing:
Code: data store in word form:
 Mov ax , [num1]
 Mov ax , [num1+2 ]
DIRECT ADDRESSING
SIZE MISMATCH ERRORS
DIRECT ADDRESSING
DIRECT ADDRESSING
DIRECT ADDRESSING
Indirect Addressing
Indirect addressing:
Mov bx , num1
Mov ax , [bx]
Mov ax , [bx+2]
INDIRECT ADDRESSING
INDIRECT ADDRESSING
INDIRECT ADDRESSING
Jumps
 Conditional jumps
This is performed by a set of jump instructions j<condition> depending upon
the condition.
 Unconditional jumps?
This is performed by the JMP instruction. Conditional execution often involves
a transfer of control to the address of an instruction that does not follow the
currently executing instruction.
CONDITIONAL JUMPS
UNCONDITIONAL JUMP
SORTING EXAMPLE
Assembly language (Example with mapping from C++ to Assembly)

More Related Content

PDF
Open stack
PPTX
Aspectos de diseno
PPTX
Operating System Concepts_1.pptx
PDF
IBM MQ - High Availability and Disaster Recovery
PPTX
Cloud service models
PDF
UNYOUG - APEX 19.2 New Features
PPTX
Introduction to Parallel and Distributed Computing
PDF
Introduction to Oracle Cloud Infrastructure Services
Open stack
Aspectos de diseno
Operating System Concepts_1.pptx
IBM MQ - High Availability and Disaster Recovery
Cloud service models
UNYOUG - APEX 19.2 New Features
Introduction to Parallel and Distributed Computing
Introduction to Oracle Cloud Infrastructure Services

What's hot (20)

PPTX
Network virtualization
PPTX
Data center Technologies
 
PDF
IBM general parallel file system - introduction
PDF
MQ Guide France - IBM MQ and Containers
PPTX
Getting started with azure event hubs and stream analytics services
PPTX
Cloud Computing - Economics
PPTX
Oracle GoldenGate Performance Tuning
PDF
Multicore Computers
PPTX
Comparison of dbms
PDF
Oracle on Azure IaaS 2023 Update
PPTX
2. Distributed Systems Hardware & Software concepts
PPT
Server Side Technologies
PPTX
Virtualization & cloud computing
PDF
Concurrency vs parallelism
PPTX
Network Virtualization
PDF
Operating system structures
PPTX
Introduction to public cloud
PPTX
Hardware virtualization basic
PDF
Microservices with Kafka Ecosystem
Network virtualization
Data center Technologies
 
IBM general parallel file system - introduction
MQ Guide France - IBM MQ and Containers
Getting started with azure event hubs and stream analytics services
Cloud Computing - Economics
Oracle GoldenGate Performance Tuning
Multicore Computers
Comparison of dbms
Oracle on Azure IaaS 2023 Update
2. Distributed Systems Hardware & Software concepts
Server Side Technologies
Virtualization & cloud computing
Concurrency vs parallelism
Network Virtualization
Operating system structures
Introduction to public cloud
Hardware virtualization basic
Microservices with Kafka Ecosystem
Ad

Similar to Assembly language (Example with mapping from C++ to Assembly) (20)

PPTX
Assembly language (Example with mapping from C++ to Assembly)
PPT
Assembly language
PPTX
Coal (1)
PPT
Assembler
PPT
Wk1to4
PDF
Assembly language part I
PDF
Assembly language part I
PPTX
Introduction of 8086 micro processor .
PPTX
Assembly language.pptx
PPTX
2ProgrammerViewOfComputerAndInstructionCycle.pptx
PPT
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
PPTX
Intro to reverse engineering owasp
PPT
data transfers, addressing and arithmetic
PPTX
The 8051 microcontroller
PPTX
Addressing modes
PPT
Assembler
PPT
Unit 3 assembler and processor
PPT
Types of instructions
PPTX
[ASM]Lab4
Assembly language (Example with mapping from C++ to Assembly)
Assembly language
Coal (1)
Assembler
Wk1to4
Assembly language part I
Assembly language part I
Introduction of 8086 micro processor .
Assembly language.pptx
2ProgrammerViewOfComputerAndInstructionCycle.pptx
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Intro to reverse engineering owasp
data transfers, addressing and arithmetic
The 8051 microcontroller
Addressing modes
Assembler
Unit 3 assembler and processor
Types of instructions
[ASM]Lab4
Ad

More from Tish997 (9)

PPTX
2 3 Trees Algorithm - Data Structure
PPTX
Hermes 2.1 Ransomware (Malware)
PPTX
JS Bank (Evaluation of the Performance Appraisal System)
PPTX
Energy Core Ecx - 2000 Processor
PPT
Transition words - English
PPT
Parts of Report - English Presentation
PPTX
Theory of expectancy
PPTX
Online vehicle showroom DB project
PPTX
Bayes rule (Bayes Law)
2 3 Trees Algorithm - Data Structure
Hermes 2.1 Ransomware (Malware)
JS Bank (Evaluation of the Performance Appraisal System)
Energy Core Ecx - 2000 Processor
Transition words - English
Parts of Report - English Presentation
Theory of expectancy
Online vehicle showroom DB project
Bayes rule (Bayes Law)

Recently uploaded (20)

PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Business Ethics Teaching Materials for college
PPTX
Cell Types and Its function , kingdom of life
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Basic Mud Logging Guide for educational purpose
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
01-Introduction-to-Information-Management.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Institutional Correction lecture only . . .
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
RMMM.pdf make it easy to upload and study
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
2.FourierTransform-ShortQuestionswithAnswers.pdf
Business Ethics Teaching Materials for college
Cell Types and Its function , kingdom of life
Final Presentation General Medicine 03-08-2024.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Basic Mud Logging Guide for educational purpose
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
01-Introduction-to-Information-Management.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Institutional Correction lecture only . . .
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Renaissance Architecture: A Journey from Faith to Humanism
RMMM.pdf make it easy to upload and study

Assembly language (Example with mapping from C++ to Assembly)

  • 2. Assembly language Assembly language  Slightly higher-level language  Readability of instructions is better than machine language  One-to-one correspondence with machine language instructions Assemblers translate assembly to machine code Compilers translate high-level programs to machine code
  • 3. Translating Languages English: D is assigned the sum of A times B plus 10. High-Level Language: D = A * B + 10 Intel Assembly Language: mov eax, A mul B add eax, 10 mov D, eax Intel Machine Language: A1 00404000 F7 25 00404004 83 C0 0A A3 00404008 A statement in a high-level language is translated typically into several machine-level instructions
  • 4. Flags The FLAGs register is the status register in Intel x86 microprocessors that contains the current state of the processor.  Types of flags ?  Carry flag  Zero flag  Parity flag  Over flow flag  Sign flag
  • 5. Registers  General registers,  Control registers, and  Segment registers. The general registers are further divided into the following groups −  Data registers,  Pointer registers, and  Index registers.
  • 6. Data Registers  AX is the primary accumulator; it is used in input/output and most arithmetic instructions. For example, in multiplication operation, one operand is stored in EAX or AX or AL register according to the size of the operand.  BX is known as the base register, as it could be used in indexed addressing.  CX is known as the count register, as the ECX, CX registers store the loop count in iterative operations.  DX is known as the data register. It is also used in input/output operations. It is also used with AX register along with DX for multiply and divide operations involving large values
  • 7. C++ To Assembly Example int num1=5; int num2=6; If (num1>=num2) mov ax, 5 mov bx, 6 cmp ax, bx
  • 8. Type of Addressing  Direct Addressing  Indirect Addressing
  • 9. Direct Addressing Direct addressing: Code: data store in word form:  Mov ax , [num1]  Mov ax , [num1+2 ]
  • 14. Indirect Addressing Indirect addressing: Mov bx , num1 Mov ax , [bx] Mov ax , [bx+2]
  • 18. Jumps  Conditional jumps This is performed by a set of jump instructions j<condition> depending upon the condition.  Unconditional jumps? This is performed by the JMP instruction. Conditional execution often involves a transfer of control to the address of an instruction that does not follow the currently executing instruction.