SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Important Note: This code needs to be able to compile in Microsoft Visual Studio.
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
Solution
DisplayTable PROC
;
; Display the non-empty entries of the frequency table.
; This procedure was not required, but it makes it easier
; to demonstrate that Get_frequencies works.
;-------------------------------------------------------------
.data
colonStr BYTE ": ",0
.code
call Crlf
mov ecx,LENGTHOF freqTable ; entries to show
mov esi,OFFSET freqTable
mov ebx,0 ; index counter
;; tigher version of your char-count loop
xor eax, eax ; clear upper bits of EAX
L1:
lodsb ; AL = [ESI], inc ESI
inc DWORD PTR [edi + eax*4] ; inc table[AL]
test al,al ; Set flags based on AL
jz L1 ; loop if it's not the end of the string
;; fall through when done
;;dec DWORD PTR [edi] ; undo the count of the zero if you care
L2: add esi,TYPE freqTable ; point to next table entry
inc ebx ; increment index
loop L1
call Crlf
ret
DisplayTable ENDP
END main
.data
str2 BYTE "one two three",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

Weitere ähnliche Inhalte

Ähnlich wie Count and display word frequencies in a string

Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamDr. Girish GS
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptMuhammad Sikandar Mustafa
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 
Assembly language programs 2
Assembly language programs 2Assembly language programs 2
Assembly language programs 2HarshitParkar6677
 
Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2SANTIAGO PABLO ALBERTO
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly LanguageAhmed M. Abed
 
lec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdflec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdfhasan58964
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
 
Creating a Fibonacci Generator in Assembly - by Willem van Ketwich
Creating a Fibonacci Generator in Assembly - by Willem van KetwichCreating a Fibonacci Generator in Assembly - by Willem van Ketwich
Creating a Fibonacci Generator in Assembly - by Willem van KetwichWillem van Ketwich
 
N_Asm Assembly numbers (sol)
N_Asm Assembly numbers (sol)N_Asm Assembly numbers (sol)
N_Asm Assembly numbers (sol)Selomon birhane
 
How to recover malare assembly codes
How to recover malare assembly codesHow to recover malare assembly codes
How to recover malare assembly codesFACE
 
3CA949D5-0399-46AE-8A97-F01C8599B2DA.pdf
3CA949D5-0399-46AE-8A97-F01C8599B2DA.pdf3CA949D5-0399-46AE-8A97-F01C8599B2DA.pdf
3CA949D5-0399-46AE-8A97-F01C8599B2DA.pdfSantoshDeshmukh36
 

Ähnlich wie Count and display word frequencies in a string (20)

Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progam
 
Assembly language programs
Assembly language programsAssembly language programs
Assembly language programs
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
 
Advance ROP Attacks
Advance ROP AttacksAdvance ROP Attacks
Advance ROP Attacks
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Assembly language programs 2
Assembly language programs 2Assembly language programs 2
Assembly language programs 2
 
Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2
 
[ASM]Lab5
[ASM]Lab5[ASM]Lab5
[ASM]Lab5
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly Language
 
Taller Ensambladores
Taller EnsambladoresTaller Ensambladores
Taller Ensambladores
 
lec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdflec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdf
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
Verilogforlab
VerilogforlabVerilogforlab
Verilogforlab
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
 
Creating a Fibonacci Generator in Assembly - by Willem van Ketwich
Creating a Fibonacci Generator in Assembly - by Willem van KetwichCreating a Fibonacci Generator in Assembly - by Willem van Ketwich
Creating a Fibonacci Generator in Assembly - by Willem van Ketwich
 
N_Asm Assembly numbers (sol)
N_Asm Assembly numbers (sol)N_Asm Assembly numbers (sol)
N_Asm Assembly numbers (sol)
 
[ASM]Lab4
[ASM]Lab4[ASM]Lab4
[ASM]Lab4
 
How to recover malare assembly codes
How to recover malare assembly codesHow to recover malare assembly codes
How to recover malare assembly codes
 
Chapter1c
Chapter1cChapter1c
Chapter1c
 
3CA949D5-0399-46AE-8A97-F01C8599B2DA.pdf
3CA949D5-0399-46AE-8A97-F01C8599B2DA.pdf3CA949D5-0399-46AE-8A97-F01C8599B2DA.pdf
3CA949D5-0399-46AE-8A97-F01C8599B2DA.pdf
 

Mehr von mckerliejonelle

What was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxWhat was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxmckerliejonelle
 
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxWhat subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxmckerliejonelle
 
what type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxwhat type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxmckerliejonelle
 
What skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxWhat skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxmckerliejonelle
 
What pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxWhat pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxmckerliejonelle
 
What percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxWhat percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxmckerliejonelle
 
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxWhat makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxmckerliejonelle
 
What motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxWhat motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxmckerliejonelle
 
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxWHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxmckerliejonelle
 
What is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxWhat is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxmckerliejonelle
 
What is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxWhat is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxmckerliejonelle
 
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxWhat is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxmckerliejonelle
 
What is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxWhat is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxmckerliejonelle
 
What is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxWhat is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxmckerliejonelle
 
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxWhat is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxmckerliejonelle
 
What is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxWhat is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxmckerliejonelle
 
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxWhat is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxmckerliejonelle
 
What is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxWhat is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxmckerliejonelle
 
What is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxWhat is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxmckerliejonelle
 
What is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxWhat is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxmckerliejonelle
 

Mehr von mckerliejonelle (20)

What was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxWhat was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docx
 
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxWhat subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
 
what type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxwhat type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docx
 
What skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxWhat skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docx
 
What pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxWhat pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docx
 
What percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxWhat percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docx
 
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxWhat makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
 
What motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxWhat motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docx
 
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxWHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
 
What is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxWhat is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docx
 
What is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxWhat is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docx
 
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxWhat is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
 
What is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxWhat is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docx
 
What is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxWhat is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docx
 
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxWhat is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
 
What is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxWhat is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docx
 
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxWhat is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
 
What is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxWhat is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docx
 
What is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxWhat is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docx
 
What is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxWhat is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docx
 

Kürzlich hochgeladen

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 

Kürzlich hochgeladen (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 

Count and display word frequencies in a string

  • 1. Important Note: This code needs to be able to compile in Microsoft Visual Studio. 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 Solution DisplayTable PROC ; ; Display the non-empty entries of the frequency table. ; This procedure was not required, but it makes it easier ; to demonstrate that Get_frequencies works. ;------------------------------------------------------------- .data colonStr BYTE ": ",0 .code call Crlf mov ecx,LENGTHOF freqTable ; entries to show mov esi,OFFSET freqTable mov ebx,0 ; index counter ;; tigher version of your char-count loop xor eax, eax ; clear upper bits of EAX L1: lodsb ; AL = [ESI], inc ESI inc DWORD PTR [edi + eax*4] ; inc table[AL] test al,al ; Set flags based on AL jz L1 ; loop if it's not the end of the string ;; fall through when done ;;dec DWORD PTR [edi] ; undo the count of the zero if you care
  • 2. L2: add esi,TYPE freqTable ; point to next table entry inc ebx ; increment index loop L1 call Crlf ret DisplayTable ENDP END main .data str2 BYTE "one two three",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