1 / 4

MIPS Assembly Language Programming

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

barb
Télécharger la présentation

MIPS Assembly Language Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CDA 3101 Discussion Section 05 MIPS Assembly Language Programming

  2. 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.

  3. 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.

  4. 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

More Related