Texas-instruments MSP50C6xx Manuel d'utilisateur Page 353

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 390
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 352
Beware of Stack Corruption
5-57Code Development Tools
5.8 Beware of Stack Corruption
MSP50C614/MSP50P614 stack (pointed by R7 register) can easily get
corrupted if care is not taken. Notice the following table read code:
SUBB R7, 4
MOV A0, *R7––
ADD A0, address
MOV A0, *A0
ADD A0, *R7––
MOV A0, *A0
RET
This code will work perfectly well if no interrupts happen before SUBB and
MOV instruction. If interrupts do happen between SUBB and MOV
instructions, the parameter in the stack is corrupted by the return address
pushed by the hardware. This problem may not be easily observed in the
system level. But once it happens, it is very difficult to debug. Use the following
method to modify stack pointer instead:
MOV A0, *R7 + 2 * 2
ADD A0, address
MOV A0, *A0
ADD A0, *R7 + 2 * 1
MOV A0, *A0
RET
This method will not have the stack corruption problem since the MOV instruc-
tion performs the entire operation either before or after an interrupt.
Vue de la page 352
1 2 ... 348 349 350 351 352 353 354 355 356 357 358 ... 389 390

Commentaires sur ces manuels

Pas de commentaire