can you guys check whats wrong with my code...
the output must be:
Example
String entered: The quick brown fox jump over the lazy dog
number of words:9
number of characters:36
my output is: a smile and some characters
i cant really understand this language yet..
How to count the words and characters in a string?
thanks!!
.model small .stack .data str1 db "Enter a sentence>>","$" str2 db 0AH,0Dh,"Number of words>>","$" str3 db 0AH,0Dh,"Number of letters>>","$" var1 db ?,"$" var2 db ?,"$" .code mov ax,@data mov ds,ax mov ah,9 lea dx,str1 int 21h startloop: ;loop for . mov ah,01h int 21h cmp al,"." ;compare . je jump1 ;jump1 cmp al,20h ;compare space add var2,1 je jump2 ;jump2 loop startloop ;loop for . jump1: ;jump1 mov ah,9 lea dx,str2 int 21h add var1,1 mov ah,9 lea dx,var1 int 21h jump2: ;jump2 mov ah,9 lea dx,var1 int 21h mov ah,9 lea dx,str3 int 21h mov var2,ch mov ah,9 lea dx,var2 int 21h mov dl,bl add dl,01h mov ah,2 int 21h jmp exit exit: mov ah,4ch int 21h end

New Topic/Question
Reply



MultiQuote


|