Microprocessor & Assembly Language

Slides:



Advertisements
Similar presentations
Copyright ©2009 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved. The Intel Microprocessors: 8086/8088, 80186/80188,
Advertisements

NEG Instruction Change operand content into two’s complement (negative value) and stored back into its operand mov bl, b neg bl; bl = mov.
8085 processor. Bus system in microprocessor.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
©Brooks/Cole, 2003 Chapter 4 Operations on Bits. ©Brooks/Cole, 2003 Apply arithmetic operations on bits when the integer is represented in two’s complement.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Computer Organization & Assembly Language
Logical and Shift operations A particular bit, or set of bits, within the byte is set to 1 or 0 depending on conditions encountered during the execution.
By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 5 Arithmetic and Logic Instructions.
9-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 5: Arithmetic and Logic Instructions.
Unit-1 PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE Advance Processor.
Operations on data CHAPTER 4.
4 Operations On Data Foundations of Computer Science ã Cengage Learning.
Parul Polytechnic Institute Parul Polytechnic Institute Subject Code : Name Of Subject : Microprocessor and assembly language programming Name.
Computers Organization & Assembly Language
Ch. 7 Logic, Shift and Rotate instr.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To be able to use the bitwise logical operators in programs ❏ To be able to use.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
Bits and Bytes. BITWISE OPERATORS Recall boolean logical operators in Java… boolean logical operators: &, |, ^ not: ! Show truth tables.
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.
Lecture – 4 PIC18 Family Instruction Set 1. Outline Literal instructions. Bit-oriented instructions. Byte-oriented instructions. Program control instructions.
Dr. José M. Reyes Álamo 1.  Review: ◦ Statement Labels ◦ Unconditional Jumps ◦ Conditional Jumps.
Microprocessors Monday, Apr. 13 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
Department of Computer Science and Software Engineering
Logic Conditional Processing. Status flags - review The Zero flag is set when the result of an operation equals zero. The Carry flag is set when an instruction.
Ass. Prof. Dr Masri Ayob Lecture 5: Arithmetic and Logic Instructions TK 2633: Microprocessor & Interfacing.
1 Logic, Shift, and Rotate Instructions Read Sections 6.2, 7.2 and 7.3 of textbook.
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.
Arithmetic Operations
Assembly 05. Outline Bit mapping Boolean logic (review) Bitwise logic Bit masking Bit shifting Lookup table 1.
Arithmetic and Logic Instructions
Logical and Bit Operations Chapter 9 S. Dandamudi.
EEL 3801 Part V Conditional Processing. This section explains how to implement conditional processing in Assembly Language for the 8086/8088 processors.
What is a program? A sequence of steps
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.
CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS.
Chapter 7 Bit Manipulation. 7.1 Logical Operations.
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
Format of Assembly language
Chapter 4 Operations on Bits.
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
Assembly Language Assembly Language
Introduction to 8086 Microprocessor
8086 Microprocessor.
Introduction to 8085 Instructions
Chapter 3 Bit Operations
EE3541 Introduction to Microprocessors
More on logical instruction and
Assembly Language Programming Part 2
Microcomputer Programming
Chapter 14 Bitwise Operators Objectives
CS 301 Fall 2002 Computer Organization
Computer Organization and Design
CS-401 Computer Architecture & Assembly Language Programming
Shift & Rotate Instructions)
Shift & Rotate Instructions)
Chapter 5 Arithmetic and Logic Instructions
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
Microprocessor and Assembly Language
Computer Organization and Assembly Language
Chapter 5: Arithmetic and Logic Instructions
Computer Architecture Assembly Language
Shift and Rotate Instructions.
Presentation transcript:

Microprocessor & Assembly Language Logical, shift, rotate, and bit Instructions

Basic Logic Instructions Include AND, OR, Exclusive-OR, and NOT. – also TEST, a special form of the AND instruction – NEG, similar to the NOT instruction Logic operations provide binary bit control in low-level software. –Can manipulate bits, do logical operations, allow bits to be set, cleared, or complemented and do arithmetic operations • Low-level software appears in machine language or assembly language form and often controls the I/O devices in a system. Logic operations always clear the carry and overflow flags, while the other flags change to reflect the condition of the result Except not instruction it does not affect any flags

AND Instruction The AND operation performs logical multiplication Figures: (a) The truth table for the AND operation and (b) the logic symbol of an AND gate The AND operation clears bits of a binary number The task of clearing a bit in a binary number is called masking

AND Examples AND Form: AND dest, source ;dest := dest and source AND instruction uses any addressing mode except memory-to-memory and segment register addressing The two operand must be the same size and reg, reg and mem, reg and reg, mem and reg, immediate data and mem, immediate data

OR Instruction The OR operation performs logical addition and is often called the Inclusive-OR function Figure: (a) The truth table for the OR operation and (b) the logic symbol of an OR gate The OR operation clears bits of a binary number

OR Example OR uses the same formats as AND

XOR Instruction Exclusive-OR: If the inputs are both 0 or both 1, the output is 0 If the inputs are different, the output is 1 (a) truth table of XOR (b) Symbol of XOR gate Exclusive-OR is sometimes called a comparator XOR instruction allows part of a number to be inverted A common use for the Exclusive-OR instruction is to clear a register to zero. For example, the XOR CH,CH instruction clears register CH to 00H

XOR Example XOR uses the same formats as AND

TEST Instruction The TEST instruction performs the AND operation BUT AND instruction changes the destination operand TEST instruction does not changes the destination operand TEST only affects the condition of the flag register, which indicates the result of the test The zero flag (Z) is a logic 1 if the bit under test is a zero, and (indicating a nonzero result) if the bit under test is not zero. The TEST instruction functions in the same manner as a CMP instruction, The difference is TEST instruction normally tests a single bit (or occasionally multiple bits) CMP instruction tests the entire byte, word, or doubleword. The TEST instruction uses the same addressing modes as the AND instruction The destination operand is normally tested against immediate data The value of immediate data is 1 to test the rightmost bit position, 2 to test the next bit, 4 for the next,and so on. Usually the TEST instruction is followed by either the JZ (jump if zero) or JNZ (jump if not zero) instruction

Test Example Example 1: Examples: TEST AL,1 ;test right bit JNZ RIGHT ;if set TEST AL,128 ;test left bit JNZ LEFT ;if set Examples:

Additional Test Instructions The 80386 through the Pentium 4 processors contain additional test instructions that test single bit positions Example: BTS CX, 0 ; set bit 0

NOT and NEG Instructions Logical inversion, or the one’s complement (NOT), and arithmetic sign inversion, or the two’s complement (NEG) NOT and NEG can use any addressing mode except segment register addressing Examples:

Shift Instructions Shift instructions position or move numbers to the left or right within a register or memory location. They also perform :simple arithmetic such as multiplication by powers of 2+n (left shift) division by powers of 2-n (right shift) The microprocessor’s instruction set contains four different shift instructions as shown in figure

Shift Instructions Logical shift function with unsigned numbers • Arithmetic shift function with signed numbers • Logical shifts multiply or divide unsigned data; arithmetic shifts multiply or divide signed data. – a shift left always multiplies by 2 for each bit position shifted – a shift right always divides by 2 for each position – shifting a two places, multiplies or divides by 4 Shift form: shl dest, count shl dest, CL ; cl aontain count number • Destination can be memory location or register; Segment shift not allowed.

Shift Examples Two different forms of shifts:

Rotate Rotate instructions position binary data by rotating the information in a register or memory location, either from one end to another or through the carry flag Rotation dressing modes are the same shifts The four available rotate instructions appear:

Rotation Examples