# Register Usage:
#     $s0 for global variables
#
	.text 
 	.globl main 
 main:
	la	$s0, GVARS
#
# Start Code
# 
# Generate Assignment Statement 
	li	$t0,0
	sw	$t0,0($s0)
#
# Generate Loop statement for
LOOP_0:
# 
# Generate Writeln statement 
	la	$a0, S1
	li	$v0, 4
	syscall    # from GenString()
	li	$v0, 1
	lw 	$a0,0($s0)
	syscall
	la	$a0, S0
	li	$v0, 4
	syscall

# 
# Generate Assignment Statement 
	lw	$t0,0($s0)
	add	$t0,$t0,1
	sw	$t0,0($s0)
#
# Generate Exit statement for
	lw	$t0,0($s0)
	seq	$t0,$t0,3
	bne	$t0, 0,LOOP_1
	j	LOOP_0
LOOP_1:
#
# End Loop
# 
# Generate Writeln statement 
	la	$a0, S2
	li	$v0, 4
	syscall    # from GenString()
	la	$a0, S0
	li	$v0, 4
	syscall

# 
# Generate Assignment Statement 
	li	$t0,0
	sw	$t0,0($s0)
#
# Generate Loop statement for
LOOP_2:
# 
# Generate Writeln statement 
	la	$a0, S3
	li	$v0, 4
	syscall    # from GenString()
	li	$v0, 1
	lw 	$a0,0($s0)
	syscall
	la	$a0, S0
	li	$v0, 4
	syscall

# 
# Generate Assignment Statement 
	lw	$t0,0($s0)
	add	$t0,$t0,1
	sw	$t0,0($s0)
#
# Generate Exit statement for
	lw	$t0,0($s0)
	seq	$t0,$t0,3
	bne	$t0, 0,LOOP_3
	j	LOOP_2
LOOP_3:
#
# End Loop
# 
# Generate Assignment Statement 
	li	$t0,0
	sw	$t0,0($s0)
#
# Generate Loop statement for
LOOP_4:
	lw	$t0,0($s0)
	seq	$t0,$t0,0
	beq	$t0, 0,LOOP_5
# 
# Generate Writeln statement 
	la	$a0, S4
	li	$v0, 4
	syscall    # from GenString()
	la	$a0, S0
	li	$v0, 4
	syscall

# 
# Generate Assignment Statement 
	lw	$t0,0($s0)
	add	$t0,$t0,1
	sw	$t0,0($s0)
	j	LOOP_4
LOOP_5:
#
# End Loop
# 
# Generate Writeln statement 
	la	$a0, S5
	li	$v0, 4
	syscall    # from GenString()
	la	$a0, S0
	li	$v0, 4
	syscall

#
# Halt execution
	li	$v0 10
	syscall

#
# Finish up by writing out constants 
	.word 0
CONST:		#Constant storage area
	.data
S0:	.asciiz	"\n"
	.data
S1:	.asciiz	"simple loop, i="
	.data
S2:	.asciiz	""
	.data
S3:	.asciiz	"loop with name exit with loopname and when condition, i="
	.data
S4:	.asciiz	"loop with name and while"
	.data
S5:	.asciiz	"finished"
#
# Reserve space for global variables
	.word 0
GVARS:		# space for Global Variables
	.data
_i:	.word 0	# Offset at 0
	.data
_j:	.word 0	# Offset at 4
	.data
_myName1:	.word 0	# Offset at 8
	.data
_myName2:	.word 0	# Offset at 12
	.data
Temp_Wr:
	.word 0 #just for alignment of write(exprtree)
