This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SAVE RESTORE Floating Point Registers

The Texas Instruments (TI) Signal Processing Resource Application Report SPRAN9a, entitled TMS320C28x FPU Primer,  includes the following sentence in section "4.1 High-Priority Interrupt Context Save and Restore":

"SAVE and RESTORE should only be used in high-priority interrupts."

Note the use of the word "only".

 

QUESTION:

If a C callable assembly function is never interrupted by ISRs that use floating point registers, is it true that SAVE and RESTORE may be used to simply and swiftly save and restore the floating point registers instead of having to save and restore them using the following?

    MOV32        *SP++, R4H

    MOV32        *SP++, R5H

    MOV32        *SP++, R6H

    MOV32        *SP++, R7H

and:

    MOV32        R7H, *--SP, UNCF

    MOV32        R6H, *--SP, UNCF

    MOV32        R5H, *--SP, UNCF

    MOV32        R4H, *--SP, UNCF

 

Note that it is not necessary to save and restore R0H, R1H, R2H, and R3H in a called function based on the following given in SPRU514g, entitled TMS320C28x Optimizing C/C++ Compiler v6.2.4:

“7.3.2 How a Called Function Responds

A called function (child function) must perform the following tasks:

1. If the called function modifies XAR1, XAR2, or XAR3, it must save them, since the calling function

assumes that the values of these registers are preserved upon return. If the target is FPU, then in

addition to the C28x registers, the called function must save registers R4H, R5H, R6H or R7H, if it

modifies any of them. Any other registers may be modified without preserving them.”

 

Thank you,

Tim Ball

TDB Consulting

  • P.S.
    The Texas Instruments (TI) Signal Processing Resource User Guide SPRUEo2a, entitled TMS320C28x Floating Point Unit and Instruction Set, includes the following in section “2.1 CPU Registers”:
    "All of the floating-point registers except the repeat block register are shadowed. This shadowing can be
    used in high priority interrupts for fast context save and restore of the floating-point registers."

    In that same document, the following is included in section "RESTORE Restore the Floating-Point Registers":
    "Restore the floating-point register set (R0H - R7H and STF) from their shadow registers.
    The SAVE and RESTORE instructions should be used in high-priority interrupts. That is
    interrupts that cannot themselves be interrupted. In low-priority interrupt routines the
    floating-point registers should be pushed onto the stack."