Showing posts with label check. Show all posts
Showing posts with label check. Show all posts

Saturday, 9 August 2014

8086 program to count the number of vowels in a string

This is an 8086 program to count the number of vowels in a string. If you have any doubts, please let me know.

.MODEL SMALL
.DATA
inp db 0ah,0dh,'enter the string: ','$'
msg db 0ah,0dh,'the number of vowels: ','$'
vowel db 'a','A','e','E','i','I','o','O','u','U','$'
databuf db 100,0,100 dup('$')
.code
START:
mov ax,@data
mov ds,ax

lea dx,inp
mov ah,09h
int 21h

lea dx,databuf
mov ah,0ah
int 21h
mov si,dx

lea dx,msg
mov ah,09h
int 21h
       
mov bl,00h
check:  lea di,vowel
mov cx,000ah
mov al,[si]
cont:
cmp al,[di]
je found
inc di
loop cont
jmp next
found:  inc bl
next:   inc si
cmp databuf[si],0ah
jne check
mov dl,bl
add dl,30h
mov ah,02h
int 21h


.EXIT
END START

8086 program to check whether a string is a palindrome or not

This is an 8086 program to check whether a string is a palindrome or not. If you have any doubts, please let me know.

.MODEL SMALL
.DATA
MSG DB 'ENTER A STRING:','$'
INP DB 100,0,100 DUP('$')
MSG2 DB 0AH, 0DH,'PALINDROME','$'
MSG3 DB 0AH, 0DH,'NOT A PALINDROME','$'
.CODE
START:
MOV AX,@DATA
MOV DS,AX

LEA DX,MSG
MOV AH,09H
INT 21H

LEA DX,INP
MOV AH,0AH
INT 21H

LEA SI,INP
LEA DI,INP
         MOV CX,0000H

CONT:   MOV AL,[DI+02H]
CMP AL,0DH
JE L1
INC CX
INC DI
JMP CONT

L1: DEC DI

L2:    MOV AL,[DI+02H]
    CMP [SI+02H],AL
    JNE NP
    INC SI
    DEC DI
    LOOP L2  

P:  LEA DX,MSG2
    MOV AH,09H
    JMP LAST
NP: LEA DX,MSG3
    MOV AH,09H
LAST:INT 21H
   
.EXIT
END START