Write an MSP430 assembly language subroutine, REP_FREE, to examine the elements
ID: 3861329 • Letter: W
Question
Write an MSP430
assembly language subroutine, REP_FREE, to examine the elements of a list of positive word_size numbers stored at location LIST_IN. the list is already sorted in an ascending order. the first element is the number, n, the length of the array. the subroutine will copy the elements from the location LIST_IN to the location LIST_OUT. while copying, if an element occurs more than once (repeated), then repeated copies are ignored. In essence, the subroutine eliminates the replicated element from LIST_IN and places the result in LIST_OUT. Note that you need to update number m (the first element on the top) which is the actual number of elements in LIST_OUT after eliminating replicates.
Thank You!
Explanation / Answer
#include "msp430.h" ; #define controlled include file
NAME main ; module name
PUBLIC main ; make the main label vissible
; outside this module
EXTERN suma_rp
ORG 0FFFEh
DC16 init ; set reset vector to 'init' label
RSEG CSTACK ; pre-declaration of segment
RSEG CODE ; place program in 'CODE' segment
init: MOV #SFE(CSTACK), SP ; set up stack
main: NOP ; main program
MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer
BIS.B #0xFF,&P1DIR ; configure P1.x as output
BIS.B #0xFF,&P2DIR ; configure P2.x as output
BIS.B #0xFF,&P3DIR ; configure P3.x as output
BIS.B #0xFF,&P4DIR ; configure P4.x as output
MOV #arr1, R12 ; put address into R12
MOV #8, R13 ; put array length into R13
MOV #0, R14 ; display #0 (P1&P2)
CALL #suma_rp
MOV #arr2, R12 ; put address into R12
MOV #7, R13 ; put array length into R13
MOV #1, R14 ; display #0 (P3&P4)
CALL #suma_rp
JMP $
arr1 DC16 1, 2, 3, 4, 1, 2, 3, 4 ; the first array
arr2 DC16 1, 1, 1, 1, -1, -1, -1 ; the second array
END
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.