Comparison Instructions Test instruction –Performs an implied AND operation between each of the bits in 2 operands. Neither operand is modified. (Flags.

Slides:



Advertisements
Similar presentations
Registers of the 8086/ /2002 JNM.
Advertisements

Conditional Jumps Jcond destination  Cond refers to a flag condition  Destination should be a local label  Destination must be within –128 to +127 bytes.
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
Computer Organization & Assembly Language
80x86 Instruction Set Dr. Qiang Lin.
Assembly Language :CSC 225 (Lec#4: Flag Register and Conditional Statements) By Dr. Syed Noman.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers
CS2422 Assembly Language & System Programming October 17, 2006.
CS2422 Assembly Language and System Programming Conditional Processing Department of Computer Science National Tsing Hua University.
Flow Control Instructions
9-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
Conditional Processing If … then … else While … do; Repeat … until.
Ch. 7 Logic, Shift and Rotate instr.
1/2002JNM1 Basic Elements of Assembly Language Integer Constants –If no radix is given, the integer is assumed to be decimal. Int 21h  Int 21 –A hexadecimal.
Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1 CMC complement carry flag [CF] CF.
Sahar Mosleh California State University San MarcosPage 1 CPU Flags and Boolean Instructions.
Low Level Programming Lecturer: Duncan Smeed Low Level Program Control Structures.
LAB Flag Bits and Register
ICS312 Set 9 Logic & Shift Instructions. Logic & Shift Instructions Logic and Shift Instructions can be used to change the bit values in an operand. The.
Microprocessors Monday, Apr. 13 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
Boolean and Comparison Instructions Operation Description ANDAND Destination, Source OROR Destination, Source XORXOR Destination, Source NOTNOT Destination.
Copyright 2000ELEC 242 Arithmetic Instructions1 Arithmetic Instructions Arithmetic and logical instructions modify the contents of the Flag (Status) register.
Dr. José M. Reyes Álamo 1.  Review: ◦ of Comparisons ◦ of Set on Condition  Statement Labels  Unconditional Jumps  Conditional Jumps.
Arithmetic Flags and Instructions
(Flow Control Instructions)
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.
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.
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
Microprocessor MA Rahim Khan Computer Engineering and Networks Department.
Assembly 06. Outline cmp (review) Jump commands test mnemonic bt mnemonic Addressing 1.
2/20/2016CAP 2211 Flow Control Instructions. 2/20/2016CAP 2212 Transfer of Control Flow control instructions are used to control the flow of a program.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
K.K. Leung Fall 2008Introductory Pentium Programming1 Pentium Architecture: Introductory Programming Kin K. Leung
Computer Architecture CST 250
Data Transfers, Addressing, and Arithmetic
Microprocessor T. Y. B. Sc..
ICS312 SET 7 Flags.
Instruksi Set Prosesor 8088
Microprocessor and Assembly Language
Assembly Language for Intel-Based Computers, 5th Edition
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
INSTRUCTION SET.
Assembly IA-32.
INSTRUCTION SET.
More on logical instruction and
Assembly Language Programming Part 2
Microprocessor and Assembly Language
CS-401 Assembly Language Programming
Arithmetic Instructions
Computer Organization and Assembly Language
Flags Register & Jump Instruction
Shift & Rotate Instructions)
Program Logic and Control
Program Logic and Control
Shift & Rotate Instructions)
Flow Control Instructions
University of Gujrat Department of Computer Science
EECE.3170 Microprocessor Systems Design I
Computer Organization and Assembly Language
Assembly Language for Intel 8086 Jump Condition
CNET 315 Microprocessor & Assembly Language
Chapter 7 –Program Logic and Control
Carnegie Mellon Ithaca College
Chapter 8: Instruction Set 8086 CPU Architecture
Chapter 7 –Program Logic and Control
Presentation transcript:

Comparison Instructions Test instruction –Performs an implied AND operation between each of the bits in 2 operands. Neither operand is modified. (Flags affected: OF=CF=0, SF, ZF,AF,PF) –TEST reg, reg-TEST mem, reg –TEST reg,mem -TEST mem, immed –TEST reg, immed Example: Checking printer status –Mov ah,2 ;function: read printer status –Int 17h ;call BIOS –Test al, b ;ZF=0 if out of paper Can check if either bit 0 or bit 3 is set (ZF=1 only if both bits are clear)

Comparison Instructions CMP Instruction –Performs an implied subtraction of a source operand from a destination operand. Neither operand is modified. Segment registers cannot be used. –CMP reg, reg- CMP mem, reg –CMP reg,mem - CMP mem, immed –CMP reg, immed For Unsigned operand comparisons:

Using Compare (CMP)

Comparison Instructions CMP Instruction For Signed operand comparisons:

Conditional Jumps Jcond Instructions –Transfers control to a destination address when a flag condition is true. –Destination address must be –128 to +127 bytes from the current location, which can sometimes be a problem. –Three types of conditional jump instructions: general comparisons unsigned comparisons signed comparisons

Jumps Based on General Comparisons

Jumps Based on Unsigned Comparisons

Jumps Based on Signed Comparisons

Steps to executing IF statements Use comparison and arithmetic statements (CPU sets individual flags based on result) Use conditional jump instructions (CPU takes action based on flags) cmp al, 0 Jznext;jump if ZF=1 … Next:

Use SHORT operator to improve machine code Use SHORT before jump label to eliminate NOP instructions after your jump instruction. Cmp ax,0 Jne short L2 Movbx,2 L2: …

Do While Loop