Logical Operations bitwise logical operations AND, OR, EOR, NOT

Slides:



Advertisements
Similar presentations
Overheads for Computers as Components 2nd ed.
Advertisements

Microprocessors.
Chapter 3 Introduction to the 68000
EECC250 - Shaaban #1 Lec # 2 Winter Addressing Modes  Addressing modes are concerned with the way data is accessed  Addressing can be.
The family.
© 2000 Morgan Kaufman Overheads for Computers as Components ARM instruction set zARM versions. zARM assembly language. zARM programming model. zARM memory.
Machine Instructions Operations
Machine Instructions Operations 1 ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-1.ppt Modification date: March 18, 2015.
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,
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.
Differences between Java and C CS-2303, C-Term Differences between Java and C CS-2303, System Programming Concepts (Slides include materials from.
EECC250 - Shaaban #1 lec #16 Winter Estimation of Assembly Programs Execution Time For a CPU running at a constant clock rate: clock rate =
Topics covered: ARM Instruction Set Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Microcontroller Fundamentals & Programming
ECE 265 – LECTURE 7 The M68HC11 Basic Instruction Set Logical, Shift and Rotate, Data Testing 8/14/ ECE265.
ARM Instructions I Prof. Taeweon Suh Computer Science Education Korea University.
Some material taken from Assembly Language for x86 Processors by Kip Irvine © Pearson Education, 2010 Slides revised 2/2/2014 by Patrick Kelley.
Assembly Programming on the TI-89 Created By: Adrian Anderson Trevor Swanson.
Ch. 7 Logic, Shift and Rotate instr.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set (2)
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.
Microprocessors Monday, Apr. 13 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
BITWISE OPERATIONS – Microprocessor Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Bitwise Operators Fall 2008 Dr. David A. Gaitros
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.
Arithmetic and Logic Chapter 5
COMP3221: Microprocessors and Embedded Systems--Lecture 10 1 COMP3221: Microprocessors and Embedded Systems Lecture 10: Shift and Bit-set Instructions.
Chapter 7 Bit Manipulation. 7.1 Logical Operations.
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.
Logical, Shift, Rotate & BCD. What we will learn in this session: Logical instructions. Shift & Rotate instructions. BCD operations. Bit operations.
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.
C Calling Conventions parameters are passed on the run-time or system stack, SP (or A7) parameters pushed on stack in “right to left” order of call A6.
Addressing Modes the addressing mode defines how data is accessed
e. g. Write a program to count the spaces in a string
Status Register Status = system byte (supervisor only) + user byte = system status + condition code register usually, it is not important to know.
Assembly Language Programming of 8085
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
Subroutines … passing data
Morgan Kaufmann Publishers Computer Organization and Assembly Language
More on logical instruction and
Microcomputer Programming
The University of Adelaide, School of Computer Science
Arithmetic and Logic Chapter 5
68000 Arithmetic Instructions
Control Unit.
The University of Adelaide, School of Computer Science
Topic 6: Bitwise Instructions
CS-401 Computer Architecture & Assembly Language Programming
Shift & Rotate Instructions)
Write a program to calculate x**y, given x and y.
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)
Subroutines … passing data
Arithmetic and Logic Chapter 5
The ARM Instruction Set
Branching instructions
Microprocessor and Assembly Language
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.
Shift and Rotate Instructions.
CS-401 Computer Architecture & Assembly Language Programming
ECE511: Digital System & Microprocessor
Presentation transcript:

Logical Operations bitwise logical operations AND, OR, EOR, NOT “mask” = setting specific bits to zero e.g. mask high four bits in NUM NUM DC.B $4C for bit operations, could mask out all the bits you are not interested in testing

Utilization of Bits to Store Data - the case of 8 doors; 1 indicates door is open DOORS DC.B $05 or DOORS DC.B %00000101 Are the even numbered doors closed? DOOR1 DC.B 1 DOOR2 DC.B 0 DOOR3 DC.B 1 DOOR4 DC.B 0 … DOOR8 DC.B 0 D1 D3 D5 D7 D2 D4 D6 D8 hallway

Shift Operations directions: left, right types: logical, arithmetic, circular length: 1 bit, > 1 bit flags: Z, N, C, sometimes X

Shift Operations Right: logical ≠ arithmetic Left: logical ≡ arithmetic C lsr X asl lsl C C asr X X rol C C ror roxl X X C C roxr

Utilization of Bits to Store Data - the case of 8 doors; 1 indicates door is open DOORS DC.B $05 or DOORS DC.B %00000101 How many doors are open? DOOR1 DC.B 1 DOOR2 DC.B 0 DOOR3 DC.B 1 DOOR4 DC.B 0 … DOOR8 DC.B 0

Bit Operations instructions operate on one bit in Dn or memory bit numbering: Dn = (long) 31 … 1 0 memory 7 6 5 4 3 2 1 0 (byte)

Bit Operations e.g. NUM1 DC.B $A2 D0=$0000F8AB Bit Test BTST #$F,D0 z ← ~(<bit number>) of destination Bit Set = test a bit then set BSET #3,NUM z ← ~(<bit number>) of destination <bit number> of destination ← 1 Bit Clear = test a bit then clear BCLR #8,D0 z ← ~(<bit number>) of destination <bit number> of destination ← 0 Bit Change = test a bit then toggle BCHG #1,NUM z ← ~(<bit number>) of destination <bit no> of dest ← ~<bit no> of dest * source operand could be Dn (contains bit position)

Utilization of Bits to Store Data - the case of 8 doors; 1 indicates door is open DOORS DC.B $05 or DOORS DC.B %00000101 Is door 3 open? DOOR1 DC.B 1 DOOR2 DC.B 0 DOOR3 DC.B 1 DOOR4 DC.B 0 … DOOR8 DC.B 0

Set according to condition used primarily to set/clear flags Scc = set a byte according to condition cc if (condition true) then destination ← $FF ; set to “true” else destination ← $00 ; set to “false” endif e.g. SEQ Flag … Flag DC.B $00

Note: Aliases are set elsewhere. We will see this code again later. /***************************************************************/ /* Purpose..: Compute result = left << right */ /* Input....: pointer to result */ /* Input....: left operand */ /* Input....: shift count */ /* Return...: pointer to result */ extern asm CInt64* __rt_shl64(CInt64 *result,CInt64 left,short count) { move.l LEFT_LO,d0 move.l LEFT_HI,d1 move.w SHIFT_COUNT,d2 and.w #0x003F,d2 bra.s l1 l0: add.l d0,d0 addx.l d1,d1 l1: dbf d2,l0 move.l RESULT,a0 move.l d0,RESULT_LO move.l d1,RESULT_HI rts } Note: Aliases are set elsewhere. We will see this code again later.

/***************************************************************/ /* Purpose..: Compute result = left >> right (signed) */ /* Input....: pointer to result */ /* Input....: left operand */ /* Input....: shift count */ /* Return...: pointer to result */ extern asm CInt64* __rt_shrs64(CInt64 *result,CInt64 left,short count) { move.l LEFT_LO,d0 move.l LEFT_HI,d1 move.w SHIFT_COUNT,d2 and.w #0x003F,d2 bra.s l1 l0: lsr.l #1,d0 asr.l #1,d1 bcc.s l1 bset #31,d0 l1: dbf d2,l0 move.l RESULT,a0 move.l d0,RESULT_LO move.l d1,RESULT_HI rts }

/***************************************************************/ /* Purpose..: Compute result = __rol(left,right) */ /* Input....: pointer to result */ /* Input....: left operand */ /* Input....: shift count */ /* Return...: pointer to result */ extern asm CInt64* __rt_rotl64(CInt64 *result,CInt64 left,short count) { move.l LEFT_LO,d0 move.l LEFT_HI,d1 move.w SHIFT_COUNT,d2 and.w #0x003F,d2 bra.s l1 l0: add.l d0,d0 addx.l d1,d1 bcc.s l1 addq.w #1,d0 l1: dbf d2,l0 move.l RESULT,a0 move.l d0,RESULT_LO move.l d1,RESULT_HI rts }

Reading, Expectations Reading: Expectations: M68000 Assembly Language [pdf, 92p; N. Znotinas] review operation of instructions covered in presentation examples were taken from the PalmOS 64 bit arithmetic library, LongLong68K.c Expectations: you can explain the operation of and the differences between the various shifts and rotates you can read/write code that uses all of the above instructions, eg. the PalmOS 64 bit arithmetic library