title: Creating a single linked list
body: <p>I am supposed to create a single linked list with MIPS then sort it etc. Here is a piece of my code:</p>
  
  <pre><code>   .data
  STR_NEWLINE:    .asciiz     "\n"
  STR_ENTER:      .asciiz     "enter an integer(0 to finish): "
  
       .text
  main:
      sw      $zero,0($sp)                # list_head = 0
      move    $s0,$sp                 # list_end adress
  main_loop:
      la      $a0,STR_ENTER           
      li      $v0,4
      syscall
  
      li      $v0,5                   
      syscall
  
      blez    $v0,bubble_loop         
  
      addi $sp, $sp, -8               
  
      sw      $v0,0($sp)              
      sw      $t0,4($sp)              
      move    $s0,$sp                 
  
      addi $t0, $t0, -8              
      j       main_loop
  </code></pre>
  
  <p>It works well, it gets inputs from the user, stores them on the memory, sorts and prints as well. But the problem (may be not) is i am not sure is it a real linked list because as I know linked list structure is like:</p>
  
  <p>| data | pointerToAnywhere | ... | data | pointerToAnywhere |</p>
  
  <p>But in my code it's like one after another always, so there is no point to have pointers if next input can't be stored in any empty place in memory.</p>
  
  <p>To sum up, how should i improve my code to have $sp = (any empty place in the memory) instead of "addi $sp, $sp, -8"?</p>