CHECK WHETHER THE CHARACTER IS PRESENT OR NOT - MICROPROCESSOR 8086 - Code Developer Pro

Breaking

Code Developer Pro

Solutions to all coding problems

Like us on Facebook

test banner

Post Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Monday, 29 June 2015

CHECK WHETHER THE CHARACTER IS PRESENT OR NOT - MICROPROCESSOR 8086

How to check whether the character is present or not in Assembly Language program using 8086 Microprocessor?


Solution

print macro str
        mov ah,09h
        mov dx,offset str
        int 21h
endm
data segment
        str1 db 'Enter the string:$'
        str2 db 'Enter the character to be searched:$'
        msg1 db 'The character is present.$'
        msg2 db 'The character is not present..!!$'
        arr db 80 dup('$')
        aa db 0dh,0ah,'$'
data ends
code segment
        assume ds:data,cs:code
start:  mov ax,data
        mov ds,ax
        print str1
        mov si,offset arr
        mov cl,00h
label1: mov ah,01h
        int 21h
        cmp al,0dh
        jz label2
        mov [si],al
        inc si
        inc cl
        jmp label1
label2: mov [si],'$'
        mov si,offset arr
        print aa
        print str2
        mov ah,01h
        int 21h
        mov ch,00h
check:  mov bh,[si]
        cmp bh,al
        jz stop
        inc si
        loop check
stop:   cmp cl,00h
        jnz stop1
        print aa
        print msg2
        mov ah,4ch
        int 21h
stop1:  print aa
        print msg1
        mov ah,4ch
        int 21h
code ends
end start

Output

Enter the string:hello world
Enter the character to be searched:w
The character is present.

Enter the string:hello world
Enter the character to be searched:a
The character is not present..!!


No comments:

Post a Comment

Post Top Ad

Responsive Ads Here