design and write an MSP430 assembly language subtoutine
4. (25 points) Write a subroutine Design and write an MSP430 assembly language subroutine i2a_s(char *a, int myl) that converts a 16-bit integer, myl, into a character array with elements corresponding to the hexadecimal representation of the integer. For example, an integer my13,486-0x34AE is converted into an array with 4 elements as follows a[0E', a[1]='A", a[2]=4', a[33'. The main program that calls the subroutine is shown below Ascii('A')-0x41, ascii('O')-0x30 RESET: StopWDT: mov .w # STACK END,SP ; Initialize stack pointer ; mov . w #WDTPHIWDTHOLD,&NDTCTL Stopwatchdog timer ; Main code here sub.w #4, SP mov.w SP, R14 mov.W myI, R4 push.w R14 call #i2a_s add.w #2, SP jmp $ ; allocate space for ascii chars ; R14 points to the allocated area ; integer is passed through R4 ; push the starting address on the stack call subroutine free space on the stack lend: myr: word 8x34AE Stack Pointer definition global-STACK-END .sect stack Interrupt Vectors .sect ".reset" MSP430 RESET Vector short RESET 12a s 4. (25 points) Write a subroutine Design and write an MSP430 assembly language subroutine i2a_s(char *a, int myl) that converts a 16-bit integer, myl, into a character array with elements corresponding to the hexadecimal representation of the integer. For example, an integer my13,486-0x34AE is converted into an array with 4 elements as follows a[0E', a[1]='A", a[2]=4', a[33'. The main program that calls the subroutine is shown below Ascii('A')-0x41, ascii('O')-0x30 RESET: StopWDT: mov .w # STACK END,SP ; Initialize stack pointer ; mov . w #WDTPHIWDTHOLD,&NDTCTL Stopwatchdog timer ; Main code here sub.w #4, SP mov.w SP, R14 mov.W myI, R4 push.w R14 call #i2a_s add.w #2, SP jmp $ ; allocate space for ascii chars ; R14 points to the allocated area ; integer is passed through R4 ; push the starting address on the stack call subroutine free space on the stack lend: myr: word 8x34AE Stack Pointer definition global-STACK-END .sect stack Interrupt Vectors .sect ".reset" MSP430 RESET Vector short RESET 12a s