#Application 7 .text 0x00400000 #Code section start: #Display the message "\nGive Number:" li $v0,4 #Load the function number la $a0,read_int #Load the message starting address syscall #Function call #Read the number li $v0,5 #Load the function number syscall #Function call move $t1,$v0 #Load the number in $t1 blt $t1,1,error #Out of range from the left side, #Goto error bgt $t1,10,error #Out of range from the right side, #Goto error #The number belongs to value range mul $t1,$t1,$t1 #Square calculation ($t1=$t1*$t1) #Display the message "\nX^2=" li $v0,4 #Load the function number la $a0,apot #Load the message starting address syscall #Function call #Display result li $v0,1 #Load the function number move $a0,$t1 #Load the result to be displayed syscall #Function call exodos: #Program termination li $v0,10 #Load the function number syscall #Function call error: #Display the message "\n ERROR! #Out of range [1,10]" li $v0,4 #Load the function number la $a0,error_msg #Load the message starting address syscall #Function call j start #return to start, read new number .data #Data section error_msg: .asciiz "\n ERROR! Out of range [1,10]" apot: .asciiz "\nX^2=" read_int: .asciiz "\nGive Number:"