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

write an msp430 assembly language filtering subroutine,clipfilter,... Question W

ID: 3674642 • Letter: W

Question

write an msp430 assembly language filtering subroutine,clipfilter,... Question Write an MSP430 assembly language filtering subroutine,ClipFilter, to examine the elements of a list of positive word-size numbers stored at location pointed to by R5. These numbers are actually the digitized values of a sample of analog wave form. The first word inthe list is the length of the list. The secondword inthe list is the max value before clipping starts. The subroutine will scan the whole list and clips all values which exceed the max. Clipping means replacing any value which exceeds themax with max value itself.

Explanation / Answer

.data
   R5: .word 10, 5, 2, 7, 2, 6, 9, 0, 5, 5
.text

   main:  
       jal ClipFilter
      
       li $v0, 10
       syscall
  
   ClipFilter:  
           la $t0, R5   # $t0 points to R5
           lw $t1, ($t0)   # $t1 has number of digits
           lw $t2, 4($t0)   # $t2 has max Clipping value
          
           li $t3, 2   # iterator for this list
           while:   bge $t3, $t1, end
               sll $t4, $t3, 2       # $t4 has address of each element in list
               lw $t5, R5($t4)       # get the digit into $t5
               if:   ble $t5, $t2, endif
                   sw $t2, R5($t4)
               endif:   addi $t3, $t3, 1
               b while
           end:  
           jr $ra