ICS 51 Lab 3 MIPS

res += catalan_recur(i) * catalan_recur(n-i-1) return res;
>> a0: the argument for the given positive integer input, n
3A. Complete load_pts_file function that reads multiple pairs of numbers from a file and finds the distance between every two numbers on a number line:
Few steps as the guidance
1) Open/Read the .dat file into a pre-allocated given space, data_buffer. 2) The format is fixed in every single line of the file, parse the content
and interpret each as an integer number.
3) Finding distances from the every-two-number, iteratively store the distance to an integer array
(note: the base address is given in $a1).
4) Return the number of distances calculated.
For example,
lab3_pts.dat Integer Array for Distances Return Value
11 12 -3 4 11 -12
[-1, -1, -1, -1, -1] [After]
[1, 1, 7, 23, -1]
The above example shows that load_pts_file function
– opens/reads lab3_pts.dat file (into data_buffer),
– parses and interprets ‘1’ as the integer numbers, 1, and ‘2’ as 2
– finds the distance of 1 and 2 to be 1 and updates the distance array
– repeats the above two until the end of file, then returns 4 distances calculated.
浙大学霸代写 加微信 cstutorcs
NOTE: you can safely assume
I. the file will strictly follow such format in every single line.
II. there will be at least one line in the file.
III. The file won’t exceed 300 bytes, i.e. you don’t need to worry about out of memory in the given space, data_buffer. IV. The default values in data_buffer were all 0.
Arguments and Given parameters:
>> $a0: the address of the string that represents the input file name, “lab3_pts.dat”.
>> $a1: the base address of an integer array that will be used to store distances
>> data_buffer: the buffer that you use to hold data for file read/write (MAXIMUM: 300 bytes)
3B. Complete save_dist_list function that saves N distances’ values into a file For example,
Integer Array for Distances
Number of Distances to Save
lab3_dist.dat
[1, 1, 7, 23, -1]
Note: the NEWLINE character (at the end of every line) is not visible.
The above example shows that save_dist_list function takes 4 distances from the distance array, converts integers into ASCII characters, as a result of “1 1 7 2 3 ” in the data_buffer, then makes syscall to write 9 characters from this string into lab3_dist.dat file.
Thought before starting to code: How to convert 23 into ‘2’, ‘3’? other examples, 123 -> ‘1’, ‘2’, ‘3’?

Code Help, Add WeChat: cstutorcs
NOTE: you can safely assume
I. The distances to save are guaranteed positive/valid, e.g. N=4, the first four numbers in the array must be positive.
Arguments and Given parameters:
>> $a0: the address of the string that represents the output file name, “lab3_dist.dat”.
>> $a1: the base address of an integer array that stores distances
>> $a2: the number of distances to save from an integer array
>> data_buffer: the buffer that you use to hold data for file read/write (MAXIMUM: 300 bytes)
Side Note:
If you have finished part3A, you may un-comment the code block (line 233-234 in lab3_test.asm) to forward part3A result to be part3B input. Therefore, by orchestrating with part3A, part3B can save found distances, originally from a points file, lab3_pts.dat, into a distance file, lab3_dist.dat.
Submission instructions
Please upload the modified “lab3.asm” to Gradescope under Assignment “Lab3”. The autograder will test against the given (case1) as well as hidden (case2) test cases. Only upload lab3.asm to Gradescope, NOTHING ELSE.
Code Help