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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section8.3: Random File Access
Problem 6E
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr