Stacks?

Hey, I'm really sorry for all of the questions but I have another one. I'm using MIPS and I'm kind of confused about the use of stacks. Here is a some code that I hope someone can clarify for me...

##
## factorial function f
## f(0) = 1; f(n) = n * f(n-1)
## f(n) = n*(n-1)*(n-2)*...* 1
##
## version 2: recursive version
##
.text
.globl main
main:
li $v0,4
la $a0,prompt
syscall
li $v0,5
syscall # read n

move $a0,$v0
li $v0,1
syscall # print result
la $a0,words
li $v0,4
syscall
lw $a0,($sp)
add $sp,$sp,4
li $v0,1
syscall
li $v0,10
syscall # exit
##
## if n = 1 or 0, return 1
## else call n*f(n-1)
##
fact:
sub $sp,$sp,8 # make room for 2 bytes
sw $ra,8($sp)
sw $a0,4($sp)
ble $a0,1,ret
##
## recursive step
##
ret:
li $v0,1 # return value is 1
lw $a0,4($sp)
lw $ra,8($sp)
add $sp,$sp,8
jr $ra

.data
prompt: .asciiz "input a low non-neg value: "
words: .asciiz " is the factorial of "

I mainly don't understand what is going on within the fact loop and the ret loop. I think $sp is the register that points to the stack, but I'm not sure what something like 8($sp) does. Also I'm not sure what register $ra is for.
[1414 byte] By [daydreamerz] at [2007-11-20 7:05:29]
# 1 Re: Stacks?
8($sp)

Is a reference to the memory location 8 bytes below (into) the stack pointer.
TheCPUWizard at 2007-11-10 3:55:21 >