This is Microprocessor code for Displaying the Number of times that letter repeated the string is read from keyboard using BIOS function...
Algorithm is:
The code is as follows...
;Finding The Occurance of Letter
;Author:AKSHATH KUMAR
;------------------------------------------
;---MACRO FOR DISPLAYING MSG---
printf macro msg
lea dx,msg
mov ah,09h
int 21h
endm
;---------------------------------------------
data segment
msg1 db 10,13,"Enter the String:",10,13,"$"
str1 db 10h,?,10h dup(' ')
len dw 01h dup(0)
msg2 db 10,13,"$"
data ends
;--------------------
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
printf msg1
lea dx,str1
mov ah,10
int 21h
printf msg2
mov bx,0h
mov cx,0h
mov bl,str1[1]
mov str1[bx+2],"$"
lea di,str1+2
mov cl,bl
mov len,cx
again:
mov al,ds:[di]
push cx
mov cx,len
mov bl,0h
lea si,str1+2
up:
cmp al,ds:[si]
jnz skip
inc bl
skip:
inc si
loop up
pop cx
inc di
add bl,30h
mov dl,bl
mov ah,02h
int 21h
loop again
int 3h
code ends
end start
Algorithm is:
- Initialize Data segment
- read string from keyboard
- point 2 pointer SI and DI to starting of string.
- One is used for checking individual character of string with other (DI)
- If any Character is repeated Increment BL
- After Checking with all the character display the result...
The code is as follows...
;Finding The Occurance of Letter
;Author:AKSHATH KUMAR
;------------------------------------------
;---MACRO FOR DISPLAYING MSG---
printf macro msg
lea dx,msg
mov ah,09h
int 21h
endm
;---------------------------------------------
data segment
msg1 db 10,13,"Enter the String:",10,13,"$"
str1 db 10h,?,10h dup(' ')
len dw 01h dup(0)
msg2 db 10,13,"$"
data ends
;--------------------
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
printf msg1
lea dx,str1
mov ah,10
int 21h
printf msg2
mov bx,0h
mov cx,0h
mov bl,str1[1]
mov str1[bx+2],"$"
lea di,str1+2
mov cl,bl
mov len,cx
again:
mov al,ds:[di]
push cx
mov cx,len
mov bl,0h
lea si,str1+2
up:
cmp al,ds:[si]
jnz skip
inc bl
skip:
inc si
loop up
pop cx
inc di
add bl,30h
mov dl,bl
mov ah,02h
int 21h
loop again
int 3h
code ends
end start