Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MIPS Computer Architecture How to write an int to a file in MIPS? I found code for writing an asciiz to a file(shown in the
MIPS Computer Architecture
How to write an int to a file in MIPS? I found code for writing an asciiz to a file(shown in the code below), but the same does not work for an int. For my purposes, I simply am incrementing an int and before exiting the program I want to write the int to a file.
# Sample MIPS program that writes to a new file. # by Kenneth Vollmar and Pete Sanderson .data fout: .asciiz "testout.txt" # filename for output buffer: .asciiz "The quick brown fox jumps over the lazy dog." .text ############################################################### # Open (for writing) a file that does not exist li $v0, 13 # system call for open file la $a0, fout # output file name li $a1, 1 # Open for writing (flags are 0: read, 1: write) li $a2, 0 # mode is ignored syscall # open a file (file descriptor returned in $v0) move $s6, $v0 # save the file descriptor ############################################################### # Write to file just opened li $v0, 15 # system call for write to file move $a0, $s6 # file descriptor la $a1, buffer # address of buffer from which to write li $a2, 44 # hardcoded buffer length syscall # write to file ############################################################### # Close the file li $v0, 16 # system call for close file move $a0, $s6 # file descriptor to close syscall # close file ###############################################################
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