# Writing a MIPS program to find the minimum integer

Page 1 of 1

## 1 Replies - 2357 Views - Last Post: 31 October 2012 - 06:37 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=297855&amp;s=546c34cca85b653828a7576879953627&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 832954

Reputation: 0
• Posts: 4
• Joined: 30-October 12

# Writing a MIPS program to find the minimum integer

Posted 31 October 2012 - 12:11 AM

I am trying to write a MIPS program that prints out the minimum of several integers that should each have 4-bytes. The program should prompt that user to enter the number of integers that will be entered, and then prompt for each of those integer numbers. It should then print out the minimum of the integers entered. Assuming that all user inputs are valid and the user inputs at least one integer number.

Here is the program that I tried on my own, but it doesn't to give the correct output:

################## DATA SECTION ##################
.data
prompt: .asciiz "\n How many integer numbers?(5 integers,minimum)"
result: .asciiz "The minimum integer is "

################## CODE SECTION ##################
.text
.globl main
main:
li \$v0, 4 # system call code for Print String
syscall # print the prompt message

li \$v0, 5 # system call code for Read Integer
syscall # reads the value into \$v0

blez \$v0, end # branch to end if \$v0 < = 0
li \$t0, 0 # clear register \$t0 to zero
loop:
add \$t0, \$t0, \$v0 # sum of integers in register \$t0
addi \$v0, \$v0, -1 # summing integers in reverse order
bnez \$v0, loop # branch to loop if \$v0 is != zero

li \$v0, 4 # system call code for Print String
syscall # print the string

li \$v0, 1 # system call code for Print Integer
move \$a0, \$t0 # move value to be printed to \$a0
syscall # print sum of integers
b main # branch to main
end: li \$v0, 4 # system call code for Print String
syscall # print the string
li \$v0, 10 # terminate program run and
syscall # return control to system

Is This A Good Question/Topic? 0

## Replies To: Writing a MIPS program to find the minimum integer

### #2 GunnerInc

• "Hurry up and wait"

Reputation: 900
• Posts: 2,346
• Joined: 28-March 11

## Re: Writing a MIPS program to find the minimum integer

Posted 31 October 2012 - 06:37 PM

Ooooh, a dup topic! Please don't do that, you won't get help any faster