beq x0, x0 main test: addi t0, x0, 4 blt a0, t0, is_prime addi t0, x0, 2 rem t1, a0, t0 beq t1, x0, is_not_prime addi t1, x0, 3 div t2, a0, t0 addi t2, t2, 1 #addi t2, x0, 32 #todo: t2 = min((t2)/2, 32) prime_loop: rem t0, a0, t1 beq t0, x0, is_not_prime addi t1, t1, 2 blt t1, t2, prime_loop is_prime: addi a0, x0, 1 jalr ra is_not_prime: addi a0, x0, 0 jalr ra main: add t3, x0, ra lw t5, 0(x0) #size lw t6, 4(x0) #pointer #lw t5, size #la t6, array addi t4, x0, 2 sll t5, t5, t4 add t5, t6, t5 main_loop: beq t5, t6, end lw a0, 0(t6) jal ra, test sw a0, 0(t6) addi t6, t6, 4 beq, x0, x0, main_loop end: add ra, x0, t3 beq x0, x0, end