Intel 8086: Instruction Set

Similar documents
3.1 DATA MOVEMENT INSTRUCTIONS 45

Summer 2003 Lecture 4 06/14/03

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

8086 INSTRUCTION SET

PESIT Bangalore South Campus

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Code segment Stack segment

8088/8086 Programming Integer Instructions and Computations

APPENDIX C INSTRUCTION SET DESCRIPTIONS

Signed number Arithmetic. Negative number is represented as

EC 333 Microprocessor and Interfacing Techniques (3+1)

CS401 Assembly Language Solved Subjective MAY 03,2012 From Midterm Papers. MC

Arithmetic Instructions

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

ASSEMBLY LANGUAGE PROGRAMMING OF THE MICROCOMPUTER

Week /8086 Microprocessor Programming I

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

CS401 Assembly Language Solved MCQS From Midterm Papers

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.

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

9/25/ Software & Hardware Architecture

Intel 8086 MICROPROCESSOR ARCHITECTURE

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.

8086 ASSEMBLY LANGUAGE PROGRAMMING

ADVANCE MICROPROCESSOR & INTERFACING

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

EEM336 Microprocessors I. Data Movement Instructions

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

Week /8086 Microprocessor Programming II

Computer Architecture 1 ح 303

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

Chapter Four Instructions Set

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

Intel 8086 MICROPROCESSOR. By Y V S Murthy

Arithmetic and Logic Instructions And Programs

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

Lecture 16: Passing Parameters on the Stack. Push Examples. Pop Examples. CALL and RET

Basic Execution Environment

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

EC 333 Microprocessor and Interfacing Techniques (3+1)

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

Week /8086 Microprocessor Programming

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

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

CS-202 Microprocessor and Assembly Language

UNIT 4. Modular Programming

WINTER 12 EXAMINATION Subject Code : Model Answer Page No : / N. a) Describe the function of SID and SOD pins of 8085 microprocessor

Basic Assembly SYSC-3006

if 2 16bit operands multiplied the result will be

ORG ; TWO. Assembly Language Programming

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

Instructions moving data

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

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

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

Lecture (07) x86 programming 6

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

8086 INTERNAL ARCHITECTURE

Architecture and components of Computer System Execution of program instructions

EC-333 Microprocessor and Interfacing Techniques

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

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

Experiment 3 3 Basic Input Output

EEM336 Microprocessors I. Arithmetic and Logic Instructions

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998

Computer Architecture and System Software Lecture 06: Assembly Language Programming

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

Data Movement Instructions

UNIT 2 PROCESSORS ORGANIZATION CONT.

CC411: Introduction To Microprocessors

US06CCSC04: Introduction to Microprocessors and Assembly Language UNIT 3: Assembly Language Instructions II

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

Defining and Using Simple Data Types

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

22 Assembly Language for Intel-Based Computers, 4th Edition. 3. Each edge is a transition from one state to another, caused by some input.

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)


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

Introduction to IA-32. Jo, Heeseung

Internal architecture of 8086

Computer Organization & Assembly Language Programming. CSE 2312 Lecture 15 Addressing and Subroutine

Lecture 5:8086 Outline: 1. introduction 2. execution unit 3. bus interface unit

INTRODUCTION TO IA-32. Jo, Heeseung

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

LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS

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

8086 programming Control Flow Instructions and Program Structures

Lesson 1. Fundamentals of assembly language

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

Am186 and Am188 Family Instruction Set Manual. February, 1997

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

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

PESIT Bangalore South Campus

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

icroprocessor istory of Microprocessor ntel 8086:

The x86 Architecture

Complex Instruction Set Computer (CISC)

Chapter 3: Addressing Modes

CMSC 313 Lecture 07. Short vs Near Jumps Logical (bit manipulation) Instructions AND, OR, NOT, SHL, SHR, SAL, SAR, ROL, ROR, RCL, RCR

Transcription:

IUST-EE (Chapter 6) Intel 8086: Instruction Set 1

Outline Instruction Set Data Transfer Instructions Arithmetic Instructions Bit Manipulation Instructions String Instructions Unconditional Transfer Instruction Conditional Branch Instructions Interrupt Instructions Processor Control Instructions Assembly Language Program Examples 2

8086 Instruction Set The 8086 has approximately 117 different instructions with about 300 op codes. Except for string instructions which involve array operations, the 8086 instructions do not permit memory-to-memory operations. They can be classified into eight groups: 1. Data Transfer Instructions 2. Arithmetic Instructions 3. Bit Manipulation Instructions 4. String Instructions 5. Unconditional Transfer Instruction 6. Conditional Branch Instructions 7. Interrupt Instructions 8. Processor Control Instructions 3

Data Transfer Instructions 4

Examples: Data Transfer Instructions (cont.) MOV CX, DX ; (CX) (DX) MOV AX, 0205H ;(AX) 0205H MOV CH, [BX] ; (CH) (16*(DS)+(BX)) moves the 8-bit content of memory location addressed by BX and segment register DS into CH. If [BX] = 0050H, [DS] = 2000H, [20050H] = 08H, then after MOV CH, [BX], the content of CH will be 08H. 5

Data Transfer Instructions (cont.) MOV START [BP], CX ; (16*(SS)+(BP)+START) (CL), (16*(SS)+(BP)+START+1) (CH), For example, if [CX] = 5009H, [BP] = 0030H, [SS] = 3000H, START = 06H, then [30036H] = 09H and [30037H] = 50H. Note that the segment register SS can be overridden by CS using MOV CS: START [BP], CX. PUSH START [BX] ; first (SP) (SP)-2 then (16*(SS)+(SP)) (16*(DS)+START+(BX)) (16*(SS)+(SP)+1) (16*(DS)+START+(BX)+1) 6

Data Transfer Instructions (cont.) POP ES ; first (EL) (16*(SS)+(SP)), and (EH) (16*(SS)+(SP)+1), then (SP) (SP)+2 XCHG START [BX], AX exchanges the 16-bit word in AX with the contents of two consecutive memory locations starting at 20-bit physical address computed from START, BX, and DS. [AL] is exchanged with the content of the first location and [AH] is exchanged with the content of the next location XLAT can be used to convert one code into another code using a look up table in DS with BX as displacements This instruction is equivalent to MOV AL, [AL] [BX]. 7

Input/Output Instructions In fixed port addressing: IN AL, 38H inputs 8-bit data from port 38H into AL. IN AX, 38H inputs 16-bit data from ports 38H and 39H into AX. OUT 38H, AL outputs the contents of AL to port 38H. OUT 38H, AX, on the other hand, outputs the 16-bit contents of AX to ports 38H and 39H 8

Input/Output Instructions (cont.) In variable port addressing: the port address is 16-bit and is contained in the DX register. Assume [DX] =3124H IN AL, DX inputs 8-bit data from 8-bit port 3124H into AL. IN AX, DX inputs 16-bit data from ports 3124H and 312516 into AL and AH respectively. OUT DX, AL outputs 8-bit data from AL into port 3124H. OUT DX, AX outputs 16-bit data from AL and AH into ports 3124H and 3125H, respectively. 9

Address Initialization Instructions LEA reg, mem loads an offset (mem) directly into the specified register. LEA BX, 5000H and MOV BX, 5000H accomplish the same task. Accomplish different tasks: LEA DI, [SI] [BX] loads the 16-bit value computed from BX and SI into DI whereas MOV DI, [SI] [BX] loads the 16-bit contents of a memory location computed from SI and BX into DI. For example, LEA can be used to load the address of the table used by the XLAT instructions. 10

Address Initialization Instructions (cont.) LDS reg, mem can be used to initialize SI and DS to point to the start of the source string before using one of the string instructions. LDS SI, [BX] ; (SI) (16*(DS)+(BX)) (2 bytes) and (DS) (16*(DS)+(BX)+2) (2 bytes) LES reg, mem can be used to point to the start of the destination string before using one of the string instructions. LES DI, [BX] ; (DI) (16*(DS)+(BX)) (2 bytes) and (ES) (16*(DS)+(BX)+2) (2 bytes) 11

Flag Register Instructions PUSHF pushes the 16-bit flag register onto the stack. LAHF loads AH with the condition codes from the low byte of the flag register. 12

Arithmetic Instructions a a+b a a-b 13

Arithmetic Instructions (cont.) ASCII: American Standard Code for Information Interchange 14

Examples of Arithmetic Instructions To find the # of matches for an 8-bit number in an 8086 register such as DL in a data array of 50 bytes in memory pointed to by BX in DS. 15

Examples of Arithmetic Instructions AAA (ASCII adjust AL after addition) The ASCII codes for numbers 0 to 9 are 30H through 39H. AAA instruction can then be used to provide the correct unpacked BCD. packed BCD stores multiple digits, e.g. 78 in a byte unpacked BCD stores only one digit, e.g. 07 in a byte 16

Examples of Arithmetic Instructions (cont.) DAA is used to adjust the result of adding two packed BCD numbers in AL to provide a valid BCD number. If after the addition, the low 4-bit of the result in AL is greater than 9 (or if AF = 1), then the DAA adds 6 to the low 4 bits of AL. Then, if the high 4 bits of the result in AL is greater than 9 (or if CF = 1), then DAA adds 60H to AL. ADD AL, DL ;[AL] = 55H=55 BCD & [DL] = 18H=18 BCD ;Result = [AL] = 6DH DAA ; [AL] = 73H=73 BCD 17

Examples of Arithmetic Instructions (cont.) AAS: ASCII adjust [AL] after subtraction The ASCII codes for two 8-bit numbers in an 8086- based microcomputer can be subtracted. [DL] = 35H = ASCII for 5 & [AL] = 37H = ASCII for 7 SUB AL, DL ; [DL]=FEH (2 s complement addition) AAS ; CF=1, [AL]=02 DAS: Decimal adjust [AL] after subtraction If low 4-bit in AL is greater than 9 (or if AF = 1), then DAS subtracts 6 from the low 4-bit of AL. Then, if the upper 4-bit of the result in AL is greater than 9 (or if CF = 1), DAS subtracts 60 from AL. 18

Multiplication Instructions Unsigned multiplication: MUL mem/reg ;[AX] [AL]*[mem8/reg8] ;[DX][AX] [AX]*[mem 16/reg 16] : MUL WORDPTR [BX] ; unsigned 16 x 16 If [BX] = 0050H, [DS] = 3000H, [30050H] = 0002H, [AX] = 0006H, then after MUL WORDPTR [BX], [DX] = 0000H, [AX] = 000CH. IMUL mem/reg ; [AX] [AL]*[mem8/reg8] ;[DX][AX] [AX]*[mem 16/reg 16] provides signed 8 x 8 or signed 16 x 16 multiplication. If [CL] = FDH =-3, [AL] = FEH =-2, then after IMUL CL, register AX contains 0006H. 19

Division Instructions IDIV mem/reg ; 16/8 or 32/16 bit signed division [AX]/[mem8/reg8], [AH] Remainder, [AL] Quotient [DX][AX]/[mem 16/reg 16], [DX] Remainder, [AX] Quotient. IDIV WORDPTR [BX]. If [BX] = 0020H, [DS] = 2000H, [20020H] = 0004H, [DX] [AX] = 00000011H, then after [DX] = Remainder = 0001H, [AX] = Quotient = 0004H DIV mem/reg ;Unsigned division If [AX] = 0009H, [BL] = 02H, then after DIV BL, [AH] = Remainder = 01H, [AL] = Quotient = 04H, 20

Instructions (cont.) CBW extends the sign from the AL register to the AH register. if (AL) = F1H, then, after CBW, (AH)=FF to perform an arithmetic operation on two signed numbers of different lengths. CWD sign-extends the AX register into the DX if the MSB of AX is 1, then (DX)=FFFFH AAM adjusts the product of two unpacked BCD digits in AX. If (AL) = 03H and (CH) = 08H MUL CH ; (AX) = 0018H, AAM ; (AX) = 0204H=unpacked 0204. 21

Bit Manipulation Instructions 22

Logical, Shift and Rotate Instructions TEST BL, 3 ; logically ANDs the contents of BL with 00000011 but does not store the result in BL. All flags are affected. All shift and rotate instructions include two operands. The destination operand specifies the register or memory to be shifted or rotated the source operand specifies the number of times SHL DX, 1 ;logically shifts the DX once to the left. 23

Logical, Shift and Rotate Instructions (cont.) SHL DX, 1 ;logically shifts the DX once to the left SHL DX,CL, with CL = 5, logically shifts the 16-bit contents of DX five times to the left. SHR is in the right direction Arithmetic shifts 24

Logical, Shift and Rotate Instructions (cont.) Rotate instructions 25

String Instructions The word "string" means that an array of data bytes or words is stored in consecutive memory locations. 26

String Instructions:MOVS SI and DI are incremented or decremented depending on the DF flag. Assuming (10002)=1234H then 27

String Instructions: REP REP repeats the instruction that follows until the CX register is decremented to 0. Example, the following instruction sequence uses LOOP instruction for moving 50 bytes from source to destination: 28

String Instructions: REP (cont.) The above instruction sequence can be replaced using REP prefix as follows: 29

String Instructions: CMPS CMPS WORD or BYTE subtracts without any result (affects flags) 8- or 16-bit data in the source memory location addressed by SI in DS from the destination memory location addressed by DI in ES. SI and DI are incremented or decremented depending on the DF flag. For example, if (DF) = 0, (DS) =1000H, (ES) = 3000H (SI) = 0002H, (DI) = 0004H, (10002) =1234H and (30004)= 1234H after CMPS WORD, CF = 0, PF = 1, AF = 1, ZF = 1, SF = 0, OF = 0, (10002) = 1234H, (30004) = 1234H, (SI) = 0004H, (DI) = 0006H 30

String Instructions: SCAS SCAS WORD or BYTE. This compares the memory (addressed by (ES) and (DI)) with AL or AX. (DI) = 0000H, (ES) = 2000H, (DF) = 0, (20000)=05, and (AL)=03 after SCAS BYTE (DI) = 0001H because (DF) = 0 all flags are affected based on the operation (AL) - (20000). 31

String Instructions: LODS LODS BYTE or WORD loads a byte into AL or a word into AX respectively from a string in memory addressed by SI in DS SI is then automatically incremented or decremented by 1 for a byte or by 2 for a word based on DF. For example, prior to execution of LODS BYTE, if (SI )= 0020H, (DS) = 3000H, (30020H) = O5H, DF = 0, then after execution (AL)=05H, (SI)= 0021H since DF = 0. 32

String Instructions: STOS STOS BYTE or WORD, on the other hand, stores a byte in AL or a word in AX respectively into a string addressed by DI in ES. DI is then automatically incremented or decremented by 1 for a byte or by 2 for a word based on DF. 33

String Instructions: REPE/REPZ REPE/REPZ prefix can be used with CMPS or SCAS to cause one of these instructions to continue executing until ZF = 1 or CX = 0. If CMPS is prefixed with REPE or REPZ, the operation is interpreted as "compare while not end-of-string (CX# 0) or strings are equal (ZF = 1)." If CMPS is preceded by REPNE or REPNZ, the operation is interpreted as "compare while not end-of-string (CX # 0) or strings not equal (ZF = 0)." Thus, repeated CMPS instructions can be used to find matching or differing string elements. 34

Unconditional Transfer Instructions Transfer control to a location either in the current executing memory segment (intrasegment) or in a different code segment (intersegment) The 8086 CALL instructions provide the mechanism to call a subroutine The RET instruction placed at the end of the subroutine transfers control back to the main program. 35

Unconditional Transfer Instructions (cont.) There are two types of 8086 CALL instruction. Intrasegment CALL (IP changes, CS is fixed). The 8086 pushes the current contents of IP onto the stack; the SP is then decremented by 2. Intersegment CALL (both IP and CS are changed). Note that intrasegment CALL instructions are used when the main program and the subroutine are located in the same code segment. 36

CALL NEAR PROC The assembler directive NEAR specifies the CALL instruction with relative addressing mode. NEAR determines a 16-bit displacement (-32766 to + 32765) and the offset is computed relative to the address of the CALL instruction. 37

CALL mem16 and CALL reg16 specify a memory location or a 16-bit register to hold the offset to be loaded into IP. use indirect addressing mode. An example of CALL mem16 CALL [BX] ; (IP) ((DS)*16+(BX)) Examples of CALL reg16 CALL BX ; (IP) (BX) CALL BP ; (IP) (BP) 38

Intersegment CALL Instructions The main program and the subroutine are located in two different code segments. The two intersegment CALL instructions are CALL FAR PROC CALL mem32. Upon execution of these two instructions, the 8086 pushes the current contents of IP and CS onto the stack, the new values of IP and CS are then loaded. 39

Intersegnent CALL Examples 40

RET RET instruction is usually placed at the end of a subroutine which pops IP or both IP and CS (pushed onto the stack by the intersegment CALL instruction), and returns control to the main program. RET disp 16, adds 16-bit value (disp 16) to SP after placing the return address into IP (for intrasegment CALL) or into IP and CS (for intersegment CALL). 41

JUMP Similar to the CALL instruction intrasegment JMP: can have an operand with a short label, near label, reg 16 or mem16. intersegment JMP For jumps with short label, IP changes and CS is fixed. JMP disp8 adds the second object code byte (signed 8-bit displacement) to (IP + 2), and (CS) is unchanged. Near label operand allows a JMP instruction to have a signed 16-bit displacement 42

JMP label JUMP JMP START. The 8086 assembler automatically computes the value of the displacement START at assembly time. JMP reg16 or JMP meml6 specifies the JUMP address respectively by the 16bit contents of a register or a memory location. JMP SI ; (IP) (SI), (CS) is unchanged JMP [DI] ; (IP) ((DS)*16+(DI)), (CS) is unchanged The intersegment JMP instruction includes operands with far label and mem32. JMP FAR [SI] ; loads IP and CS with the contents of four consecutive bytes pointed to by SI in DS. 43

Conditional Branch Instructions All 8086 conditional branch instructions use 8-bit signed displacement. If condition is true, then IP IP + disp8, otherwise IP IP + 2 and execute next instruction 44

Conditional Branch Instructions (Example) Clear a section of memory word starting at B up to and including A, where (A) = 3000H and (B) = 2000H in DS = 1000H using the following instruction sequence JGE treats CMP operands as 2 s complement numbers. The loop will terminate when BX = 3002H 45

Conditional Branch Instructions (Example) Now, suppose that (A) = 8500H and (B) = 0500H. Then, after CMP CX, BX is first executed, Because 8000H is a negative number, the loop terminates. The correct approach: 46

Conditional Branch Instructions Affecting Individual Flags 47

Iteration Control Instructions 48

Interrupt Instructions INT n is a software interrupt instruction. Execution of INT n causes the 8086 to push current CS, IP, and Flags onto the stack, and loads CS and IP with new values based on interrupt type n; an interrupt service routine is written at this new address. IRET at the end of the service routine transfers control to the main program by popping old CS, IP, and flags from the stack. The interrupt on overflow is a type 4 (n = 4) interrupt. This interrupt occurs if the overflow flag (OF) is set and the INTO instruction is executed. 49

Processor Control Instructions 50

Assembler Pseudo-Instructions or Directives Before using a variable in a program, its type must be declared as a byte (8-bit) BEGIN DB 0 word (16-bit) START DW 25F1H double word (4 bytes or 2 words) PROG DD 0 The EQU directive can be used to assign a name to constants. NUMB EQU 21H A section of a 8086 program or a data array can be defined by the SEGMENT and ENDS directives 51

Assembler Directives (cont.) The DUP directive can be used to initialize several locations to zero START DW 4 DUP (0) ; reserves four words starting at the offset START in DS and initializes them to zero The ASSUME directive tells the assembler to use the logical segment names ASSUME CS: CODE-1, DS: DATA-1 ; Assume CODE-1, and DATA-I as the code segment, data segment, respectively. 52

Assembler Pseudo-Instructions or Directives 53

Example 1 Write an 8086 assembly language program to add two 16-bit numbers in CX and DX and store the result in location 0500H addressed by DI. 54

Example 2 Write an 8086 assembly language program to add two 64-bit numbers. Assume SI and DI contain the starting offsets of the numbers. Store the result in memory pointed to by DI. 55

Example 2 (cont.) 56

Example 3 Write an 8086 assembly language program for each of the following C language program structures. Assume x and y are addresses of two 16-bit signed integers: (BX) the offset of x (SI) the offset of y 57

Example 3 (cont.) ii) sum = 0; for (i=0; i<=9; i=i + 1 ) sum = sum + a[i]; Assume sum is the address of the 16-bit result. (SI) the address of the first element of the array (BX) the offset of sum 58

Example 4 Write an 8086 assembly program to implement the following C language program loop: sum = 0; for (i=0;i<=99; i=i + 1 ) sum = sum + x[i] * y[i]; The assembly language program will compute x i y i where x i and y i are signed 8-bit numbers stored at offsets 4000H and 5000H, respectively. Initialize DS to 2000H. Store 16-bit result in DX. Assume no overflow. 59

Example 4 (cont.) 60

Example 5 Write an 8086 assembly language program to clear 50 consecutive bytes starting at offset 1000H. Assume DS is already initialized. 61

Example 6 Write an 8086 assembly language program to compare a source string of 50 words pointed to by an offset 1000H in the data segment at 2000H with a destination string pointed to by an offset 3000H in the extra segment at 4000H. The program should be halted as soon as a match is found or the end of the string is reached. 62

Example 6 (cont.) 63

Example 7 Write an 8086 assembly language program to multiply two 16-bit unsigned numbers to provide a 32-bit result. Assume that the two numbers are stored in CX and DX. 64

Example 8 Write an 8086 assembly language program to multiply two 8-bit signed numbers stored in the same register; AH holds one number and AL holds the other number. Store the 16-bit result in DX. 65