title: How to pop from the stack in MIPS assembly?
body: <p>I'm trying to learn MIPS assembly, since I've got some free time, and I'm trying to write a program that pushes numbers on to a stack, then pops them off. I want it to count the number of numbers popped before reaching a negative number and then each time it gets a negative one keep count of how many negative and positive numbers were popped. </p>
  
  <p>so far I got this:</p>
  
  <pre><code> #count the number of negative words on the stock by poping the stack until a non-    negative word is found 
  #and print out the number of words found
  
  .text
  .globl main
  #this code reads the numbers from the data area and stores in them in a stack
  #the numbers are located in the test area and the number of numbers in the num area
  
  main:   la $t0, test
  lw $t1, num
  loop:   lw $t2,($t0)
  sub $sp, $sp, 4
  sw $t2($sp)
  add $t0, $t0, 4
  add $t1, $t1, -1
  bnez $t1, loop
  
  
  #pop from the stack and print the number of numbers in the stack before a nonnegative number is reached 
  #then keep count of how many negative and positive ones there are total
  
  #code I cannot come up with would go here
  
  .data
  test:   .word
  2, 0xfffabfff,2,-4,-9,0x99999999,0x90000000,-2147479536,0x80000000
  num:    .word 10
  ans:    .asciiz "Number is = "
  endl:   .asciiz "\n"
  </code></pre>
  
  <p>I got it to push right, far as I can tell, but I cannot figure out the pushing and counting right.  what do I have to do from here?</p>