Microprocessor 8086 - Program to Count all character in a sentence using subroutine or procedure
8086 Program to Count all character in a sentence using subroutine or procedure
-------------------------
-------------------------
.model small
.stack 100 h
.data
msg1 db "Enter the Sentence: $"
msg2 db 13,10,"The Count is $"
String db 50 dup('$')
n1 db 0
.code
.stack 100 h
.data
msg1 db "Enter the Sentence: $"
msg2 db 13,10,"The Count is $"
String db 50 dup('$')
n1 db 0
.code
main proc
mov ax,@data
mov ds,ax
mov ax,@data
mov ds,ax
lea dx,msg1
call message
lea si,String
call message
lea si,String
loop1:call enter_char
mov b1,a1
mov [si],b1
cmp b1,0dh
jz down1
inc si
jne loop1
mov b1,a1
mov [si],b1
cmp b1,0dh
jz down1
inc si
jne loop1
down1:lea dx,msg2
call message
lea si,string
call message
lea si,string
loop2:mov b1,[si]
call cnt
cmp b1,0dh
jz down2
jne inc_cnt
call cnt
cmp b1,0dh
jz down2
jne inc_cnt
inc_cnt:inc si
jne loop2
jne loop2
down2:sub n1,01h
add n1,30h
mov ah,02h
mov d1,n1
int 21h
add n1,30h
mov ah,02h
mov d1,n1
int 21h
mov ah,4ch
int 21h
main endp
int 21h
main endp
message proc
mov ah,09h
int 21h
ret
message endp
mov ah,09h
int 21h
ret
message endp
cnt proc
inc n1
ret
cnt endp
inc n1
ret
cnt endp
enter_char proc
mov ah,01h
int 21h
ret
enter_char endp
end main
mov ah,01h
int 21h
ret
enter_char endp
end main
--------------------
Output
-----------
Enter the Sentence: Hello World
The Count is 11
-----------
Enter the Sentence: Hello World
The Count is 11
Comments
Post a Comment