4.2 Arithmetic Instructions

Slides:



Advertisements
Similar presentations
Instruction Set of 8086 Engr. M.Zakir Shaikh
Advertisements

Introduction to Computer Engineering by Richard E. Haskell BCD Arithmetic Module M16.5 Section 10.4.
NEG Instruction Change operand content into two’s complement (negative value) and stored back into its operand mov bl, b neg bl; bl = mov.
1 x86’s instruction sets. 2 Instruction Set Classification  Transfer Move  Arithmetic Add / Subtract Mul / Div, etc.  Control Jump Call / Return, etc.
Department of Computer Science and Software Engineering
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, MUL Instruction The MUL (unsigned multiply) instruction.
1 Lecture 7 Integer Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
ADD Instruction ADD destination,source ADD AX,BX ADD SUM,EAX
Gursharan Singh Tatla 21-Nov-20101www.eazynotes.com.
8086 : INSTRUCTION SET By, Pramod Sunagar Assistant Professor
© 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.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may.
Shift and Rotate Instructions
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may modify.
Chapter 4 Basic Instructions. 4.1 Copying Data mov Instructions mov (“move”) instructions are really copy instructions, like simple assignment statements.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers
MUL Instruction (Unsigned Multiply) Multiplies an 8-, 16-, or 32-bit operand by either AL, AX or EAX. MUL r/m8 MUL r/m16 MUL r/m32.
Assembly Language – Lab 5
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1 CMC complement carry flag [CF] CF.
LAB Flag Bits and Register
ASCII and BCD Arithmetic Chapter 11 S. Dandamudi.
Chapter four – The 80x86 Instruction Set Principles of Microcomputers 2015年10月19日 2015年10月19日 2015年10月19日 2015年10月19日 2015年10月19日 2015年10月19日 1 Chapter.
Arithmetic Flags and Instructions
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.b: Arithmetic Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,
CT215: Assembly Language Programming
Assembly Language for Intel-Based Computers, 4 th Edition Unpacked and Packed Integers (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for x86 Processors 6th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may modify and copy.
Chapter 7: Integer Arithmetic. 2 Chapter Overview Shift and Rotate Instructions Shift and Rotate Applications Multiplication and Division Instructions.
Arithmetic Flags and Instructions Chapter 7 S. Dandamudi.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may.
The Assemble, Unassemble commands of the debugger: U Command for converting machine code language source Equivalent machine code instructions Equivalent.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
Multiplication and Division instructions Dr.Hadi AL Saadi.
Chapter Nov-2010
Data Transfers, Addressing, and Arithmetic
Microprocessor Systems Design I
Assembly Language for Intel-Based Computers, 5th Edition
Microprocessor Systems Design I
Assembly Language for x86 Processors 7th Edition
Microprocessor Systems Design I
ICS312 SET 7 Flags.
Microprocessor Systems Design I
The FLAGS Register An x bit means an unidentified value 9/12/2018
Assembly Language for Intel-Based Computers, 5th Edition
EE3541 Introduction to Microprocessors
Basic Assembly Language
Multiplication and Division Instructions
Assembly Language Programming Part 2
16.317: Microprocessor System Design I
INSTRUCTION SET OF 8086 PAWAN KUMAR SINGH.
CS 301 Fall 2002 Assembly Instructions
X86’s instruction sets.
Chapter 4: Instructions
اصول اساسی برنامه نویسی به زبان اسمبلی
תכנות בסיסי בשפת סף פרק 5 מצגת 3.
Multiplication and Division Instructions
ADDITION Register Addition. ADD AX,BX AX=AX+BX 2. Immediate Addition.
Assembly Language for Intel-Based Computers, 4th Edition
Assembly Language for Intel-Based Computers, 4th Edition
EECE.3170 Microprocessor Systems Design I
Chapter 5 Arithmetic and Logic Instructions
Multiplication and Division Instructions
Multiplication and Division Instructions
Division instruction.
Presentation transcript:

4.2 Arithmetic Instructions Addition instructions: ADD, ADC, INC ,AAA, DAA ADD, ADC INC CF 0 Initial AL: 0110 1001+ AF1 Initial BL: 0100 1000 Because: 1011>1001 AF=1 AL after ADD: 1011 0001 + AAA,DAA DAA: 0110 0110 CF 1 AL after DAA: 0001 0111 AF1 Example: BCD addition: ADD AL, BL AL after clear: 0000 0000+ CF 0 supposing: BH=29H BL=48H AL=69H DAA Initial BH: 0010 1001 AF 0 MOV BL, AL Carry Flag: 1 MOV AL, 0 Because: CF=0,0010<1001 1010>1001 2948+ 69 + ADC AL, BH AL after ADC: 0010 1010 DAA DAA: 0000 0110 3017 MOV BH, AL AL after DAA: 0011 0000

4.2 Arithmetic Instructions Subtraction instructions: SUB, SBB, DEC, NEG, AAS, DAS SUB, SBB, CMP SF 1 DEC, NEG CF 1 Initial AL: 0100 1000- AF1 Initial BL: 0110 1001 Because: CF,1101>1001 AF,1111>1001 AL after SUB: 1101 1111 - AAS,DAS DAS: 0110 0110 CF 1 AL after DAS: 0111 1001 AF 1 Example: BCD addition: SUB AL, BL AL after update: 0010 1001- CF 0 supposing: AH=29H AL=48H BL=69H DAS Subtractor: 0000 0000 AF 0 MOV BL, AL Carry Flag: 1 MOV AL, AH Because: CF=0,0010<1001 AF=0,1000<1001 2948- 69 - SBB AL, 0 AL after SBB: 0010 1000 DAS DAS: 0000 0000 2879 MOV BH, AL AL after DAS: 0010 1000

4.2 Arithmetic Instructions Multiplication instructions: MUL, IMUL, AAM MUL, IMUL IMUL additional, 2 operands Examples: signed and unsigned multiplication: AAM supposing: AL = FFH = -1(2’sC) CL = FEH = -2(2’sC) IMUL additional, 3 operands MUL CL IMUL CL AXFD02H AX0002H

4.2 Arithmetic Instructions Division and conversion instructions: DIV, IDIV, AAD, CBW, CWD DIV, IDIV CBW AAD CWD CWD CWDE Examples: multiplying AL by CX (signed values): supposing: AL = FFH = -1(2’sC) CX = FFFEH = -2(2’sC) CBW Convert byte FFH to word FFFFH in AX IMUL CX Multiplying words AX and CX

4.3 Logical Instructions AND, OR, XOR, TEST, NOT BSF, BSR Examples: difference between AND and TEST: AND, OR, XOR, TEST NOT supposing: AL = 25H = 0010 0101B CL = 55H = 0101 0101B AND AL,CL TEST AL,CL AL05H=0000 0101B SF0; ZF0; PF1; AL25H=0010 0101B SF0; ZF0; PF1; BSF, BSR supposing: EAX = 0000 0000 0111 1111 0000 0000 0000 0000B BSF, BSR BSF EBX, EAX BSR EBX, EAX EBX 10H EBX 16H

4.3 Logical Instructions BT, BTC, BTS, BTR BT, BTC, BTS, BTR Example: MOV AX,5555H ;AX=5555,CF=0 BT AX,10 ;AX=5555,CF=1 BT AX,11 ;AX=5555,CF=0 MOV BX,10 BTC AX,BX ;AX=5155,CF=1 INC BX BTS AX,BX ;AX=5955,CF=0 BTR AX,0 ;AX=5554,CF=1

4.3 Logical Instructions SETcc The terms “less” and “greater” are used for comparisons of signed integers. The terms “above” and “below” are used for comparisons of unsigned integers.