Question

In: Computer Science

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.

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 "Vector A :  "
.LC1:
        .string " "
.LC2:
        .string "\nVector B :  "
.LC3:
        .string "\nDot Product :  "
main:
        PUSHM.W #1, R4
        MOV.W   R1, R4
        SUB.W   #16, R1
        MOV.W   #3, -10(R4)
        MOV.W   #-5, -8(R4)
        MOV.W   #4, -6(R4)
        MOV.W   #2, -16(R4)
        MOV.W   #6, -14(R4)
        MOV.W   #5, -12(R4)
        MOV.W   #0, -2(R4)
        MOV.W   #0, -4(R4)
.L5:
        MOV.B   #2, R12
        CMP.W   -4(R4), R12 { JL      .L4
        MOV.W   -4(R4), R12
        ADD.W   R12, R12
        ADD.W   R4, R12
        ADD.W   #-10, R12
        MOV.W   @R12, R14
        MOV.W   -4(R4), R12
        ADD.W   R12, R12
        ADD.W   R4, R12
        ADD.W   #-16, R12
        MOV.W   @R12, R12
        MOV.W   R12, R13
        MOV.W   R14, R12
        CALL    #__mspabi_mpyi
        ADD.W   R12, -2(R4)
        ADD.W   #1, -4(R4)
        BR      #.L5
.L4:
        MOV.W   #.LC0, R13
        MOV.W   #_ZSt4cout, R12
        CALL    #_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
        MOV.W   -10(R4), R13
        CALL    #_ZNSolsEi
        MOV.W   #.LC1, R13
        CALL    #_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
        MOV.W   -8(R4), R13
        CALL    #_ZNSolsEi
        MOV.W   #.LC1, R13
        CALL    #_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
        MOV.W   -6(R4), R13
        CALL    #_ZNSolsEi
        MOV.W   #.LC2, R13
        MOV.W   #_ZSt4cout, R12
        CALL    #_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
        MOV.W   -16(R4), R13
        CALL    #_ZNSolsEi
        MOV.W   #.LC1, R13
        CALL    #_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
        MOV.W   -14(R4), R13
        CALL    #_ZNSolsEi
        MOV.W   #.LC1, R13
        CALL    #_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
        MOV.W   -12(R4), R13
        CALL    #_ZNSolsEi
        MOV.W   #.LC3, R13
        MOV.W   #_ZSt4cout, R12
        CALL    #_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
        MOV.W   -2(R4), R13
        CALL    #_ZNSolsEi
        MOV.W   #_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, R13
        CALL    #_ZNSolsEPFRSoS_E
        MOV.B   #0, R12
        ADD.W   #16, R1
        POPM.W  #1, r4
        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      .L9
        CMP.W   #-1, -4(R4) { JNE     .L9
        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
.L9:
        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

IMAGE OF OUTPUT


Related Solutions

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 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 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...
The Indexed addressing mode can not be used to specify the destination in MSP430 assembly language...
The Indexed addressing mode can not be used to specify the destination in MSP430 assembly language programs. Select one: True False
using c language: Add two vectors of doubles. Name this function vect_add(). Subtract two vectors of...
using c language: Add two vectors of doubles. Name this function vect_add(). Subtract two vectors of doubles. Name this function vect_sub(). Multiplies element by element two vectors. Name this function vect_prod(). Compute and return the dot product of two vectors. Name this function vect_dot_prod(). The dot product operation is the result of taking two vectors(single dimension arrays) and multiplying corresponding element by element and then adding up the sum of all the products. For example, if I have 2 vectors...
The cross product between the two vectors  and  is:
The cross product between the two vectors  and  is:
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two...
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. A * 5 (A + B) - (A / B) (A - B) + (A * B)
In Python: Write a function called sum_odd that takes two parameters, then calculates and returns the...
In Python: Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use at...
Must use AT&T x64/GNU Assembly syntax. Write an assembly language program that reads in two integers,...
Must use AT&T x64/GNU Assembly syntax. Write an assembly language program that reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. 1) A * 5 2) (A + B) - (A / B) 3) (A - B) + (A * B)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT