Question: 2 (25 points) Design and write an MSP430 assembly language subroutine i2a s(char *a, int myl) that converts a 16-bit integer, myl, into a character
2 (25 points) 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 represen of the integer. For example, an integer myl-0x34AE is converted into a a[O)-'E', a[1)-A', a12)-'4, , a[3)-'3,. The main programtha Ascii('A')-0x41, ascii(0')-0x30. n array with 4 elements as follows: 3'. The main program that calls the subroutine is shown below. How the parameters are passed? Explain your answer #include "msp430"h" NAME EXTERN 12a s ; #define controlled include file : module name main PUBLIC main : make the main label visible : outside this module ORG OFFFEh DC16 init : set reset vector to 'init' label RSEG CSTACK RSEGCODE : pre-declaration of segment ; place program in 'CODE' segment init: main: NOV NOP MOV.W #SPE (CSTACK), SP #WDTPW4HDTHOLD,gHDTCTL SP, R14 ; set up stack : main program ; Stop watchdog timer : 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 MOV NOV myI, R4 PUSHR14 CALL #12as ADD - #2, SP skip: JMP $ my DC16 0x34AE END #include "msp430"h" ; #define controlled include file PUBLIC 12as RSEG CODE 12a s: 2 (25 points) 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 represen of the integer. For example, an integer myl-0x34AE is converted into a a[O)-'E', a[1)-A', a12)-'4, , a[3)-'3,. The main programtha Ascii('A')-0x41, ascii(0')-0x30. n array with 4 elements as follows: 3'. The main program that calls the subroutine is shown below. How the parameters are passed? Explain your answer #include "msp430"h" NAME EXTERN 12a s ; #define controlled include file : module name main PUBLIC main : make the main label visible : outside this module ORG OFFFEh DC16 init : set reset vector to 'init' label RSEG CSTACK RSEGCODE : pre-declaration of segment ; place program in 'CODE' segment init: main: NOV NOP MOV.W #SPE (CSTACK), SP #WDTPW4HDTHOLD,gHDTCTL SP, R14 ; set up stack : main program ; Stop watchdog timer : 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 MOV NOV myI, R4 PUSHR14 CALL #12as ADD - #2, SP skip: JMP $ my DC16 0x34AE END #include "msp430"h" ; #define controlled include file PUBLIC 12as RSEG CODE 12a s
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
