#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Max/min array help

Member Posts: 2
I started trying to learn mips asm in my free time using some online tutorials that I found. In one of the tutorials it asks me to use an array and determine the smallest and greatest value using these numbers:
23, -23, 45, -32, 52, -72, 8, 13. I'm am completely lost. Unfortunately these online tutorials have NO solutions along side their questions, so I have no clue how to even begin, let alone where I can find a result. Any help on this one?

• Member Posts: 6,519
: I started trying to learn mips asm in my free time using some online tutorials that I found. In one of the tutorials it asks me to use an array and determine the smallest and greatest value using these numbers:
: 23, -23, 45, -32, 52, -72, 8, 13. I'm am completely lost. Unfortunately these online tutorials have NO solutions along side their questions, so I have no clue how to even begin, let alone where I can find a result. Any help on this one?
:
[blue]I do not know MIPS assembler, but here is an algorithm to get the min/max values out of an array:

In the steps below I will use these names:

MIN = register loaded with minimum value
MAX = register loaded with maximum value
C = register with count of values in array
V = temporary register with integer value
[green]
2. Load C with (array size - 1) (7 in your case)

5. A = A + size of a single array element
6. C = C - 1
7. V = value at address A

8. if (V > MAX) THEN MAX=V
9. if (V < MIN) THEN MIN=V

10. if (C > 0) THEN GOTO #5

11. END
[/green]
At this ^^^ point register MIN will contain minimal value from an array and register MAX will contain maximum value from the same array.
[/blue]