Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Mips x32 simple array problem....

Mips x32 simple array problem....

Mips x32 simple array problem....

Hey Everybody... im writing this code for one of my assignments and i need to have an array of size 128 which i do by

drops: .space 128

so that i can take a random number,
use that as the index and store a number 0-8 to it.....

so that in the end when i hit that number it will print out a number 0-8

for example.... say the random number was 32 and i was on the first iteration of the loop it would store 0 in the 32nd spot of the array if i was in the 2 iteration of the array... it would store 1 in the random number eg 92..spot

here is my code:

I first made everything in my array -1 so that i can test to see if something was in it...


li $t1, 0  #counter
li $t2, 0
        la $t6, drops
        bgt $t2, 128, exit
        move $a0, $s5 # send x
        jal getDrop
        move $t2, $v0
        add $t6, $t6, $t2  #random + the whole  
        lb $t3, ($t6)  
        bne $t3, -1, loopStoreRandom
        sb $t1, ($t6)
        addi $t1, $t1, 1
        addi $t2, $t2, 1
        beq $t1, 8, sub8
       j loopStoreRandom

 addi $t1, $t1, -8
 j loopStoreRandom

As you see i wish there was something that i could to just be like sb $t1, $t2($t6) but i cant...

whenever i test the code in exit... ex

lb $t5, 2($t6)
move $a0, $t5
li $v0, 1
li $v0, 10

It prints -1 everytime... and thats not what i want...  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close