Ch. 7 Logic, Shift and Rotate instr.

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. 05.c: Logical Operations 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.
Gursharan Singh Tatla 21-Nov-20101www.eazynotes.com.
8086 : INSTRUCTION SET By, Pramod Sunagar Assistant Professor
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may modify.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 5 Arithmetic and Logic Instructions.
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
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2012 Lecture 10: Flag control instructions Conditional execution.
Ch. 5 from Yu & Marut. Registers 14(16-bit) registers: 1.Data reg. – to hold data for an op. 2.Address reg – to hold addr of an instruction or data.
Introduction to Computer Engineering by Richard E. Haskell Shift and Rotate Instructions Module M16.2 Section 10.3.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
11.1/36 Repeat: From Bits and Pieces Till Strings.
Types of Registers (8086 Microprocessor Based)
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.
Copyright 2000ELEC 242 Arithmetic Instructions1 Arithmetic Instructions Arithmetic and logical instructions modify the contents of the Flag (Status) register.
5. Assembly Language. Basics of AL Program data Pseudo-ops Array Program structures Data, stack, code segments.
Arithmetic Flags and Instructions
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.
Comparison Instructions Test instruction –Performs an implied AND operation between each of the bits in 2 operands. Neither operand is modified. (Flags.
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.
Chapter Nov-2010
Microprocessor Systems Design I
Practical Session 2.
Microprocessor Systems Design I
Microprocessor Systems Design I
Chapter 3 Bit Operations
Microprocessor Systems Design I
EE3541 Introduction to Microprocessors
Instruction System - Bit Manipulation Instruction
Machine control instruction
INSTRUCTION SET.
More on logical instruction and
Assembly Language Programming Part 2
ECE 353 Introduction to Microprocessor Systems
Intel 8088 (8086) Microprocessor Structure
INSTRUCTION SET OF 8086 PAWAN KUMAR SINGH.
UNIT: 2 INSTRUCTION SET OF 8086.
CS 301 Fall 2002 Assembly Instructions
Introduction to Assembly Language
Intel 8088 (8086) Microprocessor Structure
Shift & Rotate Instructions)
Shift & Rotate Instructions)
Shift, Multiply, and Divide
Microprocessor and Assembly Language
Computer Organization and Assembly Language
CNET 315 Microprocessor & Assembly Language
Chapter 8: Instruction Set 8086 CPU Architecture
Shift and Rotate Instructions.
CS-401 Computer Architecture & Assembly Language Programming
Ch. 5 – Intel 8086 – study details from Yu & Marut
Presentation transcript:

Ch. 7 Logic, Shift and Rotate instr. Logic Instructions AND, OR, XOR and NOT TEST Instruction Shift Instructions Left shift – doubles a number Right shift – halves a number … multiply or divide by powers of 2 MUL, DIV – much slower than shift instr… Rotate Stack Operations Introduction to Procedures

7.1 AND, OR and XOR Instructions AND destination, source OR destination, source XOR destination, source Dest. – must be a Register or mem. Source – const, reg., mem Memory-to-memory operations are not allowed Effect on flags SF, ZF, PF reflect the result AF is undefined CF, OF = 0 SF – sign ZF – zero PF – parity AF – auxiliary carry OF – overflow CF – carry

Use of Logic Instructions Selectively modify the bits of destination b AND 1 = b (b represents a bit, 0/1) b AND 0 = 0 b OR 0 = b b OR 1 = 1 b XOR 0 = b b XOR 1 = ~b (complement of b) So, AND can be used to clear specific destination bit OR can be used to set specific destination bit XOR can be used to complement specific destination bit

Examples mask Example 7.2: Clear the sign bit of AL while leaving the other bits unchanged. AND AL, 7Fh Example 7.3: Set the msb and lsb of AL while preserving the other bits. OR AL, 81h Example 7.4: Change the sign bit of DX XOR DX, 8000h 0111 1111 = 7Fh 1000 0001 = 81h See example from book

How to clear a register? MOV AX, 0 ; machine code 3 bytes SUB AX, AX ; .. 2 bytes XOR AX, AX ; .. 2 bytes -- BUT mem2mem operations only for MOV is allowed here – so to clear a memory location, use MOV.

7.1.2 NOT Instruction 1’s Complement operation NOT destination No effect on status flags Example 7.5: Complement the bits in AX NOT AX

7 Logic Instructions TEST Instruction Shift and Rotate Instructions AND, OR, XOR and NOT TEST Instruction Shift and Rotate Instructions Stack Operations Introduction to Procedures

7.2 TEST Instruction TEST performs AND of the destination with source – but no change of the dest. contents TEST destination, source Effects on flags SF, ZF, PF reflect the result AF is undefined CF, OF = 0 TEST vs. CMP CMP is subtraction operation

JZ – jump if equal to zero TEST Example Jump to label BELOW if AL contains an even number TESET AL, 1 ; is AL even? JZ BELOW ; yes, go to BELOW JZ – jump if equal to zero use to examine individual bits in an operand. mask contains 1’s in the bits positions to be tested & 0’s elsewhere Even numbers have a 0 in bit#0. So, mask = 0000 0001b = 1

Agenda Logic Instructions TEST Instruction AND, OR, XOR and NOT TEST Instruction Shift and Rotate Instructions Stack Operations Introduction to Procedures

7.2 Shift and Rotate Instructions Two types of shift and rotate instructions Logical Shift / Rotate Arithmetic Shift/Rotate Both logical and arithmetic left shift are identical But right shifts are different

opcode dest, 1 ; 1 bit change opcode dest, CL ; N bits change ; CL contians N Dest  reg., mem SHL  Multiplication by left shift by multiplies of 2 SAL  for numeric multiplication

Shift and Rotate Instructions SHL DH, 3 ; DH = 1110 1111 DH = 0111 1000 C = 1 SHR DH, 3 ; DH = 1110 1111 DH = 0001 1101 C = 1 SAL DH, 2 ; DH = 1110 1111 DH = 1011 1100 C = 1 SAR DH, 2 ; DH = 1110 1111 DH = 1111 1011 C = 1

Rotate Instructions ROL – rotate left ROR – r right RCL – r carry left RCR – r c right Let DH = 8Ah = 1000 1010 CF = 1 After first RCR DH = 1100 0101 CF = 0 After second RCR DH = 0110 0010 CF = 1

Agenda Logic Instructions TEST Instruction AND, OR, XOR and NOT TEST Instruction Shift and Rotate Instructions Stack Operations

Stack vs. Queue Stack Queue LIFO : Last In First Out FIFO : First In First Out Queue Stack

PUSH vs. POP in Stack

PUSH Instructions

POP Instructions

References Some materials are from Dr. Sazzad, NSU Ch 7, Assembly Language Programming – by Charls Marut Ch 4, Intel Microprocessors – by Brey