Solved

# Simple For loop in Mips

Posted on 2007-07-24
5,503 Views
Question:
In C
for (i=0; i<n-1; i++)
{

}
--> Mips  Also i plan on using #s0 to hold that 10 so if you can use that variable in the conversion. Thanks
??
0
Question by:Mikal613

LVL 14

Accepted Solution

Take a look at this example:

http://www.informatics.sussex.ac.uk/users/emmet/comp_sys_arch/MIPS_loops.pdf

______________

Nayer Naguib
0

LVL 48

Author Comment

MIPS Code
li \$s0, 0
for_loop: #
# some code
#
blt \$s0, \$s1, for_loop
#
# code continues out of loop

Where do i put \$s0 ?
0

LVL 14

Expert Comment

This example uses \$s0 as the loop counter (i in your code), and \$s1 as the terminating value (n-1 in your code). Therefore, the code is equivalent to the following:

for ( \$s0 = 0; \$s0 < \$s1; \$s0++)
{
// some code
}

______________

Nayer Naguib
0

## Featured Post

### Suggested Solutions

withoutTen challenge 14 68
seriesUp challenge 7 79
Visual xHarbour 1 47
bunnyEars challenge 6 45
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilationâ€¦
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.