SlideShare a Scribd company logo
Microprocessor-Based Systems
Dr. Randa Elanwar
Lecture 6
Lecture Content
• Memory direct access
• 8086/8088 instruction set (Branching)
• Application examples
2Microprocessor-Based Systems Dr. Randa Elanwar
Memory segmentation, address decoding
and direct access
• According to the flow of instruction execution, the instructions
may be categorized as (i) Sequential control flow instructions
and (ii) Control transfer instructions.
• Sequential control flow instructions are the instructions which
after execution, transfer control to the next instruction
appearing immediately after it (in the sequence) in the
program.
• For example, the arithmetic, logical, data transfer and processor
control instructions are sequential control flow instructions.
• The control transfer instructions, on the other hand, transfer
control to some predefined address or the address somehow
specified in the instruction, after their execution.
• For example, INT, CALL , RET and JUMP instructions fall under
this category.
3Microprocessor-Based Systems Dr. Randa Elanwar
Memory segmentation, address decoding
and direct access
• In other words, Storage in memory is not done sequentially as
we have seen so far. Usually the coded instructions occupy
certain segments in the memory and the data occupy different
segments.
• Thus the microprocessor has to track the sequence of
instructions and access the data to operate on.
• Thus the Instruction pointer (IP) has to jump between different
locations to execute the instructions correctly.
• Instruction: Jump 3000:1253  IP jumps to the offset 1253 in
segment 3000
4Microprocessor-Based Systems Dr. Randa Elanwar
Memory segmentation, address decoding
and direct access
• Note that: Jump instruction is not saving the address of the current
instruction before it moves to the new destination meaning that it
cannot return back to the main program after ending the execution of
the subroutine.
• In such case we need an instruction that returns back if needed  CALL
instruction
5Microprocessor-Based Systems Dr. Randa Elanwar
JUMP Segment:Offset
Main program
instruction sequence
Memory segmentation, address decoding
and direct access
• When the microprocessor executes a CALL instruction, it will surely
jump to a different location other then the next memory location.
Thus it is important to save the return address in some
register/memory.
6Microprocessor-Based Systems Dr. Randa Elanwar
CALL 600
CALL 7000
Main program
Subroutine 1
Subroutine 2
2000:120
2000:123
2000:600
650
653
7000
.
.
.
.
.
.
.
.
0653
0123
Stack
(memory
locations)
Stack
Pointer
Memory segmentation, address decoding
and direct access
• If we have more than 1 CALL we need more than 1 register in the order of
execution. Since the excessive number of registers causes problem, thus it is
better to specify a part of the external memory as a STACK (pile of registers)
to save addresses and data from bottom to top in the order of call, then
return to origins from top to bottom in the order of call (i.e. first in-last out)
7Microprocessor-Based Systems Dr. Randa Elanwar
CALL 600
CALL 7000
Main program
Subroutine 1
Subroutine 2
2000:120
2000:123
2000:600
650
653
7000
.
.
.
.
.
.
.
.
0653
0123
Stack
(memory
locations)
Stack
Pointer
8086/8088 instruction set
Control transfer / Branching instructions
• The control transfer instructions transfer the flow of execution of
the program to a new address specified in the instruction directly
or indirectly.
• When this type of instruction is executed, the CS and IP registers
get loaded with new values of CS and IP corresponding to the
location where the flow of execution is going to be transferred.
• Depending upon the addressing modes, the CS may or may not be
modified. These type of instructions are classified in two types:
(a) Unconditional Control Transfer (Branch) Instructions,
(b) Conditional Control Transfer (Branch) Instructions
8Microprocessor-Based Systems Dr. Randa Elanwar
8086/8088 instruction set
Control transfer / Branching instructions
• Unconditional Control Transfer (Branch) Instructions: In case
of unconditional control transfer instructions, the execution
control is transferred to the specified location independent of
any status or condition. The CS and IP are unconditionally
modified to the new CS and IP.
• Conditional Control Transfer (Branch) Instructions: In the
conditional control transfer instructions, the control is
transferred to the specified location provided the result of the
previous operation satisfies a particular condition, otherwise,
the execution continues in normal flow sequence.
9Microprocessor-Based Systems Dr. Randa Elanwar
8086/8088 instruction set (CALL)
Unconditional Branch Instructions
• CALL: Unconditional Call: This instruction is used to call a subroutine
from a main program.
• In case of assembly language programming, the term procedure is
used interchangeably with subroutine. The address of the procedure
may be specified directly or indirectly depending upon the addressing
mode.
• There are again two types of procedures depending upon whether it
is available in the same segment (Near CALL, i.e ± 32K displacement)
or in another segment (Far CALL, i.e. anywhere outside the segment).
• The modes for them are respectively called as intrasegment and
intersegment addressing modes.
• On execution, this instruction stores the incremented IP (i.e. address
of the next instruction) and CS onto the stack along with the flags and
loads the CS and IP registers, respectively, with the segment and
offset addresses of the procedure to be called.
10Microprocessor-Based Systems Dr. Randa Elanwar
8086/8088 instruction set (RET)
• Unconditional Branch Instructions
• RET: Return from the Procedure: At each CALL instruction, the IP
and CS of the next instruction is pushed onto stack, before the
control is transferred to the procedure.
• At the end of the procedure, the RET instruction must be
executed.
• When it is executed, the previously stored content of IP and CS
along with flags are retrieved into the CS, IP and flag registers from
the stack and the execution of the main program continues
further.
11Microprocessor-Based Systems Dr. Randa Elanwar
8086/8088 instruction set (JMP)
• Unconditional Branch Instructions
• JMP: Unconditional lump: This instruction unconditionally
transfers the control of execution to the specified address using
an 8-bit or 16-bit displacement (intrasegment relative) or CS : IP
(intersegment) or label.
• No flags are affected by this instruction.
• Example:
MOV AX, 0005;
MOV BX, 0FF7H;
LABEL: OR BX, AX
AND DX, AX
JMP LABEL
12Microprocessor-Based Systems Dr. Randa Elanwar
8086/8088 instruction set (JMP)
• Conditional Branch Instructions
• When these instructions are executed, they transfer execution
control to the address specified relatively in the instruction,
provided the condition implicit in the code is satisfied,
otherwise, the execution continues sequentially.
• The conditions, here, means the status of condition code flags.
• The address has to be specified in the instruction relatively in
terms of displacement which must lie within -80H to 7FH from
the address of the branch instruction.
• In other words, only short jumps can be implemented using
conditional branch instructions. A label may represent the
displacement, if it lies within the above specified range.
13Microprocessor-Based Systems Dr. Randa Elanwar
8086/8088 instruction set (JMP)
14Microprocessor-Based Systems Dr. Randa Elanwar
Application Examples
• Write a program for the addition of a series of 8-bit numbers.
The series contains 100 (numbers).
15Microprocessor-Based Systems Dr. Randa Elanwar
Application Examples
• A program to find out the largest number from a given unordered
array of 8-bit numbers, stored in the locations starting from a
known address
16Microprocessor-Based Systems Dr. Randa Elanwar
Application Examples
• A program to find out the number of even and odd numbers
from a given series of 16-bit hexadecimal numbers
17Microprocessor-Based Systems Dr. Randa Elanwar
•The simplest logic to decide
whether a binary number is even
or odd, is to check the least
significant bit of the number.
•If the bit is zero, the number is
even, otherwise it is odd.
•Check the LSB by rotating the
number through carry flag, and
increment even or odd number
counter.
Application Examples
• Write an assembly language program to arrange a given series of
hexadecimal bytes in ascending order
• Solution
• There exist a large number of sorting algorithms. The algorithm used
here is called bubble sorting. The method of sorting is explained as
follows.
• To start with, the first number of the series is compared with the
second one. If the first number is greater than second, exchange their
positions in the series otherwise leave the positions unchanged.
• Then, compare the second number in the recent form of the series
with third and repeat the exchange part that you have carried out for
the first and the second number, and for all the remaining numbers
of the series.
18Microprocessor-Based Systems Dr. Randa Elanwar
Application Examples
• Repeat this procedure for the complete series (n-1) times. After (n-1)
iterations, you will get the largest number at the end of the series,
where n is the length of the series.
• Again start from the first address of the series. Repeat the same
procedure right from the first element to the last element.
• After (n-2) iterations you will get the second highest number at the
last but one place in the series. Continue this till the complete series
is arranged in ascending order.
• Let the series be as given:
19Microprocessor-Based Systems Dr. Randa Elanwar
Application Examples
20Microprocessor-Based Systems Dr. Randa Elanwar
•2nd largest number  4-2=2 operations
02, 19, 25, 53 1st operation
•3rd largest number  4-3 = 1
operations
•Instead of taking a variable count for
the external loop in the program like
(n-1), (n – 2), (n-3),...., etc. It is better to
take the count (n- 1) all the time for
simplicity.

More Related Content

PPTX
Microprocessors-based systems (under graduate course) Lecture 8 of 9
PPTX
Microprocessors-based systems (under graduate course) Lecture 3 of 9
PPTX
Microprocessors-based systems (under graduate course) Lecture 7 of 9
PPTX
Microprocessors-based systems (under graduate course) Lecture 4 of 9
PPTX
Microprocessors-based systems (under graduate course) Lecture 9 of 9
PPTX
Microprocessors-based systems (under graduate course) Lecture 1 of 9
PPTX
Microprocessors-based systems (under graduate course) Lecture 2 of 9
PPTX
Microprocessors-based systems (under graduate course) Lecture 5 of 9
Microprocessors-based systems (under graduate course) Lecture 8 of 9
Microprocessors-based systems (under graduate course) Lecture 3 of 9
Microprocessors-based systems (under graduate course) Lecture 7 of 9
Microprocessors-based systems (under graduate course) Lecture 4 of 9
Microprocessors-based systems (under graduate course) Lecture 9 of 9
Microprocessors-based systems (under graduate course) Lecture 1 of 9
Microprocessors-based systems (under graduate course) Lecture 2 of 9
Microprocessors-based systems (under graduate course) Lecture 5 of 9

What's hot (20)

PDF
PPTX
Timing Diagram.pptx
PPTX
DMA controller intel 8257
PPT
8085 intro
PPTX
Internal microprocessor architecture
PPTX
INTERRUPTS OF 8086 MICROPROCESSOR
PPTX
Dma and dma controller 8237
PPTX
advancsed microprocessor and interfacing
PPTX
Flag registers, addressing modes, instruction set
PDF
Unit II arm 7 Instruction Set
PPTX
Time delay programs and assembler directives 8086
PDF
Microprocessor & Interfacing (Part-2) By Er. Swapnil V. Kaware
PPTX
Arm modes
DOCX
PPT
PPT
PPT
8051 Programming Instruction Set
PPTX
flag register of 8086
PPT
8085 Microprocessor Architecture
PPSX
Microprocessor architecture II
Timing Diagram.pptx
DMA controller intel 8257
8085 intro
Internal microprocessor architecture
INTERRUPTS OF 8086 MICROPROCESSOR
Dma and dma controller 8237
advancsed microprocessor and interfacing
Flag registers, addressing modes, instruction set
Unit II arm 7 Instruction Set
Time delay programs and assembler directives 8086
Microprocessor & Interfacing (Part-2) By Er. Swapnil V. Kaware
Arm modes
8051 Programming Instruction Set
flag register of 8086
8085 Microprocessor Architecture
Microprocessor architecture II
Ad

Similar to Microprocessors-based systems (under graduate course) Lecture 6 of 9 (20)

PPTX
microprocessepjr chapter five-seven.pptx
PPTX
MES_MODULE 2.pptx
PDF
PPT
Data manipulation for Mechatronics System
PDF
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
PPTX
Computer Architecture Lecture slide 2. course se 222
PPTX
Control unit design
PPTX
module-3.pptx
PDF
CO Unit 3.pdf (Important chapter of coa)
PPTX
Chap6 procedures & macros
PPTX
COA SEMINAfrdreewqfeeerttfwsreeeeewwR.pptx
PPTX
Instructions, Instruction set and its types
PDF
8085 instructions and addressing modes
PPTX
computer organisation and architecture Module 2.pptx
PPTX
Computer Org Architecture_Lecture 08.pptx
PPTX
Lecture 10
PPTX
ARM introduction registers architectures
PPTX
Addressing Modes
PPT
PPT
instruction parallelism .ppt
microprocessepjr chapter five-seven.pptx
MES_MODULE 2.pptx
Data manipulation for Mechatronics System
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
Computer Architecture Lecture slide 2. course se 222
Control unit design
module-3.pptx
CO Unit 3.pdf (Important chapter of coa)
Chap6 procedures & macros
COA SEMINAfrdreewqfeeerttfwsreeeeewwR.pptx
Instructions, Instruction set and its types
8085 instructions and addressing modes
computer organisation and architecture Module 2.pptx
Computer Org Architecture_Lecture 08.pptx
Lecture 10
ARM introduction registers architectures
Addressing Modes
instruction parallelism .ppt
Ad

More from Randa Elanwar (20)

PDF
الجزء السادس ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
PDF
الجزء الخامس ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
PDF
الجزء الرابع ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
PDF
الجزء الثالث ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
PDF
الجزء الثاني ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
PDF
الجزء الأول ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
PDF
تدريب مدونة علماء مصر على الكتابة الفنية (الترجمة والتلخيص )_Pdf5of5
PDF
تدريب مدونة علماء مصر على الكتابة الفنية (القصة القصيرة والخاطرة والأخطاء ال...
PDF
تدريب مدونة علماء مصر على الكتابة الفنية (مقالات الموارد )_Pdf3of5
PDF
تدريب مدونة علماء مصر على الكتابة الفنية (المقالات الإخبارية )_Pdf2of5
PDF
تدريب مدونة علماء مصر على الكتابة الفنية (المقالات المبنية على البحث )_Pdf1of5
PDF
تعريف بمدونة علماء مصر ومحاور التدريب على الكتابة للمدونين
PDF
Entrepreneurship_who_is_your_customer_(arabic)_7of7
PDF
Entrepreneurship_who_is_your_customer_(arabic)_5of7
PDF
Entrepreneurship_who_is_your_customer_(arabic)_4of7
PDF
Entrepreneurship_who_is_your_customer_(arabic)_2of7
PDF
يوميات طالب بدرجة مشرف (Part 19 of 20)
PDF
يوميات طالب بدرجة مشرف (Part 18 of 20)
PDF
يوميات طالب بدرجة مشرف (Part 17 of 20)
PDF
يوميات طالب بدرجة مشرف (Part 16 of 20)
الجزء السادس ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
الجزء الخامس ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
الجزء الرابع ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
الجزء الثالث ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
الجزء الثاني ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
الجزء الأول ماذا ستقدم لعميلك ريادة الأعمال خطوة بخطوة
تدريب مدونة علماء مصر على الكتابة الفنية (الترجمة والتلخيص )_Pdf5of5
تدريب مدونة علماء مصر على الكتابة الفنية (القصة القصيرة والخاطرة والأخطاء ال...
تدريب مدونة علماء مصر على الكتابة الفنية (مقالات الموارد )_Pdf3of5
تدريب مدونة علماء مصر على الكتابة الفنية (المقالات الإخبارية )_Pdf2of5
تدريب مدونة علماء مصر على الكتابة الفنية (المقالات المبنية على البحث )_Pdf1of5
تعريف بمدونة علماء مصر ومحاور التدريب على الكتابة للمدونين
Entrepreneurship_who_is_your_customer_(arabic)_7of7
Entrepreneurship_who_is_your_customer_(arabic)_5of7
Entrepreneurship_who_is_your_customer_(arabic)_4of7
Entrepreneurship_who_is_your_customer_(arabic)_2of7
يوميات طالب بدرجة مشرف (Part 19 of 20)
يوميات طالب بدرجة مشرف (Part 18 of 20)
يوميات طالب بدرجة مشرف (Part 17 of 20)
يوميات طالب بدرجة مشرف (Part 16 of 20)

Recently uploaded (20)

PDF
My India Quiz Book_20210205121199924.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
20th Century Theater, Methods, History.pptx
PDF
HVAC Specification 2024 according to central public works department
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
IGGE1 Understanding the Self1234567891011
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
My India Quiz Book_20210205121199924.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
Chinmaya Tiranga quiz Grand Finale.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Paper A Mock Exam 9_ Attempt review.pdf.
20th Century Theater, Methods, History.pptx
HVAC Specification 2024 according to central public works department
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
IGGE1 Understanding the Self1234567891011
LDMMIA Reiki Yoga Finals Review Spring Summer
Indian roads congress 037 - 2012 Flexible pavement
Practical Manual AGRO-233 Principles and Practices of Natural Farming
AI-driven educational solutions for real-life interventions in the Philippine...
History, Philosophy and sociology of education (1).pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
B.Sc. DS Unit 2 Software Engineering.pptx

Microprocessors-based systems (under graduate course) Lecture 6 of 9

  • 2. Lecture Content • Memory direct access • 8086/8088 instruction set (Branching) • Application examples 2Microprocessor-Based Systems Dr. Randa Elanwar
  • 3. Memory segmentation, address decoding and direct access • According to the flow of instruction execution, the instructions may be categorized as (i) Sequential control flow instructions and (ii) Control transfer instructions. • Sequential control flow instructions are the instructions which after execution, transfer control to the next instruction appearing immediately after it (in the sequence) in the program. • For example, the arithmetic, logical, data transfer and processor control instructions are sequential control flow instructions. • The control transfer instructions, on the other hand, transfer control to some predefined address or the address somehow specified in the instruction, after their execution. • For example, INT, CALL , RET and JUMP instructions fall under this category. 3Microprocessor-Based Systems Dr. Randa Elanwar
  • 4. Memory segmentation, address decoding and direct access • In other words, Storage in memory is not done sequentially as we have seen so far. Usually the coded instructions occupy certain segments in the memory and the data occupy different segments. • Thus the microprocessor has to track the sequence of instructions and access the data to operate on. • Thus the Instruction pointer (IP) has to jump between different locations to execute the instructions correctly. • Instruction: Jump 3000:1253  IP jumps to the offset 1253 in segment 3000 4Microprocessor-Based Systems Dr. Randa Elanwar
  • 5. Memory segmentation, address decoding and direct access • Note that: Jump instruction is not saving the address of the current instruction before it moves to the new destination meaning that it cannot return back to the main program after ending the execution of the subroutine. • In such case we need an instruction that returns back if needed  CALL instruction 5Microprocessor-Based Systems Dr. Randa Elanwar JUMP Segment:Offset Main program instruction sequence
  • 6. Memory segmentation, address decoding and direct access • When the microprocessor executes a CALL instruction, it will surely jump to a different location other then the next memory location. Thus it is important to save the return address in some register/memory. 6Microprocessor-Based Systems Dr. Randa Elanwar CALL 600 CALL 7000 Main program Subroutine 1 Subroutine 2 2000:120 2000:123 2000:600 650 653 7000 . . . . . . . . 0653 0123 Stack (memory locations) Stack Pointer
  • 7. Memory segmentation, address decoding and direct access • If we have more than 1 CALL we need more than 1 register in the order of execution. Since the excessive number of registers causes problem, thus it is better to specify a part of the external memory as a STACK (pile of registers) to save addresses and data from bottom to top in the order of call, then return to origins from top to bottom in the order of call (i.e. first in-last out) 7Microprocessor-Based Systems Dr. Randa Elanwar CALL 600 CALL 7000 Main program Subroutine 1 Subroutine 2 2000:120 2000:123 2000:600 650 653 7000 . . . . . . . . 0653 0123 Stack (memory locations) Stack Pointer
  • 8. 8086/8088 instruction set Control transfer / Branching instructions • The control transfer instructions transfer the flow of execution of the program to a new address specified in the instruction directly or indirectly. • When this type of instruction is executed, the CS and IP registers get loaded with new values of CS and IP corresponding to the location where the flow of execution is going to be transferred. • Depending upon the addressing modes, the CS may or may not be modified. These type of instructions are classified in two types: (a) Unconditional Control Transfer (Branch) Instructions, (b) Conditional Control Transfer (Branch) Instructions 8Microprocessor-Based Systems Dr. Randa Elanwar
  • 9. 8086/8088 instruction set Control transfer / Branching instructions • Unconditional Control Transfer (Branch) Instructions: In case of unconditional control transfer instructions, the execution control is transferred to the specified location independent of any status or condition. The CS and IP are unconditionally modified to the new CS and IP. • Conditional Control Transfer (Branch) Instructions: In the conditional control transfer instructions, the control is transferred to the specified location provided the result of the previous operation satisfies a particular condition, otherwise, the execution continues in normal flow sequence. 9Microprocessor-Based Systems Dr. Randa Elanwar
  • 10. 8086/8088 instruction set (CALL) Unconditional Branch Instructions • CALL: Unconditional Call: This instruction is used to call a subroutine from a main program. • In case of assembly language programming, the term procedure is used interchangeably with subroutine. The address of the procedure may be specified directly or indirectly depending upon the addressing mode. • There are again two types of procedures depending upon whether it is available in the same segment (Near CALL, i.e ± 32K displacement) or in another segment (Far CALL, i.e. anywhere outside the segment). • The modes for them are respectively called as intrasegment and intersegment addressing modes. • On execution, this instruction stores the incremented IP (i.e. address of the next instruction) and CS onto the stack along with the flags and loads the CS and IP registers, respectively, with the segment and offset addresses of the procedure to be called. 10Microprocessor-Based Systems Dr. Randa Elanwar
  • 11. 8086/8088 instruction set (RET) • Unconditional Branch Instructions • RET: Return from the Procedure: At each CALL instruction, the IP and CS of the next instruction is pushed onto stack, before the control is transferred to the procedure. • At the end of the procedure, the RET instruction must be executed. • When it is executed, the previously stored content of IP and CS along with flags are retrieved into the CS, IP and flag registers from the stack and the execution of the main program continues further. 11Microprocessor-Based Systems Dr. Randa Elanwar
  • 12. 8086/8088 instruction set (JMP) • Unconditional Branch Instructions • JMP: Unconditional lump: This instruction unconditionally transfers the control of execution to the specified address using an 8-bit or 16-bit displacement (intrasegment relative) or CS : IP (intersegment) or label. • No flags are affected by this instruction. • Example: MOV AX, 0005; MOV BX, 0FF7H; LABEL: OR BX, AX AND DX, AX JMP LABEL 12Microprocessor-Based Systems Dr. Randa Elanwar
  • 13. 8086/8088 instruction set (JMP) • Conditional Branch Instructions • When these instructions are executed, they transfer execution control to the address specified relatively in the instruction, provided the condition implicit in the code is satisfied, otherwise, the execution continues sequentially. • The conditions, here, means the status of condition code flags. • The address has to be specified in the instruction relatively in terms of displacement which must lie within -80H to 7FH from the address of the branch instruction. • In other words, only short jumps can be implemented using conditional branch instructions. A label may represent the displacement, if it lies within the above specified range. 13Microprocessor-Based Systems Dr. Randa Elanwar
  • 14. 8086/8088 instruction set (JMP) 14Microprocessor-Based Systems Dr. Randa Elanwar
  • 15. Application Examples • Write a program for the addition of a series of 8-bit numbers. The series contains 100 (numbers). 15Microprocessor-Based Systems Dr. Randa Elanwar
  • 16. Application Examples • A program to find out the largest number from a given unordered array of 8-bit numbers, stored in the locations starting from a known address 16Microprocessor-Based Systems Dr. Randa Elanwar
  • 17. Application Examples • A program to find out the number of even and odd numbers from a given series of 16-bit hexadecimal numbers 17Microprocessor-Based Systems Dr. Randa Elanwar •The simplest logic to decide whether a binary number is even or odd, is to check the least significant bit of the number. •If the bit is zero, the number is even, otherwise it is odd. •Check the LSB by rotating the number through carry flag, and increment even or odd number counter.
  • 18. Application Examples • Write an assembly language program to arrange a given series of hexadecimal bytes in ascending order • Solution • There exist a large number of sorting algorithms. The algorithm used here is called bubble sorting. The method of sorting is explained as follows. • To start with, the first number of the series is compared with the second one. If the first number is greater than second, exchange their positions in the series otherwise leave the positions unchanged. • Then, compare the second number in the recent form of the series with third and repeat the exchange part that you have carried out for the first and the second number, and for all the remaining numbers of the series. 18Microprocessor-Based Systems Dr. Randa Elanwar
  • 19. Application Examples • Repeat this procedure for the complete series (n-1) times. After (n-1) iterations, you will get the largest number at the end of the series, where n is the length of the series. • Again start from the first address of the series. Repeat the same procedure right from the first element to the last element. • After (n-2) iterations you will get the second highest number at the last but one place in the series. Continue this till the complete series is arranged in ascending order. • Let the series be as given: 19Microprocessor-Based Systems Dr. Randa Elanwar
  • 20. Application Examples 20Microprocessor-Based Systems Dr. Randa Elanwar •2nd largest number  4-2=2 operations 02, 19, 25, 53 1st operation •3rd largest number  4-3 = 1 operations •Instead of taking a variable count for the external loop in the program like (n-1), (n – 2), (n-3),...., etc. It is better to take the count (n- 1) all the time for simplicity.