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.

Slides:



Advertisements
Similar presentations
Integer Arithmetic: Multiply, Divide, and Bitwise Operations
Advertisements

Machine Instructions Operations
Machine Instructions Operations 1 ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-1.ppt Modification date: March 18, 2015.
NEG Instruction Change operand content into two’s complement (negative value) and stored back into its operand mov bl, b neg bl; bl = mov.
COMP3221 lec9-logical-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 9: C/Assembler Logical and Shift - I
1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,
Bit Manipulation. Binary Numbers Base 10 numbers are represented by sum of digits times powers of 10. For example: 234 = 2* * *10 0 Binary.
©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.
Computer Organization & Assembly Language
Shifters Discussion D7.1 Example Bit Shifter.
Logical, Shift, and Rotate Operations CS208. Logical, Shift and Rotate Operations  A particular bit, or set of bits, within the byte can be set to 1.
Microcomputer & Interfacing Lecture 3
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
Binary Operations Math/Logical. Binary Math Decimal Addition Example ) Add = 15 Write down 5, carry ) Add 3 +
Introduction to Computer Engineering by Richard E. Haskell Shift and Rotate Instructions Module M16.2 Section 10.3.
Operations on data CHAPTER 4.
4 Operations On Data Foundations of Computer Science ã Cengage Learning.
Numbering systems.
Ch. 7 Logic, Shift and Rotate instr.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
1 Homework Turn in HW2 tonight HW3 is on-line already Questions?
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.
Lecture12. Outline Binary representation of integer numbers Operations on bits –The Bitwise AND Operator –The Bitwise Inclusive-OR Operator –The Bitwise.
Microprocessors Monday, Apr. 13 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Department of Computer Science and Software Engineering
Bitwise operators. Representing integers We typically think in terms of decimal (base 10) numbers.  Why?  A decimal (or base 10) number consists of.
BITWISE OPERATIONS – Microprocessor Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Bitwise Operators Fall 2008 Dr. David A. Gaitros
Bit Operations Horton pp Why we need to work with bits Sometimes one bit is enough to store your data: say the gender of the student (e.g. 0.
1 Logic, Shift, and Rotate Instructions Read Sections 6.2, 7.2 and 7.3 of textbook.
Assembly 05. Outline Bit mapping Boolean logic (review) Bitwise logic Bit masking Bit shifting Lookup table 1.
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.
Lecture 12 Integer Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
WEEK 4 ET2640 Logic and Numerical Methods 1ET2640.
Chapter 7 Bit Manipulation. 7.1 Logical Operations.
1 Sec (2.4) Arithmetic / logic instruction:. 2 Logical operations: Ex: XOR OR AND
Microprocessor & Assembly Language
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Chapter four – The 80x86 Instruction Set Principles of Microcomputers 2016年3月17日 2016年3月17日 2016年3月17日 2016年3月17日 2016年3月17日 2016年3月17日 1 Chapter Four.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Bitwise and Logical Manipulations Assembly Language Programming University of Akron Dr. Tim Margush.
CS2422 Assembly Language and System Programming 0 Week 13 & 14 Codes in Assembly Language.
Programming in Machine Language
Microprocessor Systems Design I
Bit Operations Horton pp
Chapter 3 Bit Operations
Instruction System - Bit Manipulation Instruction
Machine control instruction
Assembly Language Programming Part 2
Overview Introduction General Register Organization Stack Organization
INSTRUCTION SET OF 8086 PAWAN KUMAR SINGH.
Chapter 14 Bitwise Operators Objectives
Chapter 8 Central Processing Unit
Computer Organization and Design
Introduction to Programming
CS-401 Computer Architecture & Assembly Language Programming
Shift & Rotate Instructions)
Logical Operations In some applications it is necessary to manipulate other sizes of data, or perhaps only individual bits. There are instructions that.
Shift & Rotate Instructions)
Shift, Multiply, and Divide
Bitwise Operators.
Microprocessor and Assembly Language
Computer Organization and Assembly Language
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Shift and Rotate Instructions.
CS-401 Computer Architecture & Assembly Language Programming
Bit Operations Horton pp
CS 111 – Sept. 16 Machine language examples Instruction execution
Presentation transcript:

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 of a program. When so used, these bits are often called "flags". Frequently, the programmer must manipulate these individual bits - an activity sometimes known as "bit twiddling". The logical and shift operations provide the means for manipulating the bits.

Logical operations OR Operations OR Results in 1 if either or both of the operands are 1. OR Table 0 OR 0 = 0 0 OR 1 = 1 1 OR 0 = 1 1 OR 1 = 1

Logical operations To perform the OR operation, take one column at a time and perform the OR operation using the OR table. Ex 1: OR

Logical operations Ex 2: OR Ex 3: 0111 OR

Logical operations XOR Operations The exclusive OR. Similar to OR except that it gives 0 when both its operands are 1. Rules. 0 XOR 0 = 0 0 XOR 1 = 1 1 XOR 0 = 1 1 XOR 1 = 0

Logical operations Ex 1: XOR Ex 2: 0111 XOR

Logical operations NOT Operations NOT is a separate operator for flipping all bits. Rules. NOT 0 = 1 NOT 1 = 0 Example.NOT

Logical operations AND Operations AND yields 1 only if both its operands are 1. Rules. 0 AND 0 = 0 0 AND 1 = 0 1 AND 0 = 0 1 AND 1 = 1

Logical operations Ex 1: AND Ex 2: 0111 AND

Shift and Rotate operations Where as logical operations allow the changing of bit values in place, shift and rotate operations allow bits to be moved left or right without changing their values.

Shift and Rotate operations SHL SHL (shift left) shifts each bit one place to the left. The original leftmost bit is lost and a 0 is shifted into the rightmost position. Ex 1.SHL Ex 2.SHL

Shift and Rotate operations SHR SHR (shift right) shifts each bit one place to the right. The original rightmost bit is lost and a 0 is shifted into the leftmost position. Ex 1.SHR Ex 2.SHR

Shift and Rotate operations ROL ROL (rotate left) shifts each bit one place to the left. The original leftmost bit is shifted into the rightmost position. No bits are lost. Ex 1.ROL ROL

Shift and Rotate operations ROR ROR (rotate right) shifts each bit one place to the right. The original rightmost bit is shifted into the leftmost position. No bits are lost. Ex 1.ROR Ex 2.ROR