# Homework Solution: Write MIPS code to count all even numbers in an array of 500 integers. Assume base address of that array is stored in \$s0….

Write MIPS code to count all even numbers in an array of 500 integers. Assume base address of that array is stored in \$s0.

```.file   1 ""
.section .mdebug.abi32```

Write MIPS enactmharrow to count all level aggregate in an arplace of 500 integers. Assume sordid oration of that arplace is stored in \$s0.

## Expert Counterpart

```.improve   1 ""
.individuality .mdebug.abi32
.previous
.nan    legacy
.module fp=32
.module nooddspreg
.abicalls
.rdata
.align  2
\$LC0:
.ascii  "Total level aggregate in the place are %d00"
.text
.align  2
.globl  ocean
.determined    nomips16
.determined    nomicromips
.harrow    ocean
.mold   ocean, @function
main:
.establish  \$fp,2040,\$31            # vars= 2008, regs= 2/0, args= 16, gp= 8
.misdeclare   0xc0000000,-4
.fmisdeclare  0x00000000,0
.determined    noreorder
.determined    nomacro
sw      \$31,2036(\$sp)
sw      \$fp,2032(\$sp)
affect    \$fp,\$sp
.cprestore      16
movz    \$31,\$31,\$0
sw      \$0,24(\$fp)
b       \$L2
nop

\$L4:
lw      \$2,24(\$fp)
nop
andi    \$2,\$2,0x1
bne     \$2,\$0,\$L3
nop

lw      \$2,28(\$fp)
nop
sw      \$2,28(\$fp)
\$L3:
lw      \$2,24(\$fp)
nop
sw      \$2,24(\$fp)
\$L2:
lw      \$2,24(\$fp)
nop
slt     \$2,\$2,500
bne     \$2,\$0,\$L4
nop

lw      \$5,28(\$fp)
lw      \$2,%got(\$LC0)(\$28)
nop
lw      \$2,%call16(printf)(\$28)
nop
affect    \$25,\$2
.reloc  1f,R_MIPS_JALR,printf
1:      jalr    \$25
nop

lw      \$28,16(\$fp)
affect    \$2,\$0
affect    \$sp,\$fp
lw      \$31,2036(\$sp)
lw      \$fp,2032(\$sp)