Middle Technical University Digital Controller Lab.
Electrical Engineering Technical College Third Stage
Electrical Power Technical Engineering Dept. Mohammed D. Altamemi Experiment-3 Addressing Modes 3-1 Object: To study and understand every type of addressing mode, and executed each type by using EMU8086 software. 3-2 Theory: the way of specifying data to be operated by an instruction is known as addressing modes. This specifies that the given data is an immediate data or an address. It also specifies whether the given operand is register or register pair. Types of addressing modes: 1. Register mode – In this type of addressing mode both the operands are registers. Example: MOV AX, BX XOR AX, DX ADD AL, BL 2. Immediate mode – In this type of addressing mode the source operand is a 8 bit or 16 bit data. Destination operand can never be immediate data. Example: MOV AX, 2000 MOV CL, 0A ADD AL, 45 AND AX, 0000 Note that to initialize the value of segment register an register is required. 3. Displacement or direct mode – In this type of addressing mode the effective address is directly given in the instruction as displacement. Example: MOV AX, [DISP] MOV AX, [0500] 4. Register indirect mode – In this addressing mode the effective address is in SI, DI or BX. Example: MOV AX, [DI] ADD AL, [BX] Middle Technical University Digital Controller Lab. Electrical Engineering Technical College Third Stage Electrical Power Technical Engineering Dept. Mohammed D. Altamemi MOV AX, [SI] 5. Based indexed mode – In this the effective address is sum of base register and index register. Base register: BX, BP Index register: SI, DI The physical memory address is calculated according to the base register. Example: MOV AL, [BP+SI] MOV AX, [BX+DI] 6. Indexed mode – In this type of addressing mode the effective address is sum of index register and displacement. Example: MOV AX, [SI+2000] MOV AL, [DI+3000] 7. Based mode – In this the effective address is the sum of base register and displacement. Example: MOV AL, [BP+ 0100] 8. Based indexed displacement mode – In this type of addressing mode the effective address is the sum of index register, base register and displacement. Example: MOV AL, [SI+BP+2000] 9. String mode – This addressing mode is related to string instructions. In this the value of SI and DI are auto incremented and decremented depending upon the value of directional flag. Example: MOVS B MOVS W 10. Input/Output mode – This addressing mode is related with input output operations. Example: IN A, 45 OUT A, 50 Middle Technical University Digital Controller Lab. Electrical Engineering Technical College Third Stage Electrical Power Technical Engineering Dept. Mohammed D. Altamemi 11. Relative mode –In this the effective address is calculated with reference to instruction pointer. Example: JNZ 8 bit address IP=IP+8 bit address 12. Implied Addressing- Instructions using this mode have no operands. The instruction itself will specify the data to be operated by the instruction. Example: CLC 3-3 Procedures: 1. Write the following program, which is a program for data transfer using different addressing modes .model small .data Num dw 4321h .code Mov ax,@data ; Initialize the data segment Mov ds, ax Mov ax, 1234h Mov bx, ax Mov ax, num Mov si, 1000h Mov al, [si] Mov bl, [si+100h] Mov bx, 1000h Mov ax, [si+bx] Mov cx, [si+bx+100h] hlt End 2. Run the program in single step mode, and then record the following Step 1: AX = Step 2: DS = Step 3: AX = Step 4: BX = Step 5: AX = Step 6: SI = Step 7: AL = Step 8: BL = Step 9: BX = Step 10: AX = Middle Technical University Digital Controller Lab. Electrical Engineering Technical College Third Stage Electrical Power Technical Engineering Dept. Mohammed D. Altamemi Step 11: CX = 3-4 Discussion: 1. In program above in step 3, what is the mode of addressing? Explain briefly what is instruction doing? 2. In program above in step 4, what is the mode of addressing? Explain briefly what is instruction doing? 3. In program above in step 5, what is the mode of addressing? Explain briefly what is instruction doing? 4. In program above in step 7, what is the mode of addressing? Explain briefly what is instruction doing? 5. In program above in step 8, what is the mode of addressing? Explain briefly what is instruction doing? 6. In program above in step 10, what is the mode of addressing? Explain briefly what is instruction doing? 7. In program above in step 11, what is the mode of addressing? Explain briefly what is instruction doing? 8. Execute the following program, and then record the new values of variables D1, and D2 after executing. .model small .data d1 db 0ah,0bh,0ch,0dh,0eh d2 db 10 dup(0) .code Mov ax,@data ; Initialize the data segment Mov ds, ax Lea si, d1 ; Load offset address of d1 in si Lea di, d2 ; Load offset address of d2 in di Mov cx, 05 ; load cx with count Up: Mov al, [si] ; Move the 1st element of d1 to al Mov [di], al ; Move to d2 Inc si ; Increment si Inc di ; Increment di Dec cx ; Decrement the counter Jnz Up ; Repeat till cx becomes zero hlt End