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.

STC backup registers

Hi

Before the STC test is executed the CPU registers must be saved on the stack

I am running the STC during runtime but after restoring the registers i am getting an exception which i cant reproduce

because after the STC starts all breakpoints are removed....

Does anybody has sample backup code?, maybe i don't backup all registers

Regards 

Burim

  • Hi Burim,

    Enclosed code is to backup stackpointer. They are stored in RAM, and should be restored after STC.

    Regards,

    QJ

    =================================

    coreBackupStackPointer_:

     

    ldr r0, r1_bkup

    str r1, [r0]

    ldr r0, r2_bkup

    str r2, [r0]

     

    msr cpsr_c, #0xD1

    ldr r0, fiq_bkup

    str sp, [r0]

    msr cpsr_c, #0xD2

    ldr r0, irq_bkup

    str sp, [r0]

    msr cpsr_c, #0xD7

    ldr r0, abort_bkup

    str sp, [r0]

    msr cpsr_c, #0xDB

    ldr r0, undef_bkup

    str sp, [r0]

    msr cpsr_c, #0xDF

    ldr r0, user_bkup

    str sp, [r0]

    msr cpsr_c, #0xD3

    ldr r0, svc_bkup

    str sp, [r0]

    bx lr

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    user_bkup: 

     

     

    svc_bkup:

     

     

    fiq_bkup:

     

     

    irq_bkup:

     

     

    abort_bkup:

     

     

    undef_bkup:

     

     

    r0_bkup:

     

     

    r1_bkup:

     

     

    r2_bkup:

     

     

    .word 0x08001020
    .word 0x0800101C
    .word 0x08001018
    .word 0x08001014
    .word 0x08001010
    .word 0x0800100C
    .word 0x08001008
    .word 0x08001004
    .word 0x08001000

  • Hi  

    This backup function is taking care of just the [0-7] bits of the CPRS

    Should be taken care of the "E- data endianness bit" too? I am confused about that

    Regards

    Burim

  • Hi Burim,

    Yes. The CPSR register should also be taken care of.

    Regards,

    QJ