what i have to do is Write a program that reads a sentence from the keyboard and counts the number
of words and characters entered. Terminate the sentence with special character (of your choice).
Display results on screen.
and this is what i have so far:
TITLE Read Sentences (ReadSentences.asm)
;I want to read Sentence and then
;Count the number of words
INCLUDE Irvine32.inc
.data
buffer BYTE 100 DUP(0)
byteCount DWORD ?
aName BYTE ?
wordCount BYTE 0
charCount BYTE 0
Display1 BYTE "Please Enter Sentence: ",0
Display2 BYTE "The total amount of words is: ",0
.code
main PROC
mov edx, offset Display1
call WriteString
mov edx, offset buffer
mov ecx, (SIZEOF buffer)
call ReadString
mov byteCount, eax
;mov aName, edx
call WriteString
mov esi, 0
L1:
movzx eax, aName[esi]
cmp eax,2Eh ;(32) Check if character is period (hexadecimal value for period is 2E)
JE L3
cmp eax, 20 ; check if character is space (hexadecimal value for space is 20)
JE L2
;mov eax,[charCount+1] ;(41) increment character count
;inc charCount+1
mov eax,[esi+1] ; increment esi
;inc esi
Loop L1 ; loop L1
L2:
inc esi
; increment word count space
; increment esi
Loop L1
L3:
;mov eax, [wordCount+1] ;increment word count
inc wordcount
;then just print out character count and word count
exit
main ENDP
end main