Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

#This code is in MIPS # You will read characters (bytes) from a file (lab2_data.dat) and print them. Valid characters are only spaces (ASCII code

#This code is in MIPS

# You will read characters (bytes) from a file (lab2_data.dat) and print them. Valid characters are only spaces (ASCII code 32), #Exclamation points (ASCII code 33), and uppercase letters (A-Z). #Lower case letters should be converted to uppercase and eveything else should be discarded #The expected output should be in one line and read: THIS WAS A SUCCESS! # $a1 : address of the input buffer file_read:

# Open File

li $v0, 13 # 13=open file la $a0, file # $a2 = name of file to read add $a1, $0, $0 # $a1=flags=O_RDONLY=0 add $a2, $0, $0 # $a2=mode=0 syscall # Open FIle, $v0<-file descriptor (fd) add $s0, $v0, $0 # store fd in $s0 # Read file and store it in the buffer

li $v0, 14 # 14=read from file add $a0, $s0, $0 # $s0 contains fd la $a1, buffer # buffer to hold string li $a2, 30 # Read 30 characters syscall

############################### Part 3: your code begins here ##

############################### Part 3: your code ends here ## # Close File

done: li $v0, 16 # 16=close file add $a0, $s0, $0 # $s0 contains fd syscall # close file

jr $ra

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions