#Application 12 .text 0x00400000 #Code section main: li $t2,1 #Loop counter #$t1=deviation counter #$t4=positive numbers counter #$t5=negative numbers counter #$t6=zero numbers counter again: #Fill array #Display the message "Pos[" li $v0,4 #Load the function number la $a0,mes1 #Load the message starting address syscall #Function call #Display counter (current number) li $v0,1 #Load the function number move $a0,$t2 #Load the number to be displayed syscall #Function call #Display the message "]=" li $v0,4 #Load the function number la $a0,mes2 #Load the message starting address syscall #Function call #Read number (keyboard) li $v0,5 #Load the function number syscall #Function call move $t0,$v0 #Load number in $t0 sw $t0,arrayA($t1) #Store number starting from #the address arrayA+$t1 (4 byte) add $t1,$t1,4 #Update deviation counter add $t2,$t2,1 #Update loop counter ble $t2,10,again #If all the number have not #been read go to again #Read array li $t2,1 #Initialize loop counter li $t1,0 #Initialize deviation counter again2: lw $t3,arrayA($t1) #Read number starting from #arrayA+$t1 bgtz $t3,einai_meg_msg #If number > 0 bltz $t3,einai_mik_msg #If number < 0 add $t6,$t6,1 #Update zero numbers counter return: #return point add $t1,$t1,4 #Update deviation counter add $t2,$t2,1 #Update loop counter ble $t2,10,again2 #If all the numbers have #not been read, go to again2 #Display the message "\n(>0):" li $v0,4 #Load the function number la $a0,meg_msg #Load the message starting address syscall #Function call #Display positive numbers counter li $v0,1 #Load the function number move $a0,$t4 #Load the number to be displayed syscall #Function call #Display the message "\n(<0):" li $v0,4 #Load the function number la $a0,mik_msg #Load the message starting address syscall #Function call #Display negative numbers counter li $v0,1 #Load the number to be displayed move $a0,$t5 #Load the message starting address syscall #Function call #Display the message "\n(=0):" li $v0,4 #Load the function number la $a0,miden_msg #Load the message starting address syscall #Function call #Display zero numbers counter li $v0,1 #Load the function number move $a0,$t6 #Load the number to be displayed syscall #Function call #Program termination li $v0,10 #Load the function number syscall #Function call einai_meg_msg: #Section for positive numbers add $t4,$t4,1 #Update positive numbers counter j return #Return to main loop einai_mik_msg: #Section for negative numbers add $t5,$t5,1 #Update negative numbers counter j return #Return to main loop .data #Data section mes1: .asciiz "Pos[" mes2: .asciiz "]=" meg_msg: .asciiz "\n(>0):" mik_msg: .asciiz "\n(<0):" miden_msg: .asciiz "\n(=0):" .align 2 #Array organization arrayA: .space 40 #Array declaration