Question: 4. (25 points) Design and write an MSP430 assembly language subroutine i2a_s(char *a, int myl) that converts a 16-bit BCD encoded integer, myl, into a

 4. (25 points) Design and write an MSP430 assembly language subroutine

4. (25 points) Design and write an MSP430 assembly language subroutine i2a_s(char *a, int myl) that converts a 16-bit BCD encoded integer, myl, into a character array with elements corresponding to the decimal representation of the integer. For example, an integer myl=9,246 (0x9246 in memory) is converted into an array with 4 elements as follows: a[0]='6', a[1]='4', a[2]='2', a[3]='9'. The main program that calls the subroutine is shown below. Ascii('A')=0x41, ascii('O')=0x30. RESET: StopWDT: mov.W mov.W #_STACK_END, SP #WDTPWWDTHOLD,&WDTCTL Initialize stack pointer Stop watchdog timer - - - - - -- - - - - -- - - - -- - -- - - - -- - -- - - - -- - - -- - - -- - - - - ; Main code here - - - -- - - -- sub.W mov.W push.W mov.W call add.w jmp $ #4, SP SP, R14 R14 myI, R4 #i2a_s #2, SP ; allocate space for ascii chars ; R14 points to the allocated area ; push the starting address on the stack ; integer is passed through R4 ; call subroutine ; free space on the stack lend: .word ex2013 myI: --------------------------------- ; Stack Pointer definition - -- - - - global .sect STACK_END stack ; Interrupt Vectors ; MSP430 RESET Vector .sect ".reset" .short RESET i2a_s: 4. (25 points) Design and write an MSP430 assembly language subroutine i2a_s(char *a, int myl) that converts a 16-bit BCD encoded integer, myl, into a character array with elements corresponding to the decimal representation of the integer. For example, an integer myl=9,246 (0x9246 in memory) is converted into an array with 4 elements as follows: a[0]='6', a[1]='4', a[2]='2', a[3]='9'. The main program that calls the subroutine is shown below. Ascii('A')=0x41, ascii('O')=0x30. RESET: StopWDT: mov.W mov.W #_STACK_END, SP #WDTPWWDTHOLD,&WDTCTL Initialize stack pointer Stop watchdog timer - - - - - -- - - - - -- - - - -- - -- - - - -- - -- - - - -- - - -- - - -- - - - - ; Main code here - - - -- - - -- sub.W mov.W push.W mov.W call add.w jmp $ #4, SP SP, R14 R14 myI, R4 #i2a_s #2, SP ; allocate space for ascii chars ; R14 points to the allocated area ; push the starting address on the stack ; integer is passed through R4 ; call subroutine ; free space on the stack lend: .word ex2013 myI: --------------------------------- ; Stack Pointer definition - -- - - - global .sect STACK_END stack ; Interrupt Vectors ; MSP430 RESET Vector .sect ".reset" .short RESET i2a_s

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!