Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write MIPS code to search through array X of word size unsigned integers to find

ID: 3768570 • Letter: W

Question

Write MIPS code to search through array X of word size unsigned integers to find how many of the values are divisible by 4. Place the result is $s2 and print to screen. The array X ends with a zero. Include code that counts the number of ones in the binary number stored in $s2 from part A. Place the result in $s3. Print to screen. Example x: word 5,4,8,12,13,16,18,20,24,23,0 After execution $s2= 6 $s3 = 2 Printed to the screen: The number of values that are divisible by 4 = 6 The number of ones in the binary number = 2

Explanation / Answer

# April 21st, 2015 ######################################################################## # Main program description: # Search a predefined array of numbers for a minimum and maximum value # Determine how many numbers stored in the array are evenly divisable by 4 # Arguments: None. # # Returns: Nothing. ######################################################################## .data X: .byte 31, 17, 92, 46, 172, 208, 13, 93, 65, 112 N: .word 10 min: .asciiz "Minumum Value: " max: .asciiz " Maximum Value: " value: .asciiz " Values divisible by 4: " .text main: la $s0, X la $s1, N #Stack frame addiu $sp, $sp, -24 sw $s0, 0($sp) sb $s1, 4($sp) sb $t2, 8($sp) jal MaxMin #function call to MaxMin li $v0, 4 # Call code to print a string la $a0, min # Print string syscall li $v0, 1 # Call code to print an integer lw $a0, # Print integer syscall li $v0, 4 # Call code to print a string la $a0, max # Print string syscall li $v0, 1 # Call code to print an integer lw $a0, # Print integer syscall ######################################################################## # Description: # Searches through the array, finding the min and max value. # # Arguments: # 0($sp): starting address of array # 4($sp): number of array elements # ######################################################################## MaxMin: lw $t3, 0($sp) # get &X lb $t4, 4($sp) # get N ######################################################################## # Description: # Searches through the array, finding the min and max value. # # Arguments: # 0($sp): starting address of array # 4($sp): number of array elements # ######################################################################## Div4Count: lw $t5, 0($sp) # get &X lb $t8, 4($sp) # get N

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote