0

I'm using TI Code Composer Studio for the MSP430F1232. Starting from a template in assembler, a call to a routine doesn't work but when I put the routine directly in the code,it works. Why does the call won't work?

;generated code, the watchdog is stopped and the stack pointer is set correctly
RESET       mov.w   #__STACK_END,SP         ; Initialize stackpointer
StopWDT     mov.w   #WDTPW|WDTHOLD,&WDTCTL  ; Stop watchdog timer
;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------
            mov.b   #0FFh,P1DIR
            mov.b   #0,P1OUT
$1
            call    delay

            xor.b   #001h,P1OUT
            jmp     $1

            .newblock ;reuse local labels
delay       push    r14
            mov     #1000,r14
$1
            dec     r14
            jne     $1
            pop     r14
            ret
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Not work how; what happens when you single-step with a debugger? Fault with some kind of exception? That's an important part of your [mcve] – Peter Cordes May 03 '22 at 06:44

1 Answers1

1

I reproduced the problem with a similar micro (MSP430FR2433). It turned out that the addressing mode was wrong. With other microprocessor types, we use

call MySubroutine
...
MySubroutine:

For the MSP430 and similar, we should use

call #MySubroutine
...
MySubroutine