Assembly MSP430汇编中正确的函数调用和数组操作

Assembly MSP430汇编中正确的函数调用和数组操作,assembly,msp430,Assembly,Msp430,我正在制作一个程序,将2的幂相乘,并将乘积放入数组的元素中。我想使用硬件乘法器(并将这些产品放入阵列)和软件乘法器(并将这些产品放入它们自己的阵列)来实现这一点。如果可能的话,我还想使用嵌套的子例程来实现这一点。我已经到了需要开始调用子程序的地步,但是我被卡住了。我第一次打电话就收到垃圾。我确信我只是没有正确调用,因为我不熟悉这个IDE(CodeComposer Studio)和处理器(MSP430F5529) 用C写程序,看汇编程序的输出。用C写程序,看汇编程序的输出。

我正在制作一个程序,将2的幂相乘,并将乘积放入数组的元素中。我想使用硬件乘法器(并将这些产品放入阵列)和软件乘法器(并将这些产品放入它们自己的阵列)来实现这一点。如果可能的话,我还想使用嵌套的子例程来实现这一点。我已经到了需要开始调用子程序的地步,但是我被卡住了。我第一次打电话就收到垃圾。我确信我只是没有正确调用,因为我不熟悉这个IDE(CodeComposer Studio)和处理器(MSP430F5529)


用C写程序,看汇编程序的输出。用C写程序,看汇编程序的输出。
            .cdecls C,LIST,"msp430.h"       ;Include device header file

        .def    RESET                   ;Export program entry-point to
                                        ;make it known to linker.
        .def    calc_power
        .def    SW_Mult
        .def    HW_Mult

        .text                           ;Assemble into program memory.
        .retain                         ;Override ELF conditional linking
                                        ;and retain current section.
        .retainrefs                     ;And retain any sections that have
                                        ;references to current section.
        .data
b:      .int    2                       ;Create variable and initialize it to 2
hval:   .int    2                       ;Create variable for product placement init 0
sval:   .int    2                       ;Create variable for product placement init 0

RESET:  mov.w   #__STACK_END,SP         ;Initialize stack pointer
        mov.w   #WDTPW|WDTHOLD,&WDTCTL  ;Stop watchdog timer

;-------------------------------------------------------------------------------
; Main loop
;-------------------------------------------------------------------------------
main:   mov.w   #hwarr, R7  ;starting address of hwarr to R7
        mov.w   #swarr, R8  ;starting address of swarr to R8
        clr.w   R9

hwnext: mov.w   @R7+, R9    ;get next hwarr element
        cmp     #0, R9      ;is it a null?
        jeq     swnext      ;if yes, go to swnext
        call    hcalc_power ;calculate powers of 2
        jmp     hwnext

swnext: mov.w   @R8+, R9    ;get next swarr element
        cmp     #0, R9      ;is it a null?
        jeq     lend        ;if yes, go to end
        call    scalc_power


hcalc_power:
        call    HW_Mult
        mov.w   #hval, R9
        RET

scalc_power:
        call    SW_Mult
        mov.w   #sval, R10
        RET

HW_Mult:
        mov.w   b, &MPY     ;move b to R5
        mov.w   hval, &OP2  ;move val to R6
        nop                 ;3 clock cycles
        nop
        nop
        mov     RESLO, &hval    ;put product in val variable
        RET

SW_Mult:

hwarr:  .int    2, 2, 2, 2, 2   ;hw mult array
swarr:  .int    2, 2, 2, 2, 2   ;sw mult array

lend:   nop

;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
        .global __STACK_END
        .sect   .stack

;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
         .sect   ".reset"               ; MSP430 RESET Vector
         .short  RESET
         .end