University of Thi-Qar College of Engineering Department of Electrical and Electronic Engineering MICROPROCESSOR Lecture3 BY MSc. Zahraa M. Baqir Addressing Modes in 8086 Examples of the register-addressed instructions. Examples of the immediate-addressed instructions. Assembly Language MOV BL,44 MOV AX,44H MOV SI,0 MOV CH,100 MOV AL,’A’ MOV AX,’AB’ MOVCL,11001110B size 8-bits 16-bits 16-bits 8-bits 8-bits 16-bits 8-bits Operation Copies a 44 decimal into BL Copies a 0044H into AX Copies a 0000H into SI Copies a 100 decimal into CH Copies an ASCII A into AL Copies an ASCII BA into AX Copies a 11001110 binary into CL Examples: Direct Addressing Modes MOV DL, [2400] ;move contents of DS:2400 intoDL MOV CX, [3200] ; move contents of DS:3200 into CX Examples: Register indirect addressing modes MOV AL, [BX] ;move contents of DS:BX into AL MOV CL, [SI] MOV [DI], AH ; move contents of DS:SI into CL ; move contents of AH into DS:DI Examples: indexed relative addressing mode MOV DX,[SI]+5;PA=DS*10+SI+5 MOV CL,[DI]+20;PA=DS*10+DI+20 Examples:based indexed addressing mode Ex1: MOV AL, [2000 H] ; PA=DS*10 + 2000 H Ex2: MOV AX, [SI] ;PA=DS*10 + (SI) PA=02000 + 1234 = 03234 H Ex3: MOV [BX]+1234 H, AL . If (AL)=ED H, (DS)=0200H and (BX)=1000 H. PA=(DS)*10 + (BX) + 1234 H PA= 0200 H*10 + 1000 H+ 1234 H PA=02000 + 1000 + 1234 PA=04234 H ;copy of (AL)=ED H Ex4: MOV CX, [BX] ;PA= DS*10 + (BX). MOV [Bp], BL ;PA= SS*10 + (Bp). MOV [DI], AH ;PA= DS*10 + (DI). MOV [DI], [BX] ;NOT ALLOWED. ❖ Data Transfer Group: 1-The MOV Instruction: Mnemonic Meaning Format Operation Flags affected MOV move MOV D,S (S)→(D) None 2-PUSH/POP Instructions: Mnem. Meaning Format Operation Flags PUSH Push word onto stack PUSH S None POP POP word onto stack POP D (Sp-1) ← (S) (Sp) ← (Sp)2 (D) ← (Sp) (Sp) ← (Sp)+2 None Operand (S or D) Register Seg reg (CS illegal) Memory Flag register Example: MOV AX, 6000H MOV SS, AX MOV SP, 7500H MOV BX, 5378H PUSH BX POP BX (PA=SS*10+SP-1)=(BH) (60000+7500-1)= (BH) (674FF)= 53 H (60000+7500-2)= (BL) (674FE)= 78 H (SP) = 7500-2 (SP) = 74FE H (BL) = (PA=SS*10+SP) (BL) = (60000+74FE)= 78 H (BH) = (60000+SP+1) (BH) = (674FF)= 53 H (SP) = 7500 H 3- XCHG Instruction: 4- XLAT Instruction : Example: XCHG AL, BL XCHG [BX][DI], CX XCHG AX, SP Example: MOV AX, 2200 H MOV DS, AX MOV AL, 15 H MOV BX, 1234 H XLAT HLT ; ; Homework Q1/ What is the result of executing the following instruction sequence? MOV AX, EDH MOV SS, AX MOV SP, 7500H MOV BX, 1000H PUSH BX POP BX Q2/ What is the result of executing the following instruction sequence ? MOV AX, 0A MOV BX, 100 MOV CX,3579 MOV DS, 2200 XCHG AL, BL MOV CL, BL XCHG [BX][DI], CX XLAT HLT Q3/ Fill blanks 1. MOV SI,DI is example of --------------------addressing mode. 2. MOV AL,’G’ is an example of --------------------addressing mode. 3. MOV AL, [BX] is an example of --------------------addressing mode. 4. MOV CL,[DI]+20 is an example of --------------------addressing mode. 5. MOV CL,[BX][DI]+6 is an example of --------------------addressing mode. 6. Physical address is -------------------If (AL)=ED H, (DS)=200H and (BX)=1000 H.