Nios/mins

From ASMBits

nios/maxs8Previous

Write a function that returns the minimum value out of an array of 32-bit signed words.

The function has two parameters. The first parameter is the length of the array (at least 1). The second parameter is a pointer to the beginning of the array.

int min ( unsigned int length, int *array );


Sample Input

[1, 2, 3]

Sample Output

r2=1

Write your solution here

x
 
1
# A test case to test your function with
2
Array: .word 1, 2, 3
3
4
.global _start
5
_start:
6
    movia r4, 3 
7
    movia r5, Array
8
    call min
9
    br _start        # End of testing code
10
11
# Return minimum element of signed array
12
min:
13
    
14
    
Upload a source file...