Searching a character in a string using 8086 instructions


Searching a character in a string

Description:

This program searches a given character in a given string using 8086 instructions and DOS interrupts.

Program:

NAME                   BYTESEARCH

TITLE                    8086 ALP FOR SEARCHING A BYTE IN AN ARRAY

DATA             SEGMENT

CR EQU     13

LF EQU     10

STRNG DB      “INFANT JESUS COLLEGE OF ENGINEERING”

LENTH DW      $-STRNG

INMSG   DB      “ENTER THE LETTER TO COUNT :$”

OUTMSG  DB      CR,LF,”NO. OF THE OCCURANCE OF THE LETTER: ”

RESULT  DB      ?,CR,LF,”$”

DATA    ENDS

CODE    SEGMENT

ASSUME CS:CODE, DS:DATA

SRCH:   MOV     AX, DATA

MOV     DS, AX

MOV     ES, AX

LEA     DX,INMSG

MOV     AH,09H

INT     21H

MOV     AH,01

INT     21H

MOV     BL,0

CLD

MOV       DI, 0

MOV     CX, LENTH

CONT:   REPNE   SCASB

JCXZ    DISPLAY

INC     BL

JMP     CONT

DISPLAY:

ADD     BL,”0″

MOV       RESULT, BL

LEA     DX, OUTMSG

MOV       AH, 09H

INT         21H

MOV   AH, 4CH

INT     21H

CODE    ENDS

END     SRCH

Advertisements