INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Similar documents
8088/8086 Programming Integer Instructions and Computations

Mnem. Meaning Format Operation Flags affected ADD Addition ADD D,S (D) (S)+(D) (CF) Carry ADC Add with ADC D,C (D) (S)+(D)+(CF) O,S,Z,A,P,C

Arithmetic Instructions

Week /8086 Microprocessor Programming I

Intel 8086: Instruction Set

Signed number Arithmetic. Negative number is represented as

Computer Architecture 1 ح 303

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

Ex : Write an ALP to evaluate x(y + z) where x = 10H, y = 20H and z = 30H and store the result in a memory location 54000H.

Lecture 9. INC and DEC. INC/DEC Examples ADD. Arithmetic Operations Overflow Multiply and Divide

Q1: Multiple choice / 20 Q2: Memory addressing / 40 Q3: Assembly language / 40 TOTAL SCORE / 100

EC 333 Microprocessor and Interfacing Techniques (3+1)

We will first study the basic instructions for doing multiplications and divisions

Instructions moving data

ASSEMBLY LANGUAGE PROGRAMMING OF THE MICROCOMPUTER

1-Operand instruction types 1 INC/ DEC/ NOT/NEG R/M. 2 PUSH/ POP R16/M16/SR/F 2 x ( ) = 74 opcodes 3 MUL/ IMUL/ DIV/ DIV R/M

4- MACHINE LANGUAGE CODING 4-1THE INSTRUCTION SET:

16.317: Microprocessor Systems Design I Spring 2014

EC 333 Microprocessor and Interfacing Techniques (3+1)

16.317: Microprocessor Systems Design I Fall 2013

Lecture (07) x86 programming 6

Integer Arithmetic Part2

8086 INSTRUCTION SET

Lesson 1. Fundamentals of assembly language

3.1 DATA MOVEMENT INSTRUCTIONS 45

Integer Arithmetic. Pu-Jen Cheng. Adapted from the slides prepared by Kip Irvine for the book, Assembly Language for Intel-Based Computers, 5th Ed.

APPENDIX C INSTRUCTION SET DESCRIPTIONS

Assignment no:4 on chapter no :3 : Instruction set of 8086

Arithmetic and Logic Instructions And Programs

Defining and Using Simple Data Types

Chapter Four Instructions Set

Code segment Stack segment

complement) Multiply Unsigned: MUL (all operands are nonnegative) AX = BH * AL IMUL BH IMUL CX (DX,AX) = CX * AX Arithmetic MUL DWORD PTR [0x10]

Computer Architecture and System Software Lecture 04: Floating Points & Intro to Assembly

Adding Binary Integers. Part 4. Negative Binary. Integers. Adding Base 10 Numbers. Adding Binary Example = 10. Arithmetic Logic Unit

UNIT III MICROPROCESSORS AND MICROCONTROLLERS MATERIAL OVERVIEW: Addressing Modes of Assembler Directives. Procedures and Macros

Q1: Multiple choice / 20 Q2: Protected mode memory accesses

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Data Movement Instructions

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Basic characteristics & features of 8086 Microprocessor Dr. M. Hebaishy

EEM336 Microprocessors I. Arithmetic and Logic Instructions

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Adding Binary Integers. Part 5. Adding Base 10 Numbers. Adding 2's Complement. Adding Binary Example = 10. Arithmetic Logic Unit

8086 Programming. Multiplication Instructions. Multiplication can be performed on signed and unsigned numbers.

db "Please enter up to 256 characters (press Enter Key to finish): ",0dh,0ah,'$'

Summer 2003 Lecture 4 06/14/03

Logic Instructions. Basic Logic Instructions (AND, OR, XOR, TEST, NOT, NEG) Shift and Rotate instructions (SHL, SAL, SHR, SAR) Segment 4A

Kingdom of Saudi Arabia Ministry of Higher Education. Taif University. Faculty of Computers & Information Systems

8086 ASSEMBLY LANGUAGE PROGRAMMING

Introduction to Microprocessor

ADVANCE MICROPROCESSOR & INTERFACING

Week /8086 Microprocessor Programming

SHEET-2 ANSWERS. [1] Rewrite Program 2-3 to transfer one word at a time instead of one byte.

ECOM Computer Organization and Assembly Language. Computer Engineering Department CHAPTER 7. Integer Arithmetic

Basic Assembly SYSC-3006

CS401 Assembly Language Solved MCQS From Midterm Papers

EXPERIMENT - 1: ADDITION & SUBTRACTION

PESIT Bangalore South Campus

ENE 334 Microprocessors

Computer Architecture and System Programming Laboratory. TA Session 3

Chapter 4: Data Movement Instructions. 4 1 MOV Revisited

Integer Arithmetic. Computer Organization and Assembly Languages Yung-Yu Chuang 2005/11/17. with slides by Kip Irvine

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION 80x86 Instructions

Chapter 3: Addressing Modes

6/20/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

9/25/ Software & Hardware Architecture

Intel 8086 MICROPROCESSOR ARCHITECTURE

Lecture 9. INC and DEC. INC/DEC Examples ADD. ADD Examples SUB. INC adds one to a single operand DEC decrements one from a single operand

IBM PC Hardware CPU 8088, Pentium... ALU (Arithmetic and Logic Unit) Registers. CU (Control Unit) IP.

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

CS-202 Microprocessor and Assembly Language

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

8086 INTERNAL ARCHITECTURE

.code. lea dx,msg2. Page 1/8. Problem 1: Programming in Assembly [25 Points]

L1 Remember, L2 Understand, L3 - Apply, L4 Analyze, L5 Evaluate, L6 Create

Chapter 7 Integer Arithmetic

EEM336 Microprocessors I. Data Movement Instructions

UNIT 2 PROCESSORS ORGANIZATION CONT.

BAHAR DÖNEMİ MİKROİŞLEMCİLER LAB3 FÖYÜ

Computer Organization and Assembly Language CSC-210

Integer Arithmetic. Shift and rotate. Overview. Shift and Rotate Instructions

Assembling, Linking and Executing 1) Assembling: .obj obj .obj.lst .crf Assembler Types: a) One pass assembler:

Q1: Define a character string named CO_NAME containing "Internet Services" as a constant?

MOV CX,80 MOV CX,100. For example, MOV DI, OFFSET TEXT_STRING ;DI points to the TEXT_STRING in the extra segment ; Byte to be scanned in AL

Name (10) # Student. Student. 2017, Microprocessors 1 / 11

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Electronics and Communication

if 2 16bit operands multiplied the result will be

LAB 5 Arithmetic Operations Simple Calculator

Microprocessor and Assembly Language Week-5. System Programming, BCS 6th, IBMS (2017)

UNIT 4. Modular Programming

Section 001 & 002. Read this before starting!

Intel 8086 MICROPROCESSOR. By Y V S Murthy

Mr. Sapan Naik 1. Babu Madhav Institute of Information Technology, UTU

BLDEA S V.P. DR. P.G. HALAKATTI COLLEGE OF ENGINEERING & TECHNOLOGY, VIJAYAPURA

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Hands on Experience for Faculty in Laboratories Phase I JNTUK, Kakinada

Practical Course File For

Transcription:

8

Unsigned and Signed Integer Numbers 1. Unsigned integer numbers: each type of integer can be either byte-wide or word-wide. This data type can be used to represent decimal numbers in the range 0 through 255. The unsigned word integer can be used to represent decimal numbers in the range 0 through 65535. 2. Signed integer numbers: each type of integer can be either byte-wide or word-wide. They are similar to unsigned integer numbers except the most significant bit MSB in signed integer data type is a sign bit. This data type represents decimal numbers in the range -128 to +127. The signed word integer represents decimal numbers in the range 32768 to +32767. Note: Negative integers are stored in 2's complement form. -1H = FFH (byte), -2H = FEH (byte) -1H = FFFFH (word), -2H = FFFEH (word) 0

Instruction Set of 8086µP There are 117 basic instructions in the instruction set of 8086µP. The instruction set of 8086µP can be divided into the following groups : 1. Data Transfer Instructions 2. Arithmetic and Logic Instructions 3. Shift and Rotate Instructions 4. Flag Control Instructions 5. Compare Instructions 6. Jump Instructions 7. Loop Instructions 8. Stack Instructions 9. Strings Instructions 10. Subroutines Instructions Data Transfer Instructions The data transfer instructions include: 1. MOV (byte or word) Instruction. 2. XCHG (Exchange byte or word) 3. XLAT (Translate byte) 4. LEA (Load effective address ) 5. LDS (Load register and DS) 6. LES (Load register and ES) The MOV Instruction: The MOV instruction is used to transfer (copy) a byte or word of data from a source operand to a destination operand. The general form of MOV instruction is as shown below: The allowed operands for the source and destination are listed below: Examples : MOV AX, BX MOV AL, FFH MOV [BX], CX MOV [SI], FF87H MOV BH, [PB+DI] MOV DS, AX MOV AL, 'A' MOV [BX], [SI] is not allowed, why? MOV DS, FA34H is not allowed, why? MOV DS, CS is not allowed, why? MOV CS, AX is not allowed, why? 9

The Exchange XCHG Instruction The XCHG (exchange) instruction exchanges the contents of a register a memory with the contents of any other register or memory. The general form of this instruction is as shown below: The allowed operands for the source and destination are listed below: Example (AX)=1000H and (BX)=2000H XCHG AX, BX After execution : (AX)=2000H and (BX)=1000H H.W. Repeat the example by using MOV instructions only. The XLAT Instruction This instruction used to simplify implementation of the lookup table operation. The general form of this instruction is as shown below: Ex: Assume (DS) = 1000H, (BX)=1000H, and (AL)=05H. Execution of XLAT replaces the contents of AL by the contents of memory location with physical address : PA = (DS)0 + (BX) + (AL) = 10000H + 1000H + 05H = 11005H Thus: (AL) = 6DH (the old byte 05H in AL is replaced by 6DH) AX BX 8

Load-Effective Address (LEA, LDS, and LES) Instructions: These instructions load a segment and general purpose registers with an address directly from memory. The general forms of these instructions are as shown below: Mnemonic Meaning Format Operation Flags Affected LEA Load effective address LEA Reg16, EA EA (Reg16) None LDS Load register and DS LDS Reg16, EA [PA] (Reg16) [PA+2] (DS) None LES Load register and ES LES Reg16, EA [PA] (Reg16) [PA+2] (ES) None Ex: What does BX contain after executing: LEA BX, [SI+100H] (SI)=1000H Ans. The effective address EA=1000H + 100H = 1100H (BX) = 1100H If Ex : If (SI)=1000H and (DS)=1000H, what do the registers BX and DS contain after execution LDS BX, [SI] instruction? Ans. PA = 10000H + 1000H = 11000H The execution of LDS BX, [SI] loads BX from addresses 11000H and 11001H and DS from addresses 11002H and 11003H. (BX) = 127AH and (DS) = 3000H BX SI Note : All data transfer instructions do not affect the status flags.

Arithmetic and Logic Group The arithmetic group includes instructions for the addition, subtraction, multiplication, division as well as increment and decrement operations. Addition and Subtraction Instructions The allowed operands: Ex: Write an ALP that subtracts 1234H existing in DX from the word beginning at memory location 64200. Ans. : MOV AX, 6000H MOV DS, AX MOV BX, 4200H MOV DX, 1234H SUB [BX], DX HLT Examples ADD AL, BL ADD AX, DI ADC DX, 1234H SUB AX, [BX] SBB [BX+DI], CL INC AL DEC [DI] Ex: Write a piece of code to add two 32-bit numbers stored at 82000H and 84000H and store the result at 86000H. Ans. : MOV AX, 8000H MOV DS, AX MOV AX, [2000] MOV DX, [2002] ADD AX, [4000] ADC DX, [4002] MOV [6000], AX MOV [6002], DX HTL

Multiplication and Division Instructions: The 8086µP has instructions for multiplication and division of binary, BCD numbers, and signed or unsigned integers. Multiplication and division are performed on bytes or on words. The allowed operand: Source Examples MUL BL DIV [SI] IMUL BX IDIV [DI+1000H] Ex: Write an ALP for dividing 1234H by 34H. Ans. MOV AX, 1234H MOV CL, 34H DIV CL HLT After Execution : (AX)= 2059H Quotient in AL = 59H and Remainder in AH = 20H. Ex : If (AL) = -1 and (BL) = -2, what is the result of Executing : 1. MUL BL 2. IMUL BL Ans. The 2'complement of -1 = FFH The 2'complement of -2 = FEH 1. (AX) = FF*FE = FD02H 2. (AX) = -1H* -2H = 0002H

CBW(Convert Signed Byte to Word) & CWD(Convert Signed Word to Double Word) instructions: The division instruction can also be used to divide a sign 8-bit dividend in AL by an 8-bit divisor. For this purpose we use (CBW) instruction. When (CBW) instruction is executed the value of AX register is as shown below: AH=0 if the number is positive & AH=1 if the number is negative. Ex: What is the result of executing the following piece of code? MOV AL, A1H CBW CWD The first instruction loads AL with (AL)=A1 16 =10100001 2 Executing the second instruction gives: (AH)=11111111 2 = FF 16 (AX)=1111111110100001 2 = FFA1 16 Executing the third instruction gives: (AX)=FFA1 16 (DX)=FFFF 16 Ex: Write an ALP that divide a signed byte stored in 5600AH by the content of BL. Ans. MOV AX, 5000H MOV DS, AX MOV SI, 6000H MOV AL, [SI + 0AH] CBW IDIV BL MOV [SI + 0AH], AX HLT