【MIP编程】计算1+2+3+4+……+N
编程环境:PCspim
1 .text 2 .globl main 3 4 main: 5 la $a0,input_num_msg; 6 li $v0,4 7 syscall 8 9 li $v0,5 10 syscall 11 12 move $t8,$v0 13 move $t0,$zero 14 15 plus: 16 add $t0,$t0,$t8 17 sub $t8,$t8,1 18 slti $t2,$t8,1 19 beq $t2,0,plus 20 21 la $a0,output_int_msg; 22 li $v0,4 23 syscall 24 25 move $a0,$t0 26 li $v0,1 27 syscall 28 29 .data 30 input_num_msg:.asciiz "Please enter the number:\n" 31 output_int_msg:.asciiz "The plused number is:\n"