Question
Write a MIPS assembly program that asks the user for file name (max 50 chars). Open the file for reading. Next, read the file contents
Write a MIPS assembly program that asks the user for file name (max 50 chars). Open the file for reading. Next, read the file contents as characters (max 100 chars). After that, loop over each character, if the character is a digit (i.e. 0 to 9), convert it to integer and store it in another array called array_int. Assume the maximum number of integers in the file is 20. Finally, print array_int in reverse order. (Create a text file "numbers.txt" with the contents mentioned in the given sample.txt below and use it)
Sample numbers.txt file
1 2 3 4 5 6 7 9 hello, world 851 |
Static Data segment (Use this under .data directive)
.data filename: .space 50 filecontents: .space 100 array_int: .word 0:20 ... |
Sample Run:
Enter filename: numbers.txt Integer array reversed: 1 5 8 9 7 6 5 4 3 2 1 |
Please only provide answers after testing and running the code as I don't want my question to be wasted by someone who copy-pastes the wrong answers here. Post the correct answer if you need up-vote.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started