Simple For loop in Mips

Posted on 2007-07-24
Last Modified: 2013-12-13
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
Question by:Mikal613
    LVL 14

    Accepted Solution

    Take a look at this example:


      Nayer Naguib
    LVL 48

    Author Comment

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

    Where do i put $s0 ?
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    Title # Comments Views Activity
    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++.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now