40 likes | 250 Views
CDA 3101 Discussion Section 05. MIPS Assembly Language Programming. Problem1. Write a function MinMax(&X, N) to find the minimum and maximum of an array X of N integers. The address of the array is passed in $a0, and the number of words in the array
E N D
CDA 3101 Discussion Section 05 MIPS Assembly Language Programming
Problem1 Write a function MinMax(&X, N) to find the minimum and maximum of an array X of N integers. The address of the array is passed in $a0, and the number of words in the array is passed in $a1. The minimum and maximum are returned in registers $v0 and $v1 respectively. Also, write a short main program that • Prompts user to enter 10 integers one by one to fill a global integer array X of size 10 • Calls the MinMax function to find and return the minimum and maximum of the array X. • Prints the minimum and the maximum value.
Problem2 Implement the recursive function sillymultiply() given below in the MIPS assembly language. int sillymultiply(int x, int y) { int ret; if (y == 1) return x; ret = x + sillymultiply(x, y-1); return ret; } Also, write a short main function that prompts the user to enter the integers x and y calls the sillymultiply() function to compute x*y and prints the value returned by the sillymultiply(x,y) function.
Some Key Points • Read an integer from standard input li $v0, 5 # Read_int system service syscall # Read x move $t0, $v0 # $t0 = $v0 = result of read = x