.data array: .word # array con 10 numeri interi str_trovato: .asciiz "Trovato\n" str_non_trovato: .asciiz "Non trovato\n" .text .globl main main: # $t0 = indice = 0 # $t1 = lunghezza dell'array # $t2 = numero da cercare (5) # $t3 = indirizzo base dell'array ciclo: beq $t0, $t1, non_trovato # Se indice == 10 → fine array → non trovato # Carica array[i] in $t4 beq $t4, $t2, trovato # Se array[i] == 5 → trovato! ....... # AVANZARE ALL'ELEMENTO SUCCESSIVO DELL'ARRAY. Suggerimento: usare addi e il registro $t3 addi $t0, $t0, 1 # indice++ j ciclo # Ripeti ciclo trovato: li $v0, 4 # print_string la $a0, str_trovato syscall j fine non_trovato: li $v0, 4 la $a0, str_non_trovato syscall fine: TERMINA PROGRAMMA # Exit syscall