Consider the 20 element array shown in figure Assume all ele

Consider the 20 element array shown in figure. Assume all elements are integers. Write a code in MIPS to find the number of elements in the array that are divisible by 5. Mention clearly the registers you are using to hold variables clearly. Assume base address of array is stored in $s0. Easy to read codes with
well placed comments are appreciated!

array[19] array[1] array

Solution

.data

list:.word 10,20,5,2....... #enter numbers from 0th index to 19th

Msg: .asciiz \"numbers which are divisible by 5 are\":

FiveMod : .word 5

.text

Oh $s1, FiveMod

.globl main

ADD $t0, $0, 0

Add $t1, $0, ,0

Or i $t2, $0, 20

La $t3, list

Loop:

Andi $t4, $t4,3

Bne $t4, $zero,not_dibisible

ADD $t1, $t1,1

Not_divisible:

Add $t0, $t0,1

ADD $t3, $t3,5

J loop

Mod:

Add $s2,$s2,1

Add $t0, $t0,1

Add $t3, $t3,5

J loop

End:

Addi $v0,$0,5

La $a0,msg

Syscall

Exit :

J exit

Consider the 20 element array shown in figure. Assume all elements are integers. Write a code in MIPS to find the number of elements in the array that are divis
Consider the 20 element array shown in figure. Assume all elements are integers. Write a code in MIPS to find the number of elements in the array that are divis

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site