#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>
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
-file>