Checking for empty strings in SPIM

liunx

Guest
This is what i got so far. <br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><br />loop:<br />    la         $v0,8        #takes an input<br />    syscall<br />    move   $t0,$v0<br /><br />    sw       $t1, \n<br />                            #Branch if input is empty string.<br />    beq     $t0, $t1, done<br />        <br />    j loop<br /><br />done:<br />    #etc...<br /><!--c2--></div><!--ec2--><br /><br />I have no clue if i'm on the right track or not. This is one of my first times using SPIM<br /><br />Any help is appreciated. <br /><br />I'm basically trying to loop while my input is not an empty string.<br /><br />I'm getting an error at the "sw" line. I could be doing this totally wrong, if thats the case i would appreciated being told <img src="http://static.dreamincode.net/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /><br />I don't really need someone to do this for me, just hints on how to check for an empty string. <img src="http://static.dreamincode.net/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /><br /><br />From what I've been getting from my book bne is for not equal and beq is for equal comparisons. <br /><br />Thanks in Advance <img src="http://static.dreamincode.net/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
</div>
 
Back
Top