SlideShare a Scribd company logo
1 of 41
2nd Lecture
Instructions
 Instructions are sequence of bit that tells to processor or computer CPU to
perform a particular operations
 Instructions can also contain data to be used in the operation
Types of Instructions
 Data Movement/Transfer Instructions
 Arithmetic and logical instructions
 Program control instructions
 Input Output I/O Instructions
Data Transfer Instructions
 The instructions used to transfer data from one component to another
component during program execution
 All CPUs provide different instructions to transfer data
 A programmer can use these instructions to move data in CPU
 These instructions can also copy data from CPU to the main memory
 EXAMPLE
mov ax, 20
Arithmetic and logical instructions
 Addition subtraction multiplication and division are arithmetic operations
(+,-,*,/)
 Example:
Add ax,bx
Sub bx,ax
 Greater than, less than, equal to are logical operations (>,<,>=,<=,=,!=)
Program Control Instructions
 The instruction are used to change the sequence of instructions of a program
 These instructions transfer the execution control to a certain part of program
instead of next instruction
JUMP
JUMZ(jump if zero)
I/O Instructions
 Every CPU provides the operations of reading data from peripheral devices
and writing data to peripheral devices
Keyboard, mouse disk
Print “Hello World” on Screen
mov ah, 09h ; function to display message
mov dx, offset message ; offset of message string
int 21h ; DOS interrupt
mov ah, 4ch ; function terminate
int 21h ; DOS interrupt
ENDP
message db “Hello World$”
end main
3rd Lecture
Category of FLAG Register
 Status Flags
 Control Flags
Status Flag Registers
 There are 6 Status Flags in 8086 Processor
1) Carry Flag
2) Auxiliary Carry Flag
3) Parity Flag
4) Zero Flag
5) Overflow Flag
6) Sign Flag
Carry Flag Register
 If 9th bit generated, then the carry flag will be 1
 For example
1 0 0 1 0 0 0 1
1 0 0 1 0 0 0 1
1 0 0 1 0 0 0 1 0
Auxiliary Carry Flag Registers
 If the 4th bit contains carry, then AC is 1
 For Example
0 1 1 0 1 1 1 0
1 0 0 0 1 1 1 1
1 1 1 1 0 1 1 1
 4th bit generated carry so AC=1
Parity Flag Registers
 If number of ones in the bit are even, then parity flag is equal to one
 If number of ones in the bit are odd, then parity flag is equal to zero
 For example
0 1 1 0 1 1 1 0
0 0 0 0 1 1 1 1
0 1 1 1 0 1 1 1
0 1 1 0 1 1 1 0
1 0 0 0 1 1 1 1
1 1 1 1 0 1 1 1
The number of ones are even so PF=1 The number of ones are odd so PF=0
Zero Flag Registers
 If the answer is zero then ZF=1 otherwise ZF=0
Overflow Flag Registers
 If the bit are in the range -128 to 127 then OF=0 otherwise OF=1
 Example
 Bin=0110 1010, Hex = 6A
 𝟎 × 𝟐𝟕 + 𝟏 × 𝟐𝟔 + 𝟏 × 𝟐𝟓 + 𝟎 × 𝟐𝟒 + 𝟏 × 𝟐𝟑 + 𝟎 × 𝟐𝟐 + 𝟏 × 𝟐𝟏 + 𝟎 × 𝟐𝟎 = 𝟏𝟎𝟔
 Is in range so OF Register = 0
 Example
 Bin=1010 1010, Hex=AA
 𝟏 × 𝟐𝟕
+ 𝟎 × 𝟐𝟔
+ 𝟏 × 𝟐𝟓
+ 𝟎 × 𝟐𝟒
+ 𝟏 × 𝟐𝟑
+ 𝟎 × 𝟐𝟐
+ 𝟏 × 𝟐𝟏
+ 𝟎 × 𝟐𝟎
= 𝟏𝟕𝟎
 Is out of range so OF Register = 1
Sign Flag Register
 After any operation if the MSB(Most Significant Bit) is 1, then it indicates that
the number is negative
 And sign flag is set to 1
Lecture 4
Control Flag Registers
 There are 3 Control Flag in 8086 processors
1. Trap Flag
2. Interrupt Enable Flag
3. Direction Flag
Trap Flag (TF)
 It is used to set the trace mode i.e. start single stepping mode
 Here the microprocessor is interrupted after every instruction so that the
program can be debugged
Interrupt Enable Flag (IF)
 It is used to mask (disable) or unmask (enable) the INTR interrupt
 If users sets IF flag, the CPU will recognize external interrupt requests.
Clearing IF disables these interrupts
Direction Flag (DF)
 If this flag is set, SI and DI are in auto-decrementing mode in string operations
Addition, Subtraction, Multiplication,
Division
mov ax,7 ; ax = 7
add ax, 4 ; ax = ax+4
mov al,7 ; al = 7
mov bl,3 ; bl = 3
add al,bl ; bl = al+bl
Addition, Subtraction, Multiplication,
Division
mov al,7 ; al = 7
mov bl,3 ; bl = 3
sub al,bl ; bl = al-bl
mov ax,10 ; al = 10
mov bx,2 ; bl = 2
mul bx,ax ; mul = bl * al
Continue
Addition, Subtraction, Multiplication,
Division
mov al,10 ; al = 10
mov bl,2 ; bl = 2
div bl,al ; mul = bl / al
Continue
Basic Structure of Assembly Language
.mode small ; Define size of program
.stack 100h ; Define Storage of stack
.data ; Define Variable here
.code ; Write Assembly Program
Main Proc ; Write specific task/procedure here
.
.
.
Main End ; End procedure here
End Main ; End program here
Basic Structure of Assembly Language
.model small ; Model directive
Tiny  Data+Code Space:<=64kb
Small  Data+Code Space:Data<=64kb and code<=64kb
Medium  Data+Code Space:Data<=64kb and code<=Any size
Compact  Data+Code Space:Data<=Any size and Data<=64kb
Large  Data+Code Space:Data<=Any size and Data<=Any size
Huge  Data+Code Space:Data<=Any size and Data<=Any size
Continue
Data
Code
RAM
Write a program to print single character on
screen and multiple character on screen in
Assembly Language
.model small
.data
.code
main proc
mov dl, "A"
mov ah,2
int 21h
mov ah,4ch
int 21h
main endp
end main
Single Character Program
Write a program to print single character on
screen and multiple character on screen in
Assembly Language
.model small
.data
.code
main proc
mov dl, "M"
mov ah,2
int 21h
mov dl, "P"
mov ah,2
int 21h
mov dl, "G"
mov ah,2
int 21h
mov dl,"C"
mov ah,2
int 21h
mov ah,4ch
int 21h
main endp
end main
Multiple Character Program
Addressing Mode
 The way in which operands are specified
 Ways or model to access data is called addressing modes
 The term addressing modes refers to the way in which the operand of an
instruction is specified
 The operand may be mentioned directly or specified in register or memory
What is addressing mode?
 Addressing mode are different ways by which CPU can access data or operands
 They determine how to access a specific memory address
 To load any data from and to memory/register, MOV instruction is used
 The syntax of MOV instruction is:
 MOV destination, Source
Mov instruction addressing mode?
 The MOV instruction copies a byte or a word from source to destination
 Both operands should be of same type either byte or a word
 The syntax of MOV instruction is:
MOV destination, source
 Example
Mov ax,10
Types of addressing mode
 Register addressing mode
 Immediate addressing mode
 Direct addressing mode
 Register indirect addressing mode
 Based relative addressing mode
 Indexed relative addressing mode
 Based indexed addressing mode
Register addressing mode
 This mode involves the use of register
 These registers hold the operands
 This mode is very fast as compared to others because CPU doesn’t need to
access memory
 CPU can directly perform an operation through registers
 Example
 MOV AX,BX AX=BX
Immediate Addressing Mode
 In this mode, there are two operands
 One is a register and the other is a constant value
 The register comes quickly after the OP code
 Example
MOV AX, 405H AX=405H
MOV BX, 255 BX=255
Direct Addressing Mode
 Loads or stores the data from memory to register
 The instruction consists of a register and offset address
 Example
MOV AX, [ADDRESS]
Register Indirect Addressing Mode
 The register indirect addressing mode uses the offset address which resides in
one of these registers i.e. BX,SI,DI.
 The instruction consists of a register and offset address
 Example
MOV AX, [ADDRESS]
Based Relative Addressing Mode
 This addressing mode uses a base register either BX or BP and a displacement
value to calculate physical address
 Physical Address = Segment Register (Shifted to left by 1) + Effective address
 Example
MOV [AX+4], BX
Indexed Relative Addressing Mode
 This addressing mode is same as the based relative addressing mode
 The only difference is it uses DI and SI registers instead of BX and BP registers
 Example
MOV [DI]+12, BX
Based Indexed Addressing Mode
 The based indexed addressing mode is actually a combination of based
relative addressing mode and indexed relative addressing mode
 It uses one base register (BX,BP) and one index register (SI,DI)
 Example
MOV AX,[BX+SI+10]
How to take input and output in
assembly language
.mode small
.data
.code
main proc
Mov ah, 1 : 1 is used for output
Int 21h
Mov dl, al
Mov ah, 2 :2 is used for output
Int 21h
main endp

More Related Content

Similar to Assembly language.pptx

Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Akhila Rahul
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Siraj Ahmed
 
Intrl 8086 instruction set
Intrl 8086 instruction setIntrl 8086 instruction set
Intrl 8086 instruction setedwardkiwalabye1
 
address5ng modes.pptx IS A GOOD MATERIAL
address5ng  modes.pptx IS A GOOD MATERIALaddress5ng  modes.pptx IS A GOOD MATERIAL
address5ng modes.pptx IS A GOOD MATERIALDrkoteswararaoseelam
 
8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd year8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd yearBharghavteja1
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086Mahalakshmiv11
 
8086 instruction set (with simulator)
8086 instruction set (with simulator)8086 instruction set (with simulator)
8086 instruction set (with simulator)Aswini Dharmaraj
 
N_Asm Assembly addressing modes (sol)
N_Asm Assembly addressing modes (sol)N_Asm Assembly addressing modes (sol)
N_Asm Assembly addressing modes (sol)Selomon birhane
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086sravanithonta79
 
system software 16 marks
system software 16 markssystem software 16 marks
system software 16 marksvvcetit
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction setStefan Oprea
 
Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)Tish997
 
6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptxHebaEng
 

Similar to Assembly language.pptx (20)

Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .
 
Intrl 8086 instruction set
Intrl 8086 instruction setIntrl 8086 instruction set
Intrl 8086 instruction set
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
address5ng modes.pptx IS A GOOD MATERIAL
address5ng  modes.pptx IS A GOOD MATERIALaddress5ng  modes.pptx IS A GOOD MATERIAL
address5ng modes.pptx IS A GOOD MATERIAL
 
8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd year8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd year
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
8086 instruction set (with simulator)
8086 instruction set (with simulator)8086 instruction set (with simulator)
8086 instruction set (with simulator)
 
N_Asm Assembly addressing modes (sol)
N_Asm Assembly addressing modes (sol)N_Asm Assembly addressing modes (sol)
N_Asm Assembly addressing modes (sol)
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086
 
Register & flags
Register & flagsRegister & flags
Register & flags
 
intel 8086 introduction
intel 8086 introductionintel 8086 introduction
intel 8086 introduction
 
system software 16 marks
system software 16 markssystem software 16 marks
system software 16 marks
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
Al2ed chapter4
Al2ed chapter4Al2ed chapter4
Al2ed chapter4
 
Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)
 
6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx
 
Chapter 3 programming concepts-ii
Chapter 3  programming concepts-iiChapter 3  programming concepts-ii
Chapter 3 programming concepts-ii
 
Coal (1)
Coal (1)Coal (1)
Coal (1)
 

More from ShaistaRiaz4

Algorithms Analysis.pdf
Algorithms Analysis.pdfAlgorithms Analysis.pdf
Algorithms Analysis.pdfShaistaRiaz4
 
Case Study(Analysis of Algorithm.pdf
Case Study(Analysis of Algorithm.pdfCase Study(Analysis of Algorithm.pdf
Case Study(Analysis of Algorithm.pdfShaistaRiaz4
 
02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).pptShaistaRiaz4
 
01_Introduction.ppt
01_Introduction.ppt01_Introduction.ppt
01_Introduction.pptShaistaRiaz4
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptxShaistaRiaz4
 
02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).pptShaistaRiaz4
 
01_Introduction.ppt
01_Introduction.ppt01_Introduction.ppt
01_Introduction.pptShaistaRiaz4
 
Bisma Zahid (1)-1.pdf
Bisma Zahid (1)-1.pdfBisma Zahid (1)-1.pdf
Bisma Zahid (1)-1.pdfShaistaRiaz4
 
MNS Lecture 1.pptx
MNS Lecture 1.pptxMNS Lecture 1.pptx
MNS Lecture 1.pptxShaistaRiaz4
 
Lecture+9+-+Dynamic+Programming+I.pdf
Lecture+9+-+Dynamic+Programming+I.pdfLecture+9+-+Dynamic+Programming+I.pdf
Lecture+9+-+Dynamic+Programming+I.pdfShaistaRiaz4
 
Lecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdfLecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdfShaistaRiaz4
 
oppositional-defiant-disorder495.pptx
oppositional-defiant-disorder495.pptxoppositional-defiant-disorder495.pptx
oppositional-defiant-disorder495.pptxShaistaRiaz4
 
Development Education.pptx
Development Education.pptxDevelopment Education.pptx
Development Education.pptxShaistaRiaz4
 
WISC-IV Introduction Handout.ppt
WISC-IV Introduction Handout.pptWISC-IV Introduction Handout.ppt
WISC-IV Introduction Handout.pptShaistaRiaz4
 
Summary and Evaluation of the Book.pptx
Summary and Evaluation of the Book.pptxSummary and Evaluation of the Book.pptx
Summary and Evaluation of the Book.pptxShaistaRiaz4
 
MH&PSS for L&NFBED 7-8 April 2020.ppt
MH&PSS for L&NFBED 7-8 April 2020.pptMH&PSS for L&NFBED 7-8 April 2020.ppt
MH&PSS for L&NFBED 7-8 April 2020.pptShaistaRiaz4
 
Intro_to_Literature_2012-2013-1.ppt
Intro_to_Literature_2012-2013-1.pptIntro_to_Literature_2012-2013-1.ppt
Intro_to_Literature_2012-2013-1.pptShaistaRiaz4
 
Coping strategies-Farzana Razi.ppt
Coping strategies-Farzana Razi.pptCoping strategies-Farzana Razi.ppt
Coping strategies-Farzana Razi.pptShaistaRiaz4
 

More from ShaistaRiaz4 (20)

Lecture3(b).pdf
Lecture3(b).pdfLecture3(b).pdf
Lecture3(b).pdf
 
Algorithms Analysis.pdf
Algorithms Analysis.pdfAlgorithms Analysis.pdf
Algorithms Analysis.pdf
 
Case Study(Analysis of Algorithm.pdf
Case Study(Analysis of Algorithm.pdfCase Study(Analysis of Algorithm.pdf
Case Study(Analysis of Algorithm.pdf
 
02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt
 
01_Introduction.ppt
01_Introduction.ppt01_Introduction.ppt
01_Introduction.ppt
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptx
 
02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt02_Computer-Evolution(1).ppt
02_Computer-Evolution(1).ppt
 
01_Introduction.ppt
01_Introduction.ppt01_Introduction.ppt
01_Introduction.ppt
 
Bisma Zahid (1)-1.pdf
Bisma Zahid (1)-1.pdfBisma Zahid (1)-1.pdf
Bisma Zahid (1)-1.pdf
 
MNS Lecture 1.pptx
MNS Lecture 1.pptxMNS Lecture 1.pptx
MNS Lecture 1.pptx
 
Plan (2).pptx
Plan (2).pptxPlan (2).pptx
Plan (2).pptx
 
Lecture+9+-+Dynamic+Programming+I.pdf
Lecture+9+-+Dynamic+Programming+I.pdfLecture+9+-+Dynamic+Programming+I.pdf
Lecture+9+-+Dynamic+Programming+I.pdf
 
Lecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdfLecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdf
 
oppositional-defiant-disorder495.pptx
oppositional-defiant-disorder495.pptxoppositional-defiant-disorder495.pptx
oppositional-defiant-disorder495.pptx
 
Development Education.pptx
Development Education.pptxDevelopment Education.pptx
Development Education.pptx
 
WISC-IV Introduction Handout.ppt
WISC-IV Introduction Handout.pptWISC-IV Introduction Handout.ppt
WISC-IV Introduction Handout.ppt
 
Summary and Evaluation of the Book.pptx
Summary and Evaluation of the Book.pptxSummary and Evaluation of the Book.pptx
Summary and Evaluation of the Book.pptx
 
MH&PSS for L&NFBED 7-8 April 2020.ppt
MH&PSS for L&NFBED 7-8 April 2020.pptMH&PSS for L&NFBED 7-8 April 2020.ppt
MH&PSS for L&NFBED 7-8 April 2020.ppt
 
Intro_to_Literature_2012-2013-1.ppt
Intro_to_Literature_2012-2013-1.pptIntro_to_Literature_2012-2013-1.ppt
Intro_to_Literature_2012-2013-1.ppt
 
Coping strategies-Farzana Razi.ppt
Coping strategies-Farzana Razi.pptCoping strategies-Farzana Razi.ppt
Coping strategies-Farzana Razi.ppt
 

Recently uploaded

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 

Recently uploaded (20)

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

Assembly language.pptx

  • 2. Instructions  Instructions are sequence of bit that tells to processor or computer CPU to perform a particular operations  Instructions can also contain data to be used in the operation
  • 3. Types of Instructions  Data Movement/Transfer Instructions  Arithmetic and logical instructions  Program control instructions  Input Output I/O Instructions
  • 4. Data Transfer Instructions  The instructions used to transfer data from one component to another component during program execution  All CPUs provide different instructions to transfer data  A programmer can use these instructions to move data in CPU  These instructions can also copy data from CPU to the main memory  EXAMPLE mov ax, 20
  • 5. Arithmetic and logical instructions  Addition subtraction multiplication and division are arithmetic operations (+,-,*,/)  Example: Add ax,bx Sub bx,ax  Greater than, less than, equal to are logical operations (>,<,>=,<=,=,!=)
  • 6. Program Control Instructions  The instruction are used to change the sequence of instructions of a program  These instructions transfer the execution control to a certain part of program instead of next instruction JUMP JUMZ(jump if zero)
  • 7. I/O Instructions  Every CPU provides the operations of reading data from peripheral devices and writing data to peripheral devices Keyboard, mouse disk
  • 8. Print “Hello World” on Screen mov ah, 09h ; function to display message mov dx, offset message ; offset of message string int 21h ; DOS interrupt mov ah, 4ch ; function terminate int 21h ; DOS interrupt ENDP message db “Hello World$” end main
  • 10. Category of FLAG Register  Status Flags  Control Flags
  • 11. Status Flag Registers  There are 6 Status Flags in 8086 Processor 1) Carry Flag 2) Auxiliary Carry Flag 3) Parity Flag 4) Zero Flag 5) Overflow Flag 6) Sign Flag
  • 12. Carry Flag Register  If 9th bit generated, then the carry flag will be 1  For example 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 0
  • 13. Auxiliary Carry Flag Registers  If the 4th bit contains carry, then AC is 1  For Example 0 1 1 0 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1  4th bit generated carry so AC=1
  • 14. Parity Flag Registers  If number of ones in the bit are even, then parity flag is equal to one  If number of ones in the bit are odd, then parity flag is equal to zero  For example 0 1 1 0 1 1 1 0 0 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 0 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1 The number of ones are even so PF=1 The number of ones are odd so PF=0
  • 15. Zero Flag Registers  If the answer is zero then ZF=1 otherwise ZF=0
  • 16. Overflow Flag Registers  If the bit are in the range -128 to 127 then OF=0 otherwise OF=1  Example  Bin=0110 1010, Hex = 6A  𝟎 × 𝟐𝟕 + 𝟏 × 𝟐𝟔 + 𝟏 × 𝟐𝟓 + 𝟎 × 𝟐𝟒 + 𝟏 × 𝟐𝟑 + 𝟎 × 𝟐𝟐 + 𝟏 × 𝟐𝟏 + 𝟎 × 𝟐𝟎 = 𝟏𝟎𝟔  Is in range so OF Register = 0  Example  Bin=1010 1010, Hex=AA  𝟏 × 𝟐𝟕 + 𝟎 × 𝟐𝟔 + 𝟏 × 𝟐𝟓 + 𝟎 × 𝟐𝟒 + 𝟏 × 𝟐𝟑 + 𝟎 × 𝟐𝟐 + 𝟏 × 𝟐𝟏 + 𝟎 × 𝟐𝟎 = 𝟏𝟕𝟎  Is out of range so OF Register = 1
  • 17. Sign Flag Register  After any operation if the MSB(Most Significant Bit) is 1, then it indicates that the number is negative  And sign flag is set to 1
  • 19. Control Flag Registers  There are 3 Control Flag in 8086 processors 1. Trap Flag 2. Interrupt Enable Flag 3. Direction Flag
  • 20. Trap Flag (TF)  It is used to set the trace mode i.e. start single stepping mode  Here the microprocessor is interrupted after every instruction so that the program can be debugged
  • 21. Interrupt Enable Flag (IF)  It is used to mask (disable) or unmask (enable) the INTR interrupt  If users sets IF flag, the CPU will recognize external interrupt requests. Clearing IF disables these interrupts
  • 22. Direction Flag (DF)  If this flag is set, SI and DI are in auto-decrementing mode in string operations
  • 23. Addition, Subtraction, Multiplication, Division mov ax,7 ; ax = 7 add ax, 4 ; ax = ax+4 mov al,7 ; al = 7 mov bl,3 ; bl = 3 add al,bl ; bl = al+bl
  • 24. Addition, Subtraction, Multiplication, Division mov al,7 ; al = 7 mov bl,3 ; bl = 3 sub al,bl ; bl = al-bl mov ax,10 ; al = 10 mov bx,2 ; bl = 2 mul bx,ax ; mul = bl * al Continue
  • 25. Addition, Subtraction, Multiplication, Division mov al,10 ; al = 10 mov bl,2 ; bl = 2 div bl,al ; mul = bl / al Continue
  • 26. Basic Structure of Assembly Language .mode small ; Define size of program .stack 100h ; Define Storage of stack .data ; Define Variable here .code ; Write Assembly Program Main Proc ; Write specific task/procedure here . . . Main End ; End procedure here End Main ; End program here
  • 27. Basic Structure of Assembly Language .model small ; Model directive Tiny  Data+Code Space:<=64kb Small  Data+Code Space:Data<=64kb and code<=64kb Medium  Data+Code Space:Data<=64kb and code<=Any size Compact  Data+Code Space:Data<=Any size and Data<=64kb Large  Data+Code Space:Data<=Any size and Data<=Any size Huge  Data+Code Space:Data<=Any size and Data<=Any size Continue Data Code RAM
  • 28. Write a program to print single character on screen and multiple character on screen in Assembly Language .model small .data .code main proc mov dl, "A" mov ah,2 int 21h mov ah,4ch int 21h main endp end main Single Character Program
  • 29. Write a program to print single character on screen and multiple character on screen in Assembly Language .model small .data .code main proc mov dl, "M" mov ah,2 int 21h mov dl, "P" mov ah,2 int 21h mov dl, "G" mov ah,2 int 21h mov dl,"C" mov ah,2 int 21h mov ah,4ch int 21h main endp end main Multiple Character Program
  • 30. Addressing Mode  The way in which operands are specified  Ways or model to access data is called addressing modes  The term addressing modes refers to the way in which the operand of an instruction is specified  The operand may be mentioned directly or specified in register or memory
  • 31. What is addressing mode?  Addressing mode are different ways by which CPU can access data or operands  They determine how to access a specific memory address  To load any data from and to memory/register, MOV instruction is used  The syntax of MOV instruction is:  MOV destination, Source
  • 32. Mov instruction addressing mode?  The MOV instruction copies a byte or a word from source to destination  Both operands should be of same type either byte or a word  The syntax of MOV instruction is: MOV destination, source  Example Mov ax,10
  • 33. Types of addressing mode  Register addressing mode  Immediate addressing mode  Direct addressing mode  Register indirect addressing mode  Based relative addressing mode  Indexed relative addressing mode  Based indexed addressing mode
  • 34. Register addressing mode  This mode involves the use of register  These registers hold the operands  This mode is very fast as compared to others because CPU doesn’t need to access memory  CPU can directly perform an operation through registers  Example  MOV AX,BX AX=BX
  • 35. Immediate Addressing Mode  In this mode, there are two operands  One is a register and the other is a constant value  The register comes quickly after the OP code  Example MOV AX, 405H AX=405H MOV BX, 255 BX=255
  • 36. Direct Addressing Mode  Loads or stores the data from memory to register  The instruction consists of a register and offset address  Example MOV AX, [ADDRESS]
  • 37. Register Indirect Addressing Mode  The register indirect addressing mode uses the offset address which resides in one of these registers i.e. BX,SI,DI.  The instruction consists of a register and offset address  Example MOV AX, [ADDRESS]
  • 38. Based Relative Addressing Mode  This addressing mode uses a base register either BX or BP and a displacement value to calculate physical address  Physical Address = Segment Register (Shifted to left by 1) + Effective address  Example MOV [AX+4], BX
  • 39. Indexed Relative Addressing Mode  This addressing mode is same as the based relative addressing mode  The only difference is it uses DI and SI registers instead of BX and BP registers  Example MOV [DI]+12, BX
  • 40. Based Indexed Addressing Mode  The based indexed addressing mode is actually a combination of based relative addressing mode and indexed relative addressing mode  It uses one base register (BX,BP) and one index register (SI,DI)  Example MOV AX,[BX+SI+10]
  • 41. How to take input and output in assembly language .mode small .data .code main proc Mov ah, 1 : 1 is used for output Int 21h Mov dl, al Mov ah, 2 :2 is used for output Int 21h main endp