1.

Auto Indexing for String Instructions

Answer»

Auto Indexing for String Instructions:

SI & DI addresses are either automatically incremented or decremented based on the setting of the direction flag DF. 

When CLD (Clear Direction Flag) is executed DF=0 permits auto increment by 1. 

When STD (Set Direction Flag) is executed DF=1 permits auto decrement by 1. 

35

Mnemonic Meaning Format Operation Flags affected 

CLD Clear DF CLD (DF) ← 0 

DF STD Set DF STD (DF) ← 1 DF 

1. LDS Instruction: 

LDS register, memory (Loads register and DS with words from memory) This instruction copies a word from two memory locations into the register specified in the instruction. It then copies a word from the next two memory locations into the DS register. LDS is useful for pointing SI and DS at the start of the string before using one of the string instructions. LDS affects no flags. 

Example 1 :LDS BX [1234] 

Copy contents of memory at displacement 1234 in DS to BL. Contents of 1235H to BH. 

Copy contents at displacement of 1236H and 1237H is DS to DS register. 

Example 2 : LDS, SI String – Pointer

(SI) ← [String Pointer] 

(DS) ← [String Pointer +2] 

DS, SI now points at start and desired string

LEA Instruction : 

Load Effective Address (LEA register, source) 

This instruction determines the offset of the variable or memory location named as the source and puts this offset in the indicated 16 bit register. 

LEA will not affect the flags. 

Examples : 

LEA BX, PRICES 

Load BX with offset and PRICES in DS 

LEA BP, SS : STACK TOP 

Load BP with offset of stack-top in SS 

LEA CX, [BX] [DI] 

Loads CX with EA : (BX) + (DI) 

36 

3. LES instruction : 

LES register, memory

Example 1: LES BX, [789A H] 

(BX) ← [789A] in DS 

(ES) ← [789C] in DS 

Example 2 : LES 

DI, [BX] (DI) ← [BX] in DS 

(ES) ← [BX+2] in DS



Discussion

No Comment Found

Related InterviewSolutions