1 Arithmetic and Logical Operations - Part I. Boolean Operations A boolean variable can only have one of the two values, i.e, can either be 1 or 0. Given.

Slides:



Advertisements
Similar presentations
B261 Systems Architecture
Advertisements

Integer Arithmetic: Multiply, Divide, and Bitwise Operations
Binary Logic (review) Basic logical operators: (Chapter 7 expanded)
Computer Organization & Assembly Language
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.
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
24/06/2015CSE1303 Part B lecture notes 1 Words, bits and pieces Lecture B05 Lecture notes section B05.
Logical & shift ops (1) Fall 2007 Lecture 05: Logical Operations.
Arithmetic and Logical Operations
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
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.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Operations on data CHAPTER 4.
4 Operations On Data Foundations of Computer Science ã Cengage Learning.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Data Representation – Binary Numbers
Computer Arithmetic Nizamettin AYDIN
Ch. 7 Logic, Shift and Rotate instr.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
Chapter 4 Register Transfer and Micro -operations
Basic Operators. What is an operator? using expression is equal to 9. Here, 4 and 5 are called operands and + is the operator Python language supports.
Registers and MAL Lecture 12. The MAL Architecture MAL is a load/store architecture. MAL supports only those addressing modes supported by the MIPS RISC.
CSCI 136 Lab 1: 135 Review.
Microprocessors Monday, Apr. 13 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
REGISTER TRANSFER LANGUAGE MICROOPERATIONS. TODAY OUTLINES Logic Microoperations Shift Microoperations.
Shift Registers pp Shift Registers Capability to shift bits ♦ In one or both directions Why? ♦ Part of standard CPU instruction set ♦ Cheap.
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.
Lecture #8 Page 1 Lecture #8 Agenda 1.VHDL : Operators 2.VHDL : Signal Assignments Announcements 1.HW #4 assigned ECE 4110– Digital Logic Design.
1 Logic, Shift, and Rotate Instructions Read Sections 6.2, 7.2 and 7.3 of textbook.
Arithmetic Operations
Assembly 05. Outline Bit mapping Boolean logic (review) Bitwise logic Bit masking Bit shifting Lookup table 1.
CS 151: Digital Design Chapter 4: Arithmetic Functions and Circuits
Arithmetic and Logic Chapter 5
Department of Electronic & Electrical Engineering Expressions operators operands precedence associativity types.
ECE/CS 552: Arithmetic I Instructor:Mikko H Lipasti Fall 2010 University of Wisconsin-Madison Lecture notes partially based on set created by Mark Hill.
Chapter 7 Bit Manipulation. 7.1 Logical Operations.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
Bit Manipulation in 'C' 'C' bit operators
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.
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
Binary Logic (review) Basic logical operators:(Chapter 7 expanded) NOT AND – outputs 1 only if both inputs are 1 OR – outputs 1 if at lest one input is.
CSE 220 – C Programming Expressions.
Programming in Machine Language
Bit Operations Horton pp
Chapter 3 Bit Operations
ECE/CS 552: Arithmetic and Logic
MISP Assembly.
REGISTER TRANSFER LANGUAGE
Computer Architecture & Operations I
The University of Adelaide, School of Computer Science
Topic 6: Bitwise Instructions
Shift & Rotate Instructions)
Logical Operations Boy who sow wild oats better hope for crop failure.
Computer Architecture
Shift & Rotate Instructions)
Bit-wise and bit-shift operators
Shift, Multiply, and Divide
Logical instructions And rd rs rt Nor rd rs rt Or rd rs rt
MIPS Assembly.
Microprocessor and Assembly Language
Computer Organization and Assembly Language
Logical Instructions And rd rs rt Nor rd rs rt Or rd rs rt
Shift and Rotate Instructions.
Bit Manipulations CS212.
Logical Operations Boy who sow wild oats better hope for crop failure.
Bit Operations Horton pp
Arithmetic and Logic Circuits
Presentation transcript:

1 Arithmetic and Logical Operations - Part I

Boolean Operations A boolean variable can only have one of the two values, i.e, can either be 1 or 0. Given a sequence of bits, each of these bits can be considered one boolean variable. A boolean operation is applied simultaneously to each bit. Logical operations are defined for boolean variables.

Unary boolean operations input zero one invert same MAL provides the not operator

Logical Operations aband ornandnorxor xnor Some MAL instructions notD,S 1 andD,S 1,S 2 norD,S 1,S 2

Masking and Merging Masking is the process of extracting a portion of the variables from a cell. A mask can be used to extract the appropriate bits needed for future operations. The and instruction can used to extract bits. Merging is simply inserting a bit sequence in the appropriate part of the cell. The or instruction can be used to merge.

Example 14.1 The following can be used as masks: mask1:.word0xff mask2:.word0x007fffff and mask Extracted bits

Example 14.2 What is the result of using mask1 with the given bit sequence? and

Example and or merged cleared

Example 14.4 Here’s a SAL code that demonstrates masking and merging: mask1:.word0xff smallc:.word0x charc:.word0x not mask, mask1 and charc, mask, charc #clear bits or charc, charc, smallc #merge

Shift Operations Sometimes it is necessary to move a sequence of bits to different positions within the word, e.g. we need to align variables before merging A shift operation rearranges the bits within the cell by shifting them There are three types of shift operation: logical, rotate and arithmetic.

Logical Shift A logical shift moves the bits within the cell one position to the right or to the left In a logical right shift, the least significant bit (lsb) is discarded and the most significant bit (msb) is assigned 0. In a logical left shift, the lsb is assigned 0 and the msb is discarded. A shift instruction will have an operand that specifies how many times the one position shift is applied.

Example in discard MAL instruction: srl D,S 1,AMT y x

Example SAL instruction: sll D,S 1,AMT 0 in discard y x

Rotate A rotate operation shifts the bits within the cell without discarding. Unlike the logical shift, no information is lost in a rotate operation. A rotate operation can either be left or right. A rotate left has an equivalent rotate right operation. A rotate right places the lsb into the msb position. A rotate left places the msb into the lsb position.

Example 14.7 SAL instruction: rol x,y, y x

Example y What is the result of SAL’s ror x,y,2 ?

Arithmetic Shift A right shift is equivalent to integer division by two. A left shift is equivalent to multiplication by two. In 2’s complement, positive or negative, a logical left shift, is equivalent to multiplication by two. An arithmetic left shift is the same as a logical left shift.

An arithmetic right shift replicates the sign bit, instead of filling in with 0’s as in the logical right shift. In 2’s complement, positive or negative, division by two is accomplished via an arithmetic right shift. There is no arithmetic left shift instruction because the logical left shift instruction produces identical result.

Example replicated y x discard SAL instruction: srax,y,1

20 Example What is the result of multiplying this by two?