Write and test a MIPS assembly language program to count each letter and digit in a text file. The program should do the following: a) Open a text file "data.txt" and read all characters into an array in memory. Limit the length of the array to 10000 characters. The maximum number of characters to be read should be 10000 characters. The actual number of characters depends on the file length. MARS provides the system calls for opening and reading a text file. If the file does not exist then the program should display an error message and terminates. b) Traverse the array character by character. Count all letters, digits, words, and numbers. A word begins with a letter (A-Z or a-z), contains letters only, and ends at a character different from a letter. A number starts with a digit, contains digits only, and ends at any character different from a digit. For example, MIPS32 has the word MIPS and the number 32, even though they are not separated by spaces. Similarly, M5 has the word M and number 5. c) Display the total count of letters, digits, words, or numbers. If file "data.txt" does not exist in the same folder then output the following error message: Error: data.txt does NOT exist. If file "data.txt" exists then output the following: Letters 126 Digits = 27 Words = 35 Numbers = 13

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please written by computer source

code in assembly

Write and test a MIPS assembly language program to count each letter and digit in a text file.
The program should do the following:
a) Open a text file "data.txt" and read all characters into an array in memory. Limit the length
of the array to 10000 characters. The maximum number of characters to be read should be
10000 characters. The actual number of characters depends on the file length. MARS provides
the system calls for opening and reading a text file. If the file does not exist then the program
should display an error message and terminates.
b) Traverse the array character by character. Count all letters, digits, words, and numbers. A
word begins with a letter (A-Z or a-z), contains letters only, and ends at a character different
from a letter. A number starts with a digit, contains digits only, and ends at any character
different from a digit. For example, MIPS32 has the word MIPS and the number 32, even
though they are not separated by spaces. Similarly, M5 has the word M and number 5.
c) Display the total count of letters, digits, words, or numbers.
If file "data.txt" does not exist in the same folder then output the following error message:
Error: data.txt does NOT exist.
If file "data.txt" exists then output the following:
Letters
126
Digits = 27
Words
= 35
Numbers 13
Transcribed Image Text:Write and test a MIPS assembly language program to count each letter and digit in a text file. The program should do the following: a) Open a text file "data.txt" and read all characters into an array in memory. Limit the length of the array to 10000 characters. The maximum number of characters to be read should be 10000 characters. The actual number of characters depends on the file length. MARS provides the system calls for opening and reading a text file. If the file does not exist then the program should display an error message and terminates. b) Traverse the array character by character. Count all letters, digits, words, and numbers. A word begins with a letter (A-Z or a-z), contains letters only, and ends at a character different from a letter. A number starts with a digit, contains digits only, and ends at any character different from a digit. For example, MIPS32 has the word MIPS and the number 32, even though they are not separated by spaces. Similarly, M5 has the word M and number 5. c) Display the total count of letters, digits, words, or numbers. If file "data.txt" does not exist in the same folder then output the following error message: Error: data.txt does NOT exist. If file "data.txt" exists then output the following: Letters 126 Digits = 27 Words = 35 Numbers 13
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Stack operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education