Write an assembly language program to input a string from the user, count and di
ID: 3844584 • Letter: W
Question
Write an assembly language program to input a string from the user, count and display the number of times each word occur in the user input string.
For example if the user types in: "Hello there how are you, there you are Hello Hello you"
Your output should be:
Hello 3
there 2
how 1
are 2
you 3
Write an assembly language program to input a string from the user, count and display the number of times each word occur in the user input string.
For example if the user types in: "Hello there how are you, there you are Hello Hello you"
Your output should be:
Hello 3
there 2
how 1
are 2
you 3
Write an assembly language program to input a string from the user, count and display the number of times each word occur in the user input string.
For example if the user types in: "Hello there how are you, there you are Hello Hello you"
Your output should be:
Hello 3
there 2
how 1
are 2
you 3
Explanation / Answer
Hi,
Please find below the code-
.data
str2 BYTE "Hello there how are you, there you are Hello Hello you",0
.code
main proc
mov edi,OFFSET str2
Mov esi,edi
Mov Ecx, 0 ;reset ecx to 0
Not Ecx ;set Ecx to -1 or highest possible integer
Mov Al, ' ' ;Initialize a1 to delimiter of (space) ' '
Cld ;Clear Direction Pointer
Repne Scasb ;scan edi one byte at a time until delimiter found
Not Ecx
Lea Eax, [ecx-1] ;Set Eax to index of found delimiter
Xchg Esi, Edi ;Take Edi which is now equal to string after found delimiter and put in esi
mov edx, esi
call WriteString
main endp
end main
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.