print macro msg
lea dx,msg
mov ah,09h
int 21h
endm
.model small
.stack 100h
.data
s1 db 10,13,'Enter a sentance $'
s2 db 10,13,'The no of words in the string is $'
s3 db 50 dup('$')
.code
mov ax,@data
mov ds,ax
print s1
mov dx,offset s3
mov bx,00h
mov ah,3fh
int 21h
sub ax,02
mov si,00h
mov cx,ax
xor dx,dx
mov bl,32d
cmp cx,00
je prin
labl:cmp bl,s3[si]
jnz labl1
inc dx
labl1:inc si
loop labl
dec si
cmp bl,s3[si]
jz prin
inc dx
prin: mov bx,000ah
mov ax,dx
xor cx,cx
print1: xor dx,dx
div bx
push dx
inc cx
cmp ax,0000h
jne print1
print s2
display:pop dx
add dl,30h
mov ah,02h
int 21h
loop display
mov ah,4ch
int 21h
end
No comments:
Post a Comment