ARM Bitwise Logic.

Slides:



Advertisements
Similar presentations
1 ECE 5465 Advanced Microcomputers Group 11: Brian Knight Benjamin Moore Alex Williams.
Advertisements

COMP3221 lec9-logical-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 9: C/Assembler Logical and Shift - I
Binary Logic (review) Basic logical operators: (Chapter 7 expanded)
Thumb Data Processing Instructions and Breakpoint Instructions 02/18/2015 Mingliang Ge Yi (Leo) Wu Xinuo (Johnny) Zhao.
Review Two’s complement
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
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.
ARM Instructions I Prof. Taeweon Suh Computer Science Education Korea University.
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
CS-280 Dr. Mark L. Hornick 1 ASCII table. 2 Displaying Numbers as Text Problem: display numerical values as text Consider the numerical value 0x5A held.
Bits and Bytes. BITWISE OPERATORS Recall boolean logical operators in Java… boolean logical operators: &, |, ^ not: ! Show truth tables.
Lecture 2: Operations Bryan Burlingame 9Sept2015.
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.
Bitwise operators. Representing integers We typically think in terms of decimal (base 10) numbers.  Why?  A decimal (or base 10) number consists of.
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.
REGISTER TRANSFER LANGUAGE MICROOPERATIONS. TODAY OUTLINES Logic Microoperations Shift Microoperations.
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.
MIPS Logic & Shift. Bitwise Logic Bitwise operations : logical operations applied to each bit Bitwise OR:
Lecture 2: Advanced Instructions, Control, and Branching EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer.
20. LOW-LEVEL PROGRAMMING. Bitwise Shift Operators The bitwise shift operators are: > right shift The expression i
Assembly 05. Outline Bit mapping Boolean logic (review) Bitwise logic Bit masking Bit shifting Lookup table 1.
EET 4250 Instruction Representation & Formats Acknowledgements: Some slides and lecture notes for this course adapted from Prof. Mary Jane Penn.
Arithmetic and Logic Chapter 5
CSE 351 Number Representation. Number Bases Any numerical value can be represented as a linear combination of powers of n, where n is an integer greater.
1 Sec (2.4) Arithmetic / logic instruction:. 2 Logical operations: Ex: XOR OR AND
Bit Manipulation in 'C' 'C' bit operators
©2000 Addison Wesley Little- and big-endian memory organizations.
Ch 5. ARM Instruction Set  Data Type: ARM processors supports six data types  8-bit signed and unsigned bytes  16-bit signed and unsigned half-words.
1 Manipulating Information (1). 2 Outline Bit-level operations Suggested reading –2.1.7~
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.
CompSci From bits to bytes to ints  At some level everything is stored as either a zero or a one  A bit is a binary digit a byte is a binary.
ARM Bitwise Logic. Bitwise Logic Bitwise operations : Work on patterns of bits, not values represented by those bits.
From bits to bytes to ints
COMPUTER ARCHITECTURE & OPERATIONS I
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
Assembly Language Assembly Language
Bitfields and Logic Basics
Processor Instructions set. Learning Objectives
Chapter 3 – Digital Logic and Binary Numbers
Bitwise Logic and Immediate Operands
How do you write 4.3 ÷ 104?.
ECE 3430 – Intro to Microcomputer Systems
March 2006 Saeid Nooshabadi
Arithmetic and Logic Chapter 5
REGISTER TRANSFER LANGUAGE
Computer Architecture & Operations I
Bitwise Operations and Bitfields
The University of Adelaide, School of Computer Science
Bitwise Operations C includes operators that permit working with the bit-level representation of a value. You can: - shift the bits of a value to the left.
Bitwise Operators CS163 Fall 2018.
Topic 6: Bitwise Instructions
CS-401 Computer Architecture & Assembly Language Programming
How is 0.41  10 related to 0.41  100?.
The University of Adelaide, School of Computer Science
Homework Homework Continue Reading K&R Chapter 2 Questions?
CS 206D Computer Organization
Arithmetic and Logic Chapter 5
Branching instructions
Bitwise Operators.
Logical instructions And rd rs rt Nor rd rs rt Or rd rs rt
Bitwise operators.
Logical Instructions And rd rs rt Nor rd rs rt Or rd rs rt
Immediate data Immediate operands : ADD r3, r3, #1 valid ADD r3, #1,#2 invalid ADD #3, r1,r2 invalid ADD r3, r2, #&FF ( to represent hexadecimal immediate.
Binary Lesson 7 Review of Binary and Hexadecimal
Bit Manipulations CS212.
EECE.2160 ECE Application Programming
Arithmetic and Logic Chapter 3
Presentation transcript:

ARM Bitwise Logic

Boolean Logic Identities A or 1 = 1 Anything or'd with 1 is 1 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 A xor 0 = A Xoring with 0 does nothing

Bitwise Logic Bitwise operations : Work on patterns of bits, not values represented by those bits

Bitwise Logic Bitwise OR:

Binary Immediates #0b starts a binary immediate value No spaces Any 1’s must be in 8 consecutive bits 0b11111111 0b1111111100000000 0b0000000000010101011000 0b100000000000100

ORR ORR: Bitwise OR ORR rd, rs, #___ ORR rd, rs, rm

AND AND: Bitwise AND AND rd, rs, #___ AND rd, rs, rm

EOR EOR: Bitwise exclusive OR EOR rd, rs, #___ EOR rd, rs, rm

Fun Fact In Place Swap EOR can swap two values in place

NOT No NOT instruction – use MVN

BIC BIC: Binary Clear BIC rd, rs, #___ BIC rd, rs, rm Clear bits set in # or rm

Bit Isolation Getting particular bits out of pattern Strategy 1: Shift to wipe out others Want to clear left 8 bits: 1010 1011 1111 0110 1010 1011 1111 0110 Shift left 8 bits: 1111 0110 1010 1011 1111 0110 0000 0000 Shift back right 8 bits: 0000 0000 1111 0110 1010 1011 1111 0110

Bit Isolation Getting particular bits out of pattern Strategy 1: Shift to wipe out others Want to isolate green five bits 1111 1111 1111 0110 1010 1011 1111 0110 Shift left 8 bits 1111 0110 1010 1011 1111 0110 0000 0000 Shift right 27 0000 0000 0000 0000 0000 0000 0001 1110

Bit Isolation Getting particular bits out of pattern Strategy 2: Mask : binary pattern showing bits to keep

Using Masks AND with a 0 guantees 0 AND with 1, keeps other value: 0000 1111 Mask 0011 0000 0101 1011 Data 0000 1011 AND result 0001 0000

Hex Mask F (1111) mask a whole hex digit 0x0000000f Mask 0xfff00000 Data 0x00000008 AND result 0x12300000

Other Masks Sample mask patterns: 0x00 : keep no bits 0x01 : keep bit 0 (0000 0001) 0x04 : keep bit 2 (0000 0100) 0x05 : keep bit 0 & 2 (0000 0101) 0xC0 : keep bit 6-7 (1100 0000)

Bit Isolation Getting particular bits out of pattern Strategy 2: Masking : binary pattern showing bits to keep Want to keep just green bits 1010 1011 1111 0110 1010 1011 1010 0110 Create mask… 0x01F0 or 0b111110000 0000 0000 0000 0000 0000 0001 1111 0000 AND 0000 0000 0000 0000 0000 0001 1010 0000

Mask Samples

High Level Code In C/C++

High Level Code