Introduction to Computer Engineering by Richard E. Haskell Branching Instructions Module M17.2 Section 11.1.

Slides:



Advertisements
Similar presentations
Jump Condition.
Advertisements

Flow of Control Instruction/Control structure Looping structure Looping structure Branching structure Branching structure For assembly language program.
CSC 221 Computer Organization and Assembly Language Lecture 21: Conditional and Block Structures: Assembly Programs.
Introduction to Computer Engineering by Richard E. Haskell BCD Arithmetic Module M16.5 Section 10.4.
Introduction to Computer Engineering by Richard E. Haskell Basic Digital Design Module M1.2 Section 3.2.
Introduction to Computer Engineering by Richard E. Haskell Multiplication and Division Instructions Module M16.4 Section 10.4.
Writing and reading files. Creating a file on a disk Get a file handle from system Use INT 21H function 3C to create a directory entry for the file Use.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Assembly Language for Intel-Based Computers
Introduction to Computer Engineering by Richard E. Haskell Number Systems Module M3.1 Sections
CS2422 Assembly Language & System Programming October 17, 2006.
Introduction to Computer Engineering by Richard E. Haskell Register Indirect Addressing Module M18.2 Section 12.3.
Introduction to Computer Engineering by Richard E. Haskell 8086 Tutor Monitor Module M14.3 Section 9.3 Appendix B.
Flow Control Instructions
Introduction to Computer Engineering by Richard E. Haskell Addition and Subtraction Instructions Module M16.3 Section 10.4.
Introduction to Computer Engineering by Richard E. Haskell Logical Instructions Module M16.6 Section 10.5.
Introduction to Computer Engineering by Richard E. Haskell 8086 Memory Module M14.1 Sections 9.3.
Review Questions Chapters What TUTOR command is used to enter a string of ASCII bytes into memory? /MA 2.What are the names of the 8086 index.
Introduction to Computer Engineering by Richard E. Haskell Shift and Rotate Instructions Module M16.2 Section 10.3.
Conditional Processing If … then … else While … do; Repeat … until.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7)
Lecture 3 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Arithmetic Flags and Instructions
(Flow Control Instructions)
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 5 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
ACOE251Sofware Constructs1 Software Constructs What they are …..
EEL 3801 Part V Conditional Processing. This section explains how to implement conditional processing in Assembly Language for the 8086/8088 processors.
LEA instruction The LEA instruction can be used to get the offset address of a variable Example ORG 100h MOV AL, VAR1 ; check value of VAR1 by moving it.
Microprocessor MA Rahim Khan Computer Engineering and Networks Department.
COMP 2003: Assembly Language and Digital Logic Chapter 2: Flags and Instructions Notes by Neil Dickson.
Comparison Instructions Test instruction –Performs an implied AND operation between each of the bits in 2 operands. Neither operand is modified. (Flags.
Jumps, Loops and Branching. Unconditional Jumps Transfer the control flow of the program to a specified instruction, other than the next instruction in.
Assembly Language Wei Gao. Assembler language Instructions.
Selection and Iteration Chapter 8 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
CS2422 Assembly Language and System Programming 0 Week 13 & 14 Codes in Assembly Language.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7) By Dr. Syed Noman.
Computer Architecture CST 250
Instruksi Set Prosesor 8088
Microprocessor and Assembly Language
Lecture 4 Control Flow Structures (LOOPS)
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Assembly IA-32.
INSTRUCTION SET.
Assembly Language Programming Part 2
Microprocessor and Assembly Language
(The Stack and Procedures)
Computer Organization and Assembly Language
فصل پنجم انشعاب و حلقه.
8086 Registers Module M14.2 Sections 9.2, 10.1.
(The Stack and Procedures)
Program Logic and Control
Program Logic and Control
Morgan Kaufmann Publishers Computer Organization and Assembly Language
X86 Assembly Review.
EECE.3170 Microprocessor Systems Design I
High-level language structures
UNIT-II Assembly Language Programs Involving Logical
Assembly Language for Intel 8086 Jump Condition
CNET 315 Microprocessor & Assembly Language
(The Stack and Procedures)
Jump & Loop instructions
Chapter 7 –Program Logic and Control
Carnegie Mellon Ithaca College
Chapter 8: Instruction Set 8086 CPU Architecture
Chapter 7 –Program Logic and Control
Computer Architecture and Assembly Language
Part VI Looping Structures
Presentation transcript:

Introduction to Computer Engineering by Richard E. Haskell Branching Instructions Module M17.2 Section 11.1

Introduction to Computer Engineering by Richard E. Haskell

Calculating Branching Displacements

Introduction to Computer Engineering by Richard E. Haskell Calculating Branching Displacements Note: Displacement is only 8 bits. Therefore, the program can only branch forward +127 bytes, or backward -128 bytes.

Introduction to Computer Engineering by Richard E. Haskell A possible way to branch conditionally more than +127 or -128 bytes is as follows: Replace JE distant next: with JNE next JMP distant next: But you should NEVER have to to this!

Introduction to Computer Engineering by Richard E. Haskell Branching Example 1 Branch on Z flag 0000 B LOOP1: MOV CX, LOOP2: DEC CX FD JNE LOOP F8 JE LOOP1

Introduction to Computer Engineering by Richard E. Haskell Branching Example 2 Branch on S flag 0000 B1 7D LOOP1: MOV CL,7DH 0002 FE C1 LOOP2: INC CL FC JNS LOOP F8 JS LOOP1

Introduction to Computer Engineering by Richard E. Haskell Branching Example 3 Branch on C flag 0000 B0 2E LOOP1: MOV AL,2EH 0002 FE C8 LOOP2: DEC AL C 2B CMP AL,2BH FA JNB LOOP F6 JC LOOP1

Introduction to Computer Engineering by Richard E. Haskell

Problem: Go through a loop (C8H) times Trial solution: MOV CL,0;set CL = 0 LOOP: INC CL;increment CL CMP CL,0C8H;compare CL toC8H JL LOOP;loop if CL < 200 How many times is the statement INC CL executed?

Introduction to Computer Engineering by Richard E. Haskell

Branching Example 1 Branch on Z flag 0000 B LOOP1: MOV CX, LOOP2: DEC CX FD JNE LOOP F8 JE LOOP B L1: MOV CX, E2 FE L2: LOOP L EB F9 JMP L1 Same as:

Introduction to Computer Engineering by Richard E. Haskell Repeat While / Repeat Until Loop L1: LOOP L1 L1: CX = CX - 1 repeat while CX /= 0 L1: CX = CX - 1 repeat until CX = 0

Introduction to Computer Engineering by Richard E. Haskell Do While Loop JCXZ NEXT L1: LOOP L1 NEXT: --- Do while CX /= CX = CX - 1 end do NEXT: ---