#include <mips.h>

.text
.globl main

main:
        /* Function prolog. 		*/
        /* Sets up environment for user program to execute. 		*/
        addiu   sp, sp, -32  /* Make room on Stack for O/S values.  */
        sw      ra, 28(sp)   /* Store O/S return address on Stack.  */
        /* Start of your program. 	*/

	move	s0, zero
loop:	
	jal	getnum
	addu	s0, s0, v0
	bne	v0, zero, loop
		
done:   move    a0, s0
        jal     printnum        /* Total */


	/* End of your program. 	*/
        /* Function epilogue. 		*/
        /* Restores the environment from the O/S. */
        lw	ra, 28(sp)  /* Restore O/S return address.              */
        addiu	sp, sp, 32  /* Restore O/S stack pointer.               */
	li	v0, 0       /* Return value of 0 (normal exit).         */
        jr		ra          /* Return to Operating System.         	*/
