Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1 CMC complement carry flag [CF] CF.

Slides:



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

MOV Instruction MOV destination, source ; copy source to dest. MOV A,#55H ;load value 55H into reg. A MOV R0,A ;copy contents of A into R0 ;(now A=R0=55H)
Introduction to Computer Engineering by Richard E. Haskell BCD Arithmetic Module M16.5 Section 10.4.
1 x86’s instruction sets. 2 Instruction Set Classification  Transfer Move  Arithmetic Add / Subtract Mul / Div, etc.  Control Jump Call / Return, etc.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
EZ-COURSEWARE State-of-the-Art Teaching Tools From AMS Teaching Tomorrow’s Technology Today.
Department of Computer Science and Software Engineering
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Computer Organization & Assembly Language
80x86 Instruction Set Dr. Qiang Lin.
Stack Memory H H FFFFF H FFFFE H SS 0105 SP 0008 TOS BOS BOS = FFFF = 1104F H H 1104F H.
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.
Chapter 4 Basic Instructions. 4.1 Copying Data mov Instructions mov (“move”) instructions are really copy instructions, like simple assignment statements.
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.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
11.1/36 Repeat: From Bits and Pieces Till Strings.
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.
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.
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,
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 6.
Assembly Language for Intel-Based Computers, 4 th Edition Unpacked and Packed Integers (c) Pearson Education, All rights reserved. You may modify.
Arithmetic and Logic Instructions
Review of Assembly language. Recalling main concepts.
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.
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.
The Assemble, Unassemble commands of the debugger: U Command for converting machine code language source Equivalent machine code instructions Equivalent.
Introduction Arithmetic instructions are used to perform arithmetic operation such as Addition Subtraction Multiplication Division These operations can.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
ECE 353 Introduction to Microprocessor Systems Michael J. Schulte Week 6.
Comparison Instructions Test instruction –Performs an implied AND operation between each of the bits in 2 operands. Neither operand is modified. (Flags.
Chapter Nov-2010
Data Transfers, Addressing, and Arithmetic
Microprocessor Systems Design I
8086 Microprocessor.
Chapter instruction description and assembler directives from Microprocessors and Interfacing by Douglas Hall.
Today we are going to discuss about,
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
EE3541 Introduction to Microprocessors
INSTRUCTION SET.
Assembly Language Programming Part 2
4.2 Arithmetic Instructions
INSTRUCTION SET OF 8086 PAWAN KUMAR SINGH.
X86’s instruction sets.
Introduction to Assembly Language
Chapter 4: Instructions
اصول اساسی برنامه نویسی به زبان اسمبلی
תכנות בסיסי בשפת סף פרק 5 מצגת 3.
Data formats or Instruction formats of 8086:
Shift & Rotate Instructions)
ADDITION Register Addition. ADD AX,BX AX=AX+BX 2. Immediate Addition.
Shift & Rotate Instructions)
University of Gujrat Department of Computer Science
Chapter 5 Arithmetic and Logic Instructions
Computer Architecture and System Programming Laboratory
CNET 315 Microprocessor & Assembly Language
Chapter 8: Instruction Set 8086 CPU Architecture
Ch. 5 – Intel 8086 – study details from Yu & Marut
Part IV The FLAGS Register
Presentation transcript:

Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1 CMC complement carry flag [CF] CF

ADD action Add ADD D,S [S] + [D]] [D] [carry] [CF] flags affected: OF, SF, ZF, AF, PF, CF ADC action Add with carry ADC D,S [S] + [D] + [CF] [D] [carry] [CF] flags affected: OF, SF, ZF, AF, PF, CF Destination Source Register Register Register Memory Memory Register Register Immediate Memory Immediate Accumulator Immediate

DH

Format INC DAction[D+1] → [D] D R 16 R 8 M not in the debugger environment ! Flags affected SF, ZF,AF,PF

ADD immediate to accumulator WDataData if W= ADD AL,25H ADD AL, BL ADD Reg/Mem with Reg DWmod reg r/mDispl-lo C3 Displ-hi D8

Only 1 binary coded decimal digit is placed in 1 byte 2 binary coded decimal digits are packed in 1 byte Packed BCD Unpacked BCD

Assume that AL contains 32 H which is the ASCII code for 2 10 and BL contains 34 H which is the ASCII code for 4 10 and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL AAA AAA = ASCII adjust after addition Note that the CF and AF remain cleared AX = 66 AX = 6 machine code Assume that AL contains 35 H which is the ASCII code for 5 10 and BL contains 37 H which is the ASCII code for 7 10 and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL AAA AX = 6C AX = Note that CF and AF are set (Unpacked BCD)

Repeat assuming that AL contains 06 H and BL contains 04 H and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL DAA DAA = decimal adjust after addition Assume that AL contains 08 H and BL contains 04 H and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL DAA 0C 0012 (packed BCD) 0A 0010 (packed BCD)

SUB register/memory with register to either DW B05 SUB AX, [DI] MOV register/memory to/from register DWmod reg r/mDispl-lo Displ-hi MOV [SI], AX mod reg r/mDispl-loDispl-hi

MOV immediate to register 1011W regDataData if W= BE00 MOV SI, 200H MOV DI, 100H MOV register/memory to/from register DWmod reg r/mDispl-lo B04 Displ-hi BF 0001 MOV AX,[SI] MOV AX, [DI] B05

INC register reg INC SI INC DI SBB register/memory and register to either DWmod reg r/mDispl-lo B05 Displ-hi SBB AX,[DI]

MOV DS,AX MOV AX, 1000

BE BF B 04 2B B B EDS: EDS: DDS:200 EF EE EE EE Mov si,0200 Mov di,0100 Mov ax,[si] Sub ax,[di] Mov [si],ax Inc si Mov ax,[si] Inc di Sbb ax,[di] Mov [si],ax

Negate instruction : MOV AX,0060 NEG AX ’complement F F A 0

B328 B DW Subtract m/reg and reg to either Mod reg r/mDisp-loDisp-hi AC3 DAS decimal adjust after subtraction F

B83800 Subtract immediate from accumulator Wdatadata if W=1 2C39 AAS ASCII adjust for subtraction F

If AL=-1 and CL=-2 MUL CL If AL=-1 and CL=-2 IMUL CL AL=FF CL= FE Unsigned multiplication Result AX= FD02 Result AX= 2 Signed multiplication CF is set because there is a carry from the LSByte VF is set because the result cannot fit in 1 Byte

MOV BX,0009 MOV AX,0007 MUL BL AAM BCD Arithmetics AX=003F MOV AX, 0603 AAD AX=003F

Signed COMPARE example MOV AX, 99 AX= ( ) MOV BX, 1B BX= ( ) CMP AX, BX 2’scomplement [ ] = = = B 16 = – 27 = = 2’s complement [ ] = 2’s complement [ ] = = D AF=1 CF=0 OF=0