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
main proc
mov ax,@data
mov ds,ax
lea dx,msg1
call message
lea si,String
loop1:call enter_char
mov b1,a1
mov [si],b1
cmp b1,0dh
jz down1
inc si
jne loop1
down1:lea dx,msg2
call message
lea si,string
loop2:mov b1,[si]
call cnt
cmp b1,0dh
jz down2
jne inc_cnt
inc_cnt:inc si
jne loop2
down2:sub n1,01h
add n1,30h
mov ah,02h
mov d1,n1
int 21h
mov ah,4ch
int 21h
main endp
message proc
mov ah,09h
int 21h
ret
message endp
cnt proc
inc n1
ret
cnt endp
enter_char proc
mov ah,01h
int 21h
ret
enter_char endp
end main
--------------------
Output
-----------
Enter the Sentence: Hello World
The Count is 11

Comments

Popular posts from this blog

Introduction to C++ Programming Language

The Assembly Process Of 8086 Microprocessor-Two Pass Assembling Steps

Installing 8086 Assembler on a Computer