To write and execute an Assembly language Program (ALP) to 8086 processor to insert or delete a character/ number from the given string.

Aim:

To write and execute an Assembly language Program (ALP) to 8086 processor to insert or delete a character/ number from the given string.

Tools:

PC installed with MASM 6.11

Program:

a) String insertion

ASSUME CS : CODE, DS : DATA, ES : EXTRA
DATA SEGMENT
STRING1 DB 'EMPTY VESSELS MORE NOISE$'
STRLEN EQU ($-STRING1)
DATA ENDS
EXTRA SEGMENT
STRING2 DB STRLEN + 5 DUP(0)
EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA
       MOV DS, AX
       MOV SI, OFFSET STRING1
       MOV DI, OFFSET STRING2
       CLD
       MOV CX, 14
       REP MOVSB
       MOV DL, 5
BACK:  MOV AH, 01
       INT 21H
       STOS STRING2
       DEC DL
       JNZ BACK
       MOV CX,  11
       REP MOVSB
       NOP
       MOV AH, 4CH
       INT 21H
CODE ENDS
END START
END

b) String deletion

 

ASSUME CS : CODE, DS : DATA, ES : EXTRA
DATA SEGMENT
STRING1 DB 'EMPTY VESSELS MAKE MORE NOISE$'
STRLEN EQU ($ - STRING1)
DATA ENDS
EXTRA SEGMENT
STRING2 DB STRLEN - 5 DUP (0)
EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA
       MOV DS, AX
       MOV AX, EXTRA
       MOV ES, AX
       MOV SI, OFFSET STRING1
       MOV DI, OFFSET STRING2
       CLD
       MOV CX, 13
       REP MOVSB
       CLD
       MOV SI, 18
       MOV CX, 12
       REP MOVSB
       MOV AH, 4CH 
       INT 21H
CODE ENDS
END START
END

Result:

EMPTY VESSELS MAKE MORE NOISE

Viva-voce questions:

1. What are the different string instructions of 8086?
2. What is the difference between near and far procedure?
3. What is the difference between macro and sub-routine?
4. What is meant by DUP?
5. What are the functions of SI and DI registers?