MIPS Logic & Shift. Bitwise Logic Bitwise operations : logical operations applied to each bit Bitwise OR:

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

Lecture 5: MIPS Instruction Set
MIPS assembly. Review  Lat lecture, we learnt  addi,  and, andi, or, ori, xor, xori, nor,  beq, j, bne  An array is stored sequentially in the memory.
CS/COE0447 Computer Organization & Assembly Language
7-5 Microoperation An elementary operations performed on data stored in registers or in memory. Transfer Arithmetic Logic: perform bit manipulation on.
Lec 12Systems Architecture1 Systems Architecture Lecture 12: Design of the MIPS ALU Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all.
Binary Logic (review) Basic logical operators: (Chapter 7 expanded)
Computer Structure - Computer Arithmetic Goal: Representing Numbers in Binary  Base 10 (decimal) - Numbers are represented using 10 numerals: 0, 1, 2,
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
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.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
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.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Lecture 4: MIPS Instruction Set
Chapter 2 CSF 2009 The MIPS Assembly Language: Introduction to Binary System.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
MIPS coding. Review Shifting – Shift Left Logical (sll) – Shift Right Logical (srl) – Moves all of the bits to the left/right and fills in gap with 0’s.
CS2100 Computer Organisation MIPS Part I: Introduction (AY2015/6) Semester 1.
Computer Organization Instructions Language of The Computer (MIPS) 2.
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.
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.
Shift Instructions and Logical Instructions
Pirouz Bazargan SabetDecember 2003 Effective Implementation of a 32-bit RISC Processor Pirouz Bazargan Sabet University of Paris 6 - LIP6 - ASIM
Bit Manipulation in 'C' 'C' bit operators
MIPS Arithmetic and Logic Instructions
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.
First Foray into Programming (the hard way). A reminder from last lesson: A machine code instruction has two parts:  Op-code  Operand An instruction.
ARM Bitwise Logic. Bitwise Logic Bitwise operations : Work on patterns of bits, not values represented by those bits.
CS2100 Computer Organisation
COMPUTER ARCHITECTURE & OPERATIONS I
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
Computer Organization and Design Instruction Sets - 2
Overview Register Transfer Language Register Transfer
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,
Computer Organization and Design Instruction Sets
Team Brian Leslie Stephen Brenner Brian Leslie Ben Whitcher
Lecture 4: MIPS Instruction Set
MPIS Instructions Functionalities of instructions Instruction format
ARM Control Structures
MISP Assembly.
How to represent signed integers
Computer Architecture & Operations I
ECE232: Hardware Organization and Design
Bitwise Operations and Bitfields
The University of Adelaide, School of Computer Science
Bitwise Operators CS163 Fall 2018.
Logical Operations Boy who sow wild oats better hope for crop failure.
The University of Adelaide, School of Computer Science
MIPS Assembly.
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
Team Stephen Brenner Brian Leslie Ben Whitcher
ARM Control Structures
ARM Bitwise Logic.
Logical instructions And rd rs rt Nor rd rs rt Or rd rs rt
MIPS Assembly.
MIPS assembly.
Logical Instructions And rd rs rt Nor rd rs rt Or rd rs rt
MIPS Arithmetic and Logic Instructions
MIPS Arithmetic and Logic Instructions
Bit Manipulations CS212.
Logical Operations Boy who sow wild oats better hope for crop failure.
MIPS instructions.
Presentation transcript:

MIPS Logic & Shift

Bitwise Logic Bitwise operations : logical operations applied to each bit Bitwise OR:

Immediate Value Immediate Value Value hard coded into instruction

Immediate Value Immediate Value Value hard coded into instruction 16 bits available to store immediate:

Register Registers = 32 bits, Immediate 16 bits Must extend immediate

Max Immediate Immediate value can't require 17+ bits Unless you use Pseudo instructions – Must be UNCHECKED for now

OR vs ORI OR $6, $5, $4 ORI $6, $0, 0xffff

Logical Ops to Know Immediate instructions ori, andi, xori instruction $dest, $source, immediate Register-Register Instructions or, and, xor, nor instruction $dest, $source1, $source2

Quick Reminders A or 0 = A – Anything or'd with 0 is that thing A and 1 = A – Anything and'd with 1 is that thing A and 0 = 0 – Anything and'd with 0 is 0 A xor 1 = not(A) – Xoring with 1 flips bit

Common Tricks ORI Load a value to register by ori $0 and value

Common Tricks OR Clear a register by oring $0 with self

Common Tricks OR Copy register by or with $0

Common Tricks OR Combine non-overlapping patterns:

Common Tricks AND Keep only specified bits by anding with 1's in desired digits

Common Tricks NOR Do NOT by NOR with $0

Logical Shift Logical Shifts – Add 0's to fill empty space sll, srl instructions: instruction $dest, $source, number of bits

NOP NOP : No operation – Done with sll $0, $0, $0 – Opcode for sll is 0 0x is nop!

Loading Large Value Loading 32bit immediate takes 3 steps: Load (ori) 16bits (in right part of register) Shift left 16 bits (move to left half of register) Load (ori) 16bits (in right part of register)

Bit Isolation Getting particular bits out of pattern Strategy 1: – Shift to wipe out others Want to clear left 8 bits: Shift left 8 bits: Shift back right 8 bits:

Bit Isolation Getting particular bits out of pattern Strategy 1: – Shift to wipe out others Now want to isolate green five bits Shift right

Bit Isolation Getting particular bits out of pattern Strategy 2: – Masking : binary pattern showing bits to keep 0x00 : keep no bits 0x01 : keep bit 1 ( ) 0x04 : keep bit 3 ( ) 0x05 : keep bit 1 & 3 ( ) 0xF0 : keep bit 5-8 ( )

Using Masks AND with a mask 0's out unmasked portions: Mask Data AND result

Hex Mask F (1111) mask a whole hex digit 0x fMask0xfff x Data0x x AND result0x

Bit Isolation Getting particular bits out of pattern Strategy 2: – Masking : binary pattern showing bits to keep Want to keep just green bits Create mask… 0x01F AND

Bit Isolation Want to keep just green bits Create mask… 0x01F AND