AnsweredAssumed Answered

Stack allocation of BF60x_CCES

Question asked by Daniel.Wang on Mar 13, 2013
Latest reply on Mar 28, 2013 by Daniel.Wang

Hi,

 

In CCES1.0.1 programming on BF609, when a C function is called, it allocates a frame in stack, and goes into the sub-function. but in sub-function, it will access memory before the start position of a frame.Please see the code marked in red, which I copied from assembly window. What is the purpose of this operation? return value or something like that? Is there a way to estimate the max size of memory before the frame that will be accessed within the function?

 

bsh_cmc_hal_GetLastOPF2Frame:
ffa04860:   LINK 0x8 ;
ffa04864:   [ FP + 0x10 ] = R2 ;
ffa04866:   [ FP + 0xc ] = R1 ;
ffa04868:   [ FP + 0x8 ] = R0 ;

717        if(!bOPF2FrameFlag){
ffa0486a:   P1.L = 0x11ea ;
ffa0486e:   P1.H = 0xff90 ;
ffa04872:   R0 = B [ P1 ] ( Z ) ;
ffa04874:   CC = R0 == 0 ;
ffa04876:   IF ! CC JUMP 8 /*0xFFA0487E*/ ;
718         return false;
ffa04878:   R0 = 0 ;
ffa0487a:   [ FP - 4 ] = R0 ;
ffa0487c:   JUMP.S 68 /*0xFFA048C0*/ ;
720        bOPF2FrameFlag=false;
ffa0487e:   R1 = 0 ;
ffa04880:   B [ P1 ] = R1 ;
722        value=(uint32_t)*pREG_DMA39_DSCPTR_PRV;
ffa04882:   P0 = 8360 ( X ) ;
ffa04886:   P0.H = 0xffc1 ;
ffa0488a:   R0 = [ P0 ] ;
ffa0488c:   [ FP - 8 ] = R0 ;
723        if(!value){
ffa0488e:   CC = R0 == 0 ;
ffa04890:   IF ! CC JUMP 6 /*0xFFA04896*/ ;
724         return false;
ffa04892:   [ FP - 4 ] = R1 ;
ffa04894:   JUMP.S 44 /*0xFFA048C0*/ ;
ffa04896:   P1 = R0 ;
726        *ppStartPos=(uint8_t*)(((ADI_DMA_LIST_DESCRIPTOR*)((value/4)*4))->nStartAddress);
ffa04898:   P1 = P1 >> 2 ;
ffa0489a:   P1 = P1 << 2 ;
ffa0489c:   R0 = [ P1 + 0x4 ] ;
ffa0489e:   P0 = [ FP + 0x8 ] ;

ffa048a0:   [ P0 ] = R0 ;
727        *pOverrun=((value%4)==0);
ffa048a2:   R0 = [ FP - 8 ] ;
ffa048a4:   R1 = 3 ;
ffa048a6:   R0 = R0 & R1 ;
ffa048a8:   P1 = [ FP + 0x10 ] ;
ffa048aa:   CC = R0 == 0 ;
ffa048ac:   R0 = CC ;
ffa048ae:   B [ P1 ] = R0 ;
728        *pSize=OPF2_BUFFER_SIZE;
ffa048b0:   P1 = [ FP + 0xc ] ;

ffa048b2:   R2 = -16384 ( X ) ;
ffa048b6:   R2.H = 18 ;
ffa048ba:   [ P1 ] = R2 ;
729        return true;
ffa048bc:   R3 = 1 ;
ffa048be:   [ FP - 4 ] = R3 ;
730       }
ffa048c0:   R0 = [ FP - 4 ] ;
ffa048c2:   UNLINK ;
ffa048c6:   RTS ;

 

Best regards,

Daniel

Outcomes