1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,

Slides:



Advertisements
Similar presentations
NEG Instruction Change operand content into two’s complement (negative value) and stored back into its operand mov bl, b neg bl; bl = mov.
Advertisements

1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 11: Control Unit Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization, ed-5.
1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 08: Multi-module Programs Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Computer Organization & Assembly Language
80x86 Instruction Set Dr. Qiang Lin.
1 Lecture 7 Integer Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Introduction to Assembly Here we have a brief introduction to IBM PC Assembly Language –CISC instruction set –Special purpose register set –8 and 16 bit.
Chapter 8 Bit Manipulation Contents: Logical Operations Shift and Rotate Instructions.
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.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may modify.
9-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
Shift and Rotate Instructions
Assembly Language for Intel-Based Computers
Introduction to Computer Engineering by Richard E. Haskell Shift and Rotate Instructions Module M16.2 Section 10.3.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 7:
Assembly Language for x86 Processors 6th Edition
Sahar Mosleh California State University San MarcosPage 1 Applications of Shift and Rotate Instructions.
Ch. 7 Logic, Shift and Rotate instr.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
Lecture 05: Assembly Language Programming (2). The 80x86 IBM PC and Compatible Computers Chapter 3 Arithmetic & Logic Instructions and Programs Chapter.
11.1/36 Repeat: From Bits and Pieces Till Strings.
Sahar Mosleh California State University San MarcosPage 1 CPU Flags and Boolean Instructions.
Bits and Bytes. BITWISE OPERATORS Recall boolean logical operators in Java… boolean logical operators: &, |, ^ not: ! Show truth tables.
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.
Department of Computer Science and Software Engineering
Lecture 5 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Sahar Mosleh California State University San MarcosPage 1 Review.
1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.b: Arithmetic Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,
Integer Arithmetic Computer Organization and Assembly Languages Yung-Yu Chuang 2007/12/24 with slides by Kip Irvine.
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.
EEL 3801 Part V Conditional Processing. This section explains how to implement conditional processing in Assembly Language for the 8086/8088 processors.
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
Lecture 12 Integer Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
COMP 2003: Assembly Language and Digital Logic Chapter 2: Flags and Instructions Notes by Neil Dickson.
The Assemble, Unassemble commands of the debugger: U Command for converting machine code language source Equivalent machine code instructions Equivalent.
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.
Boolean, Shift and Rotate instructions Dr.Hadi AL Saadi.
Data Transfers, Addressing, and Arithmetic
16.317: Microprocessor System Design I
Assembly Language for Intel-Based Computers, 5th Edition
Microprocessor Systems Design I
Chapter 3 Bit Operations
Microprocessor Systems Design I
EE3541 Introduction to Microprocessors
Instruction System - Bit Manipulation Instruction
Machine control instruction
Assembly Language Programming Part 2
# include < stdio.h > v oid main(void) { long NUM1[5]; long SUM; long N; NUM1[0] = 17; NUM1[1] = 3; NUM1[2] =  51; NUM1[3] = 242; NUM1[4] = 113; SUM =
INSTRUCTION SET OF 8086 PAWAN KUMAR SINGH.
UNIT: 2 INSTRUCTION SET OF 8086.
CS 301 Fall 2002 Assembly Instructions
CS-401 Computer Architecture & Assembly Language Programming
Shift & Rotate Instructions)
Shift & Rotate Instructions)
Assembly Language for Intel-Based Computers, 4th Edition
Assembly Language for Intel-Based Computers, 5th Edition
Shift, Multiply, and Divide
Microprocessor and Assembly Language
Computer Organization and Assembly Language
Shift and Rotate Instructions.
CS-401 Computer Architecture & Assembly Language Programming
Presentation transcript:

1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization, ed-5 3. Materi kuliah CS61C/2000 & CS152/1997, UCB 4. Intel Architecture Software Developer’s Manual 17 Maret 2004 L. Yohanes Stefanus Bobby Nazief bahan kuliah:

2 Logical Instructions °The logical instructions AND, OR, XOR (exclusive or), and NOT perform the standard Boolean operations for which they are named. OF and CF flags are cleared; SF, ZF, and PF flags are set according to the result; AF flag is undefined (AND/OR/XOR) °The shift instructions rearrange the bits within an operand. CF flag contains the value of the last bit shifted out of the destination operand; it is undefined for SHL and SHR instructions where the count is greater than or equal to the size (in bits) of the destination operand. OF flag is affected only for 1-bit shifts; otherwise, it is undefined. SF, ZF, and PF flags are set according to the result. If the count is 0, the flags are not affected. For a non-zero count, the AF flag is undefined. °The rotate instructions rearrange the bits within an operand. CF flag contains the value of the bit shifted into it. OF flag is affected only for singlebit rotates; it is undefined for multi-bit rotates.

3 Logical Instructions: Summary 1.AND And 2.OR Or 3.XOR Exclusive or 4.NOT Not 5.SAR Shift arithmetic right 6.SHR Shift logical right 7.SAL/SHL Shift arithmetic left/Shift logical left 8.SHRD Shift right double 9.SHLD Shift left double 10.ROR Rotate right 11.ROL Rotate left 12.RCR Rotate through carry right 13.RCL Rotate through carry left

4 Format Instruksi AND (OR, XOR) ACC  [ACC]  IMM AND AL,imm8 AL AND imm8 AND AX,imm16 AX AND imm16 AND EAX,imm32 EAX AND imm32 REG/MEM  [REG/MEM]  IMM AND r/m8,imm8 r/m8 AND imm8 AND r/m16,imm16 r/m16 AND imm16 AND r/m32,imm32 r/m32 AND imm32 AND r/m16,imm8 r/m16 AND imm8 (sign-extended) AND r/m32,imm8 r/m32 AND imm8 (sign-extended) REG/MEM  [REG/MEM]  [REG] AND r/m8,r8 r/m8 AND r8 AND r/m16,r16 r/m16 AND r16 AND r/m32,r32 r/m32 AND r32 REG  [REG]  [REG/MEM] AND r8,r/m8 r8 AND r/m8 AND r16,r/m16 r16 AND r/m16 AND r32,r/m32 r32 AND r/m32

5 Format Instruksi NOT °NOT r/m8 Reverse each bit of r/m8 °NOT r/m16 Reverse each bit of r/m16 °NOT r/m32 Reverse each bit of r/m32 CONTOH: °NOT DL °NOT BYTE [DATA] °NOT DX °NOT WORD [DATA] °NOT EDX °NOT DWORD [DATA]

6 Shift Instructions °Shift Left SAL (shift arithmetic left) SAL SRC SAL SRC,COUNT SHL (shift logical left) SHL SRC SHL SRC,COUNT SHLD (shift left double) SHLD SRC,REG,COUNT °Shift Right SAR (shift arithmetic right) -lihat SAL SHR (shift logical right) -lihat SHL SHRD (shift right double) -lihat SHLD

7 SAL & SHL °shift the source operand left by from 1 to 31 bit positions °empty bit positions are cleared °CF flag is loaded with the last bit shifted out of the operand

8 SHR °shifts the source operand right by from 1 to 31 bit positions °empty bit positions are cleared °CF flag is loaded with the last bit shifted out of the operand

9 SAR °shifts the source operand right by from 1 to 31 bit positions °preserves the sign of the source operand by clearing empty bit positions if the operand is positive, or setting the empty bits if the operand is negative °CF flag is loaded with the last bit shifted out of the operand

10 Format Instruksi SAL (SAR, SHL, SHR) 1-OPERAND SAL r/m8 Multiply r/m8 by 2, 1 time SAL r/m16 Multiply r/m16 by 2, 1 time SAL r/m32 Multiply r/m32 by 2, 1 time 2-OPERAND w/ CL SAL r/m8,CL Multiply r/m8 by 2, CL times SAL r/m16,CL Multiply r/m16 by 2, CL times SAL r/m32,CL Multiply r/m32 by 2, CL times 2-OPERAND w/ IMM SAL r/m8,imm8 Multiply r/m8 by 2, imm8 times SAL r/m16,imm8 Multiply r/m16 by 2, imm8 times SAL r/m32,imm8 Multiply r/m32 by 2, imm8 times

11 SHLD & SHRD °shift a specified number of bits from one operand to another °provided to facilitate operations on unaligned bit strings or to implement a variety of bit string move operations

12 Format Instruksi SHLD (SHRD) °SHLD r/m16, r16, imm8 Shift r/m16 to left imm8 places while shifting bits from r16 in from the right °SHLD r/m16, r16, CL Shift r/m16 to left CL places while shifting bits from r16 in from the right °SHLD r/m32, r32, imm8 Shift r/m32 to left imm8 places while shifting bits from r32 in from the right °SHLD r/m32, r32, CL Shift r/m32 to left CL places while shifting bits from r32 in from the right

13 Rotate Instructions °Rotate Left ROL (rotate left) RCL (rotate through carry left) °Rotate Right ROR (rotate right) RCR (rotate through carry right) °Format R-OP SRC,COUNT

14 ROL & ROR °ROL instruction rotates the bits in the operand to the left (toward more significant bit locations) °ROR instruction rotates the operand right (toward less significant bit locations) °CF flag always contains the value of the last bit rotated out of the operand

15 RCL & RCR °RCL instruction rotates the bits in the operand to the left, through the CF flag) °RCR instruction rotates the bits in the operand to the right through the CF flag °CF flag always contains the value of the last bit rotated out of the operand

16 Format Instruksi RCL (RCR, ROL, ROR) °RCL r/m8, 1 Rotate 9 bits (CF, r/m8) left once °RCL r/m8, CL Rotate 9 bits (CF, r/m8) left CL times °RCL r/m8, imm8 Rotate 9 bits (CF, r/m8) left imm8 times °RCL r/m16, 1 Rotate 17 bits (CF, r/m16) left once °RCL r/m16, CL Rotate 17 bits (CF, r/m16) left CL times °RCL r/m16, imm8 Rotate 17 bits (CF, r/m16) left imm8 times °RCL r/m32, 1 Rotate 33 bits (CF, r/m32) left once °RCL r/m32, CL Rotate 33 bits (CF, r/m32) left CL times °RCL r/m32,i mm8 Rotate 33 bits (CF, r/m32) left imm8 times