Post Go back to editing

my assemle code crashed issue

Category: Software
Product Number: 21571

i am being tortured by a crush issue

1)there are two interrupts, in the low priority interrupt, i call a assemble code  in the c code , but this asm code crushed when it was interrupted by another interrupt and the asm code will run good without being interrupted.

it seems relating with mode1 regester ,because after removing the mode1 regester operate code , it worked fine.

below is my code 

2)if the codes  marked red removed , there will be no crush issue, even being interrupted by another interrupt

3)the background is that i am moving some sharc code(21479) to sharc+ core (21565),and found this issue


////////////////////////////////////////////////////////////////////////////////
// includes
////////////////////////////////////////////////////////////////////////////////
#include <platform_include.h>
#include <asm_sprt.h>

.global _calcTest;
.type _calcTest,STT_FUNC;
#if defined(__SHORT_WORD_CODE__)
.segment /sw seg_swco;
#else
.segment /pm seg_pmco;
#endif

_calcTest:

entry;


// save temporary mode1 settings
r0 = mode1;

// switch to secondary register file, except R; set alternate register
bit set mode1 BITM_REGF_MODE1_SRCU|BITM_REGF_MODE1_SRD1L|BITM_REGF_MODE1_SRD1H|BITM_REGF_MODE1_SRD2H|BITM_REGF_MODE1_SRD2L|BITM_REGF_MODE1_ALUSAT|BITM_REGF_MODE1_CBUFEN;
bit clr mode1 BITM_REGF_MODE1_BR8|BITM_REGF_MODE1_BR0|BITM_REGF_MODE1_RND32;
nop;
b0 = r4; // handover pointer to param array
i13 = r0; // save mode1

// switch complete + SIMD
bit set mode1 BITM_REGF_MODE1_PEYEN|BITM_REGF_MODE1_SRCU|BITM_REGF_MODE1_SRD1L|BITM_REGF_MODE1_SRD1H|BITM_REGF_MODE1_SRD2H|BITM_REGF_MODE1_SRD2L|BITM_REGF_MODE1_SRRFL|BITM_REGF_MODE1_SRRFH|BITM_REGF_MODE1_ALUSAT|BITM_REGF_MODE1_CBUFEN;
nop;
nop;
r12 = 0x10000;
dm(i7,m7) = r12;

lcntr = r12, do(pc,.doTest) until lce;
nop;
nop;
nop;
.doTest: nop;

r12 = dm(1,i7);

r0 = m0; // zero return value
// switch to first register file (two machine cycle latency)
mode1 = i13;
nop;
nop;
exit;

_calcTest.end:

  • Hi,

    Are you using ADSP-21571 or ADSP-21565. If possible, can you please share simple project which simulates this issue.

    Regards,
    Divya.P

  • i am using 21565 , i will try to provide a simple project for this issue ,but it takes time,  would you please give me some suggestion for this crash issue firstly , thank you.

  • Hi,

    The C/C++ run-time model uses register I6 as the frame pointer and register I7 as the stack pointer. Setting the DAG register set that contains I6 and I7 from a background register set to an active register set will have a direct affect on any stack operations, so you must ensure that I6 and I7 are set correctly before any stack operations are performed:

    • Before switching to the alternate register set, save I6, B6 and L6, and I7, B7 and L7.
    • After switching, restore I6, B6 and L6, and I7, B7 and L7 to the saved values.

    In the _calcTest function, you have used I7 register. So, please try to save and restore it.

    Also, please refer the below CCES help path for more information:

    CrossCore® Embedded Studio 2.11.0 > SHARC® Development Tools Documentation > C/C++ Compiler Manual for SHARC® Processors > Compiler > C/C++ Run-Time Model and Environment > Registers > Dedicated Registers

    Regards,

    Divya.P