1.

Strings and String Handling Instructions

Answer»

Strings and String Handling Instructions : 

The 8086 microprocessor is equipped with special instructions to handle string operations. By string we mean a series of data words or bytes that reside in consecutive memory locations. The string instructions of the 8086 permit a programmer to implement operations such as to move data from one block of memory to a block elsewhere in memory. A second type of operation that is easily performed is to scan a string and data elements stored in memory looking for a specific value. Other examples are to compare the elements and two strings together in order to determine whether they are the same or different. 

Move String :

MOV SB, MOV SW: 

An element of the string specified by the source index (SI) register with respect to the current data segment (DS) register is moved to the location specified by the destination index (DI) register with respect to the current extra segment (ES) register. The move can be performed on a byte (MOV SB) or a word (MOV SW) of data. After the move is complete, the contents of both SI & DI are automatically incremented or decremented by 1 for a byte move and by 2 for a word move. Address pointers SI and DI increment or decrement depends on how the direction flag DF is set.

Example : 

Block move program using the move string instruction 

MOV AX, DATA SEG ADDR 

MOV DS, AX 

MOV ES, AX 

MOV SI, BLK 1 ADDR 

MOV DI, BLK 2 ADDR 

32 

MOV CK, N 

CDF ; DF=0 

NEXT : MOV SB 

LOOP NEXT 

HLT



Discussion

No Comment Found

Related InterviewSolutions