Hey
I have made this ASM fil to a msp430f2272 and I use IAR V5.30
This is a delay function that take to paremeters, but when it reaches the red line the call stack become corrupted, so when the function end, it do not return to the right place.
#include <msp430f2272.h>
NAME Delay
RTMODEL "__SystemLibrary", "CLib"
RTMODEL "__core", "430"
RTMODEL "__double_size", "32"
RTMODEL "__pic", "no"
RTMODEL "__reg_r4", "free"
RTMODEL "__reg_r5", "free"
RTMODEL "__rt_version", "3"
RSEG CSTACK:DATA:SORT:NOROOT(0)
EXTERN ?longjmp_r4
EXTERN ?longjmp_r5
EXTERN ?setjmp_r4
EXTERN ?setjmp_r5
PUBWEAK ?setjmp_save_r4
PUBWEAK ?setjmp_save_r5
PUBLIC Delay
FUNCTION Delay,0203H
ARGFRAME CSTACK, 0, STACK
LOCFRAME CSTACK, 2, STACK
CFI Names cfiNames0
CFI StackFrame CFA SP DATA
CFI Resource PC:16, SP:16, SR:16, R4:16, R5:16, R6:16, R7:16, R8:16
CFI Resource R9:16, R10:16, R11:16, R12:16, R13:16, R14:16, R15:16
CFI EndNames cfiNames0
CFI Common cfiCommon0 Using cfiNames0
CFI CodeAlign 2
CFI DataAlign 2
CFI ReturnAddress PC CODE
CFI CFA SP+2
CFI PC Frame(CFA, -2)
CFI SR Undefined
CFI R4 SameValue
CFI R5 SameValue
CFI R6 SameValue
CFI R7 SameValue
CFI R8 SameValue
CFI R9 SameValue
CFI R10 SameValue
CFI R11 SameValue
CFI R12 Undefined
CFI R13 Undefined
CFI R14 Undefined
CFI R15 Undefined
CFI EndCommon cfiCommon0
RSEG CODE:CODE:REORDER:NOROOT(1)
Delay:
CFI Block cfiBlock0 Using cfiCommon0
CFI Function Delay
OutLoop: MOV.W R14, R13; // copy DcoCorrection to R13
DcoDelay:MOV #0x18, R15; // approx. 100usec delay
Loop: SUB.W #0x1, R15;
JNZ Loop;
SUB.W #0x1, R13; // Delay--
JNZ DcoDelay; // if DcoCorrection <> 0 make new 100uSec loop
SUB.W #0x1, R12; // Delay-- (R12=Delay)
JNZ OutLoop;
Exit: RET
CFI EndBlock cfiBlock0
RSEG CODE:CODE:REORDER:NOROOT(1)
?setjmp_save_r4:
REQUIRE ?setjmp_r4
REQUIRE ?longjmp_r4
RSEG CODE:CODE:REORDER:NOROOT(1)
?setjmp_save_r5:
REQUIRE ?setjmp_r5
REQUIRE ?longjmp_r5