Shift Instructions and Logical Instructions

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

Lec 12Systems Architecture1 Systems Architecture Lecture 12: Design of the MIPS ALU Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all.
Chapter 2 Instructions: Language of the Computer
Computer Structure - Computer Arithmetic Goal: Representing Numbers in Binary  Base 10 (decimal) - Numbers are represented using 10 numerals: 0, 1, 2,
Comp Sci instruction encoding 1 Instruction Encoding MIPS machine language Binary encoding of instructions MIPS instruction = 32 bits Three instruction.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Computer Science: An Overview Tenth Edition by J. Glenn Brookshear Chapter.
1 Representing Numbers Using Bases Numbers in base 10 are called decimal numbers, they are composed of 10 numerals ( ספרות ) = 9* * *10.
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
Computer Processing CSCE 110 J. Michael Moore.
Logical & shift ops (1) Fall 2007 Lecture 05: Logical Operations.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Chapter 2.2 Machine Language.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
CMPE 325 Computer Architecture II Cem Ergün Eastern Mediterranean University Integer Representation and the ALU.
CSE378 Instr. encoding.1 Instruction encoding The ISA defines –The format of an instruction (syntax) –The meaning of the instruction (semantics) Format.
BITWISE OPERATIONS – Microprocessor Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
MIPS Logic & Shift. Bitwise Logic Bitwise operations : logical operations applied to each bit Bitwise OR:
IFT 201: Unit 1 Lecture 1.3: Processor Architecture-3
A summary of TOY. 4 Main Components Data Processor Control Processor Memory Input/Output Device.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
CS2100 Computer Organisation MIPS Part I: Introduction (AY2015/6) Semester 1.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
EET 4250 Instruction Representation & Formats Acknowledgements: Some slides and lecture notes for this course adapted from Prof. Mary Jane Penn.
Addition, Subtraction, Logic Operations and ALU Design
Chapter 2: Data Manipulation
Integer Multiplication, Division Arithmetic shift Twice the number of places MIPS multiply unit. mult, multu Significant bits Mfhi, mflo, div, divu Arithmetic.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Dale Roberts, Lecturer Information.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 9 Binary Representation and Logical Operations.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic6: Logic, Multiply and Divide Operations José Nelson Amaral.
Jump and Branch Instructions
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
Pirouz Bazargan SabetDecember 2003 Effective Implementation of a 32-bit RISC Processor Pirouz Bazargan Sabet University of Paris 6 - LIP6 - ASIM
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Programming Model CS 333 Sam Houston State University Dr. Tim McGuire.
27 October 2015 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Bit Manipulation in 'C' 'C' bit operators
Microprocessor & Assembly Language
MIPS Arithmetic and Logic Instructions
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
© 2015 Pearson Education Limited 2015 Quiz in last 15 minutes Midterm 1 is next Sunday Assignment 1 due today at 4pm Assignment 2 will be up today; due.
CS2100 Computer Organisation
Integer Multiplication, Division Arithmetic shift
COMPUTER ARCHITECTURE & OPERATIONS I
CSCI206 - Computer Organization & Programming
Bitwise Logic and Immediate Operands
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
MPIS Instructions Functionalities of instructions Instruction format
MISP Assembly.
The University of Adelaide, School of Computer Science
Computer Architecture & Operations I
ECE232: Hardware Organization and Design
Bitwise Operations and Bitfields
The University of Adelaide, School of Computer Science
Shift & Rotate Instructions)
The University of Adelaide, School of Computer Science
MIPS Assembly.
Chapter 4: Representing instructions
Instruction encoding The ISA defines Format = Encoding
Instruction encoding The ISA defines Format = Encoding
MIPS Assembly.
Instruction encoding The ISA defines Format = Encoding
MIPS assembly.
MIPS Arithmetic and Logic Instructions
MIPS Arithmetic and Logic Instructions
MIPS instructions.
CS 111 – Sept. 16 Machine language examples Instruction execution
Presentation transcript:

Shift Instructions and Logical Instructions Shift Instructions (sll, srl) No Operation Logical Instructions (or, and, xor, nor) Not, Move - pseudo instructions Textbook: Appendix A – A.10. MIPS R2000 assembly language. Central Connecticut State University, MIPS Tutorial. Chapter 12.

Shift Instructions (sll, srl) It often happens that a bit pattern must be moved left or right within a register. The instructions that do this are the shift instructions.

Shift Left Logical sll d,s,shft $d <-- the bits in $s shifted left logical by shft positions where 0 <= shft < 32 The ALU (arithmetic/logic unit) which does the operation pays no attention to what the bits mean. If the bits represent an unsigned integer, then a left shift is equivalent to multiplying the integer by two.

SLL example ## Program to logical shift left a pattern .text .globl main main: ori $8, $0, 0x6F sll $9, $8, 2 How 0x6F appears in the register $8 ? How it becomes to 0x1BC ?

Shifting in Place When an ALU operation is performed: Data is copied from the register(s) into the ALU. Then, the ALU does the operation. Next the result is written to the designated result register. There is no problem when an operand register is also the result register because the operand data was transferred to the ALU in the first step, leaving the register open to receive the result. Sending the result back to the source register is called shifting in place.

Machine instruction for shift in place 0 0 0 8 4 0 8 0 0000 0000 0000 1000 0100 0000 1000 0000 000000 00000 01000 01000 00010 000000 opcode ----- source dest shft 2ndary ALUop $8 $8 2 sll   sll $8, $8, 2

No-Op sll $0, $0, 0 ALUop $0 $0 0 sll A machine instruction that does nothing is called (in official computer science jargon) a no-op (no operation). Register $0 always contains a 32-bit zero so shifting it left by zero positions and attempting to put the result back in $0 does nothing. Any instruction that attempts to alter $0 does nothing, but this instruction is the preferred way of doing nothing. 0 0 0 0 0 0 0 0 0000 0000 0000 0000 0000 0000 0000 0000 000000 00000 00000 00000 00000 000000 opcode ----- source dest shft 2ndary ALUop $0 $0 0 sll sll $0, $0, 0

Moves bits to the right by a number of positions less than 32. The high-order bit gets zeros The low-order bits are discarded If the bit pattern is regarded as an unsigned integer, or a positive two's comp. integer, then a right shift of one bit position performs an integer divide by two. A right shift by N positions performs an integer divide by 2N. srl d,s,shft $d <-- logical right shift of $s by shft positions. shft is a 5-bit integer, 0 <= shft < 32

Bitwise logic instructions or d,s,t # $d <-- bitwise OR between $s with $t. and d,s,t # $d <-- bitwise AND between $s with $t. xor d,s,t # $d <-- bitwise XOR between $s with $t. operand 1 AND OR XOR XOR does inversion wherever one of the operands contains ones.

Not Or nor d,s,t # $d <-- bitwise NOR between $s with $t. NOT pseudoinstruction as NOR with $0 nor d,s,$0 # $d <-- bitwise NOT of $s operand 1 AND OR XOR NOR NOR does inversion wherever one of the operands contains zeroes.

MOVE pseudoinstruction as OR with Zero Copying the pattern in a source register to a destination register is called a move operation, even though the source register does not change. or d,s,$0 # $d <-- contents of $s operand 1 AND OR XOR NOR OR does setup wherever one of the operands contains zeroes.

Summary New learned instructions AND OR XOR NOR and d,s,t or d,s,t xor d,s,t nor d,s,t $d <— $s and $t $d <— $s or $t $d <— $s xor $t $d <— $s nor $t All learned instructions and andi nor or ori sll srl xor xori