Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started