Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 23rd, 2011, 02:51 AM
basketball8533 basketball8533 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2010
Posts: 1 basketball8533 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 42 sec
Reputation Power: 0
(Assembly) Mips x32... array help..

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...

Code:
storeArray: 
la $t6, drops
li $t1, 0  #counter
li $t2, 0
loopStoreRandom:
        bgt $t2, 128, exit
        la $t6, drops
        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



sub8: 
 addi $t1, $t1, -8
 j loopStoreRandom


so 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
Code:
exit:
lb $t5, 32($t6)
move $a0, $t5
li $v0, 1
syscall
li $v0, 10
syscall


it prints different numbers everytime i change the index in my test code... ex lb $t5, 2($t6) prints out a -120

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > (Assembly) Mips x32... array help..

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap