Question

In: Computer Science

Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called ‘numadd’ that...

Write an MSP430 assembly language program that implements the following algorithm:

a subroutine, called ‘numadd’ that sums up all the numeric characters present in a sentence (“string” that follows the “C” language convention). For example, if the phrase is "Today is the 21st of month 5", the subroutine must perform the following sum: 2 + 1 + 5 = 8. The subroutine must receive the address of the first character of the corresponding phrase in the " stack ”, and return the result of the sum in register R12.

Solutions

Expert Solution

Please give positive ratings for my effort. Thanks.

PROGRAM

__gthread_key_delete(int):
        PUSHM.W #1, R4
        MOV.W   R1, R4
        SUB.W   #2, R1
        MOV.W   R12, -2(R4)
        MOV.B   #0, R12
        ADD.W   #2, R1
        POPM.W  #1, r4
        RET
.LC0:
        .string "Today is the 21st of month 5"
.LC1:
        .string "Result :  "
main:
        PUSHM.W #1, R10
        PUSHM.W #1, R4
        MOV.W   R1, R4
        SUB.W   #26, R1
        MOV.W   R4, R12
        ADD.W   #-5, R12
        CALL    #_ZNSaIcEC1Ev
        MOV.W   R4, R13
        ADD.W   #-5, R13
        MOV.W   R4, R12
        ADD.W   #-26, R12
        MOV.W   R13, R14
        MOV.W   #.LC0, R13
        CALL    #_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcRKS3_
        MOV.W   R4, R12
        ADD.W   #-5, R12
        CALL    #_ZNSaIcED1Ev
        MOV.W   #0, -2(R4)
        MOV.W   #0, -4(R4)
.L9:
        MOV.W   R4, R12
        ADD.W   #-26, R12
        CALL    #_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv
        MOV.W   R12, R13
        MOV.W   -4(R4), R14
        MOV.B   #1, R12
        CMP.W   R13, R14 { JLO        .L4
        MOV.B   #0, R12
.L4:
        AND     #0xff, R12
        CMP.W   #0, R12 { JEQ .L5
        MOV.W   -4(R4), R13
        MOV.W   R4, R12
        ADD.W   #-26, R12
        CALL    #_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEj
        MOV.B   @R12, R12
        MOV.B   #47, R13
        CMP.B   R12, R13 { JHS        .L6
        MOV.W   -4(R4), R13
        MOV.W   R4, R12
        ADD.W   #-26, R12
        CALL    #_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEj
        MOV.B   @R12, R12
        MOV.B   #57, R13
        CMP.B   R12, R13 { JLO        .L6
        MOV.B   #1, R12
        BR      #.L7
.L6:
        MOV.B   #0, R12
.L7:
        CMP.W   #0, R12 { JEQ .L8
        MOV.W   -4(R4), R13
        MOV.W   R4, R12
        ADD.W   #-26, R12
        CALL    #_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEj
        MOV.B   @R12, R12
        ADD.W   #-48, R12
        ADD.W   R12, -2(R4)
.L8:
        ADD.W   #1, -4(R4)
        BR      #.L9
.L5:
        MOV.W   #.LC1, R13
        MOV.W   #_ZSt4cout, R12
        CALL    #_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
        MOV.W   -2(R4), R13
        CALL    #_ZNSolsEi
        MOV.B   #0, R10
        MOV.W   R4, R12
        ADD.W   #-26, R12
        CALL    #_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev
        MOV.W   R10, R12
        BR      #.L15
        MOV.W   R12, R10
        MOV.W   R4, R12
        ADD.W   #-5, R12
        CALL    #_ZNSaIcED1Ev
        MOV.W   R10, R12
        CALL    #_Unwind_Resume
        MOV.W   R12, R10
        MOV.W   R4, R12
        ADD.W   #-26, R12
        CALL    #_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev
        MOV.W   R10, R12
        CALL    #_Unwind_Resume
.L15:
        ADD.W   #26, R1
        POPM.W  #1, r4
        POPM.W  #1, r10
        RET
__static_initialization_and_destruction_0(int, int):
        PUSHM.W #1, R4
        MOV.W   R1, R4
        SUB.W   #4, R1
        MOV.W   R12, -2(R4)
        MOV.W   R13, -4(R4)
        CMP.W   #1, -2(R4) { JNE      .L18
        CMP.W   #-1, -4(R4) { JNE     .L18
        MOV.W   #_ZStL8__ioinit, R12
        CALL    #_ZNSt8ios_base4InitC1Ev
        MOV.W   #__dso_handle, R14
        MOV.W   #_ZStL8__ioinit, R13
        MOV.W   #_ZNSt8ios_base4InitD1Ev, R12
        CALL    #__cxa_atexit
.L18:
        NOP
        ADD.W   #4, R1
        POPM.W  #1, r4
        RET
_GLOBAL__sub_I_main:
        PUSHM.W #1, R4
        MOV.W   R1, R4
        MOV.W   #-1, R13
        MOV.B   #1, R12
        CALL    #__static_initialization_and_destruction_0(int, int)
        POPM.W  #1, r4
        RET

Related Solutions

Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called 'numadd' that...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called 'numadd' that sums up all the numeric characters present in a phrase ("string" that follows the "C" language convention). By For example, if the phrase is "Today is the 28th of month 9", the subroutine must perform the following sum: 2 + 8 + 9 = 19. The subroutine must receive the address of the first character of the corresponding phrase in the "stack", and return...
Write an MSP430 assembly language program that implements the following algorithm: a macro called "vdot" that...
Write an MSP430 assembly language program that implements the following algorithm: a macro called "vdot" that calculates the "dot product" of two vectors "a" and "b", implemented as “arrays” (following the “C” language convention), of 3 elements. the macro should receive 2 pointers to the first element of each vector and return the result in R13. I have another file where I save my vectors called, "vars.c" here I save: int a[] = { 14, 65, 9} int b[] =...
Write an MSP430 assembly language program that implements the following 2 algorithms: 2) a macro called...
Write an MSP430 assembly language program that implements the following 2 algorithms: 2) a macro called "vdot" that calculates the "dot product" of two vectors "a" and "b", implemented as “arrays” (following the “C” language convention), of 3 elements. the macro should receive 2 pointers to the first element of each vector and return the result in R13.
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x +...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x + y – z + A[j] x and y should be in reserved memory words using the .word directive and labeled as x and y. Initialize x=10 and y=200. Read in z from the console. Input the value -8. This is the value for z, not for –z. Store this value in memory with the label z. To begin, you could just initialize z to...
language assembly msp430: a macro called "vdot" that calculates the "dot product" of two vectors "a"...
language assembly msp430: a macro called "vdot" that calculates the "dot product" of two vectors "a" and "b", implemented as "arrays" (following the language convention "C"), of 3 elements. the macro must receive 2 pointers to the first element of each vector and return the result in R13.
Write an assembly program for the MSP430 to calculate the number of zeros and ones in...
Write an assembly program for the MSP430 to calculate the number of zeros and ones in an array. If the number of zeros is more than the number of ones, the red LED(connected to P1.0 on the MSP430 launchpad) will turn on. Otherwise, the green LED (connected to P1.6 on the MSP430 launchpad) will turn on.
please write a C program that implements Quick Sort algorithm.
please write a C program that implements Quick Sort algorithm.
Assembly Language Define a 64-bit constant signed integer in Flash. Then, Write a subroutine count_1s that...
Assembly Language Define a 64-bit constant signed integer in Flash. Then, Write a subroutine count_1s that would count the number of 1s in a byte. The subroutine will receive the input parameter in A and return the result back in A. Use this subroutine to write a program that would count the number of 1s inside the 64-bit constant signed integer. Define a variable that would hold the total count of 1s. (Application of Shift/Rotate instructions) (No specific Architecture)
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
Write a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT