You are on page 1of 26
> An addressing mode means the method by which an operand can be specified in a register or a memory location > 8086provide a seven Addressing Modes: (1) Register Addressing (2) Immediate Addressing (3) Direct Addressing (4) Register Indirect Addressing (5) Based Indexed Addressing (6) Register Relative Addressing (7) Relative Based Indexed Addressing Opcode and Operand in Microprocessor 8086 An opcode is a short of “operation code” An opcede is a singe instruction can be executed by the CPU. In machine language it is a binary or hexadecimal value such as B7 loaded into the instruction register. In assembly language mnemonic form an opcode is a command such as MOV or ADD or JMP. Example: MOV AX, 1000H_ —; MOV is the opcode. ; AX (register) is an operand. Operands are manipulated by the opcode. In this example, the operands are the register AX and the value 1000H. 8-bit 8-bit 8-bit OP CODE OPERAND byte 1 to 2 byte “ Transfers a copy of a byte or word from the source register or memory location to the destination register or memory location. + Use of registers to hold the data to be manipulated Memory is not accessed when this addressing mode is executed * Example: MOV BX, DX _ ; copy the contents of DX into BX MOV ES, AX ; copy the contents of AX into ES ADD AL, BH ; add the contents of BH to contents of AL “destination registers must have the same size Register Addressing Mode Assembly Language Size Operation MOV ALBL Bits Copies BL into AL MOV CH,CL Bits Copies CL into CH MOV AX,CX 16-bits Copies CX into AX MOV SP,BP 16-bits Copies BP into SP MOV DS,AX 16-bits Copies AX into DS MOV SIDI 16-bits Copies DI into SI MOV BX,ES 16-bits Copies ES into BX MOV ECX,EBX 32-bits Copies EBX into ECX MOV ESP,EDX 32-bits Copies EDX into ESP MO /ES,DS - Not allowed (segment-to-segment) MOV BL,DX - Not allowed (mixed sizes) MOV CS,AX - Not allowed (the code segment register may not be the destination register) “+ Transfers the source, an immediate byte or word of data, into the destination register or memory location + The source operand is a constant “ The operand comes immediately after the opcode +» For this reason, this addressing mode executes quickly “+ Immediate addressing mode can be used to load information into any of the registers except the segment registers and flag registers. “+ Example: MOV AX, 2550H ; move 2550H into AX MOV CX,625 ;load the decimal value 625 into cx MOV BL, 40H ; load 40H into BL “ The data must first be moved to a general-purpose register and then to the segment register. “* Example: MOV AX, 2550H MOV DS, AX MOV DS, 0123H ; illegal instruction! Assembly Language Size Operation MOV BL,44 8-bits Copies a 44 decimal (2CH) into BL MOV AX,44H 16-bits Copies a 0044H into AX MOV SI,0 16-bits Copies a 0000H into SI MOV CH, 100 B-bits Copies a 100 decimal (64H) into CH MOV AL,'A’ S-bits Copies an ASCII A into AL MOV AX,'AB’ 16-bits Copies an ASCII BA" into AX MOV CL,11001110B B-bits Copies a 11001110 binary into CL MOV EBX, 12340000H 32-bits Copies a 12340000H into EBX MOV ESI,12 32-bits Copies a 12 decimal into ESI MOV EAX, 100Y 32-bits Copies a 100 binary into EAX «+ Moves a byte or word between a memory location and a register. + The data is in some memory location(s) and the address of the data in memory comes immediately after the instruction + This address is the offset address + Example: MOV AX, [2400] _; move contents of DS:2400H into AX + The physical address is calculated by combining the contents of offset location 2400 with DS *» Example: Find the physical address of the memory location and its contents after the execution of the following, assuming that DS = 1512H. MOV AL, 3BH MOV [3518], AL “Sol > Fixée@BH is copied into AL, > Then in line two, the contents of AL are moved to logical address DS:3518 which is 1512:3518. > Shifting DS left and adding it to the offset gives the physical address of 18638H (15120H + 3518H = 18638H). » After the execution of the second instruction, the memory Prot. Fayeg?Fe ama tei-osney with address 18638H will contain the value 3BH. Assembly Language Operation MOV AL,NUMBER MOV AX,COW MOV EAX,WATER MOV NEWS,AL MOV THERE,AX MOV HOME, EAX* Copies the byte contents of data segment memory location NUMBER into AL Copies the word contents of data segment memory location COW into AX Copies the doubleword contents of memory location WATER into EAX Copies AL into data segment memory location NEWS Copies AX into data segment memory location THERE Copies EAX into data segment memory location HOME * Example: MOV AX, [BX] _ 3 moves into AX the contents of the memory location pointed to by DS:BX, 1000:1234 + The physical address is calculated as 1000x10+1234=11234H + The same rules apply when using register SI or DI. + Example: MOV CL, [ST] ; move contents of DS:SI into CL MOV [DI], AH } move contents of AH into DS:DI “> Example: ** Assume that DS = 1120, SI = 2498, and AX = 17FE Show the contents of memory locations after the execution of MOV [SI], AX ; move contents of AX into DS:SI ** Solution: > The contents of AX are moved into memory locations with logical address DS:SI and DS:SI + 1; » The physical address starts at DS (shifted left) + SI = 13698. According to the little endian convention, > Low address 13698H contains FE, the low byte, > High address 13699H will contain 17, the high byte. Assembly Language Size Operation MOV CX,[Bx) 16-bits Copies the werd contents of the data segment memory location address by BX into CX MOV [8P],DL" 8-bits Copies DL into the stack segment memory location addressed by BP MOV [01),BH 8-bits Copies BH into the data segment memory location addressed by DI Transfers a byte or word between a register and the memory location essed by a base register (BP or BX) plus an index register (DI or Combining based and indexed addressing modes. One base register and one index register are used. * Examples: mas [BX+DI], CL 3 move contents of CL into DS:BX+DI » Physical Address = DSx10 + BX+DI % MOV CH, [BX+SI] 3 move contents of the DS:BX+SI into CH ® Physical Address = DSx10 + BX+SI MOV AH, [BP+DI] 3 move contents of the SS:BP+SI into AH » Physical Address = SSx10 + BP+DI MOV [BP+SI], AL 3 move contents of AL into SS:BP+SI =SSx10 + BP+SI Based Indexed Addressing TT Assembly Language Size Operation MOV CX,[BX+DI} 16-bits Copies the word contents of the data segment memory location address by BX plus DI into CX MOV CH,BP+SI) B-bits Copies the byte contents of the stack segment memory location addressed by BP plus SI into CH MOV [BX+SI],SP 16-bits Copies SP into the data segment memory location addresses by BX plus SI “+ Moves a byte or word between a register and the memory location addressed by an index or base register plus a displacement. The data in a segment of memory are addressed by adding the displacement to the contents of a base or an index register (BP, BX, DI, or SI). + Examples: MOV AX, [BX+4] 3 move contents of DS:BX+4 into AX » Physical Address = DSx10 + BX+4 MOV CH, [SI+5] ; move contents of the DS:SI+5 into CH » Physical Address = DSx10 +SI+5 MOV AH, [DI+1] ; move contents of the DS:DI+1 into AH > Physical Address = DSx10 + DI+1 BP+2 MOV [BP+2], AL ; Move contents of AL into = SSx10 + BP+2 Register Relative Addressing Mode » Example: Assume that DS = 4500, SS = 2000, BX = 2100, SI = 1486, DI = 8500, BP= 7814, and AX = 2512. Show the exact physical memory location where AX is stored in each of the following. All values are in hex. | MOV [BX+20], AX 2 MOV [SI+10), AX 3. MOV [DI+4], AX 4 MOV [BP+12}, AX © Solution: Physical Address = segment reg. x 10 + (offset reg.) + displacement 1 DS:BX+20 location 47120 = (12) and 47121 = (25) 2 DS:SI+10 location 46496 = (12) and 46497 = (25 ) 3 DS:DI+4 location 4D504 = (12) and 4D505 = (25) 4- SS:BP+12 location 27826 = (12) and 27827 = (25) Register Relative Addressing Mode —— Assembly Language Size Operation MOV AX,(D1+100H] 16-bits Copies the word contents of the data segment memory location addressed by DI plus 100H into AX MOV ARRAY[SI}.BL B-bits ‘Copies BL into the data segment memory location addressed by ARRAY plus SI MOV LISTISH#2],CL e.bits Copies CL into the data segment memory location addressed by sum of LIST, SI, and 2 MOV DI,SET_ITIBX] 16-bits Copies the word contents of the data segment memory location addressed by the sum of SET_IT and BX into Di MOV DI{EAX+10H] 16-bits Copies the word contents of the data segment memory location addressed by the sum of EAX and 10H into DI MOV ARRAYIEBX]EAX —S2-bis_ Moves EAX into the data segment memory location addressed by the sum of ARRAY and EBX “+ The base relative-plus-index addressing mode is similar to the base-plus-index addressing mode, but adds a displacement besides using a base register and an index register to form the memory address. “+ This type of addressing mode often addresses a two-dimensional array of memory data. “+ The data in a segment of memory are addressed by adding the displacement to the contents of a base and an index register (BP, BX, DI, or SI). “+ Examples: MOV [BX+DI+1], AX ; move contents of AX into DS:BX+DI+1 > Physical Address = DSx10 + BX+DI+1H MOY AX, [BX+SI+10]; move contents of the DS:BX+S1+10 into AX PhysicalAddress = DSx10 + BX+SI+10H MOW AH, [BP+DI+3] pve contents of the SS:BP+SI+3 into AH > Physical Address = SSx10 + BP+DI+3H MOV [BP+SI+6], AL 3 move contents of AL into SS:BP+SI1+6 > Physical Address = SSx10 + BP+SI+6 MOV AX, LE[BX+DI]_ ; move contents of the DS:FILE+BX+D ito AX » Physical Address = DSx10 + BX+DI+FILE MOV LIST[BP+SI+4], DH ; move contents of DH into Is BP+SIi+4 =SSx10+LIST+ BP+SI+4 Assembly Language Size Operation MOV DH{BX+D1+20H] 8-bits Copies the byte contents of the data segment memory location addressed by the sum of BX, DI, and 20H into DH MOV AX-FILE[BX+D!) 16-bits Copies the word contents of the data segment memory location addressed by the sum of FILE, BX, and DI into AX MOV LISTIBP+DI}.CL B-bits Copies CL into the stack segment memory location addressed by the sum of LIST, BP, and DI MOV LISTIBP+SI+4] DH B-bits Copies DH into the stack segment memory location addressed by the sum of LIST, BP, SI, and 4 MOV EAXFILE[EBX+ECX+2] 32-bits Copies the doubleword contents of the data segment memory location addressed by the sum of FILE, EBX, ECX, and 2 into EAX The following Table provides a summary of the offset registers that can be used with the four segment registers of the 8086 Segment Register | CS DS ES SS Offset Register IP SI, DI, BX | SI, DI, BX | SP, BP Thank You

You might also like