'stack_effect' compiler directive related.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

'stack_effect' compiler directive related.

2,569 Views
kanu__
Contributor III

hi,

Can you please give me some inputs on the 'stack_effect' directive.


What is the significance(logic) of that ,when we declare it using commented pragma(i have seen like that only)?

1.Why we use that?

2.Whats the importance of that?

3.How to declare that for a simple asm function?

4.One example?

5. From where i will get more documents regarding this?

/Kanu__

Labels (1)
Tags (1)
0 Kudos
5 Replies

805 Views
CrasyCat
Specialist III

Hello

 

What are the remaining questions?

 

CrasyCat

0 Kudos

805 Views
kanu__
Contributor III

hi,

 

No  more questions other than above questions excluding point 4 and 9

I mean , Please give inputs for other points excluding point 4 and 9 in my second post 

@ 2010-06-07 07:12 AM - last edited on 2010-06-07 07:16 AM

 

/kanu__

0 Kudos

805 Views
CrasyCat
Specialist III

Hello

 

The commented pragma stack_effect is used by the linker to estimate stack usage for the application.

 

This feature is enabled if you add the option -Xlnk "-enable-stack-effect" to your linker option.

This feature is described in the StarCore SC100 Linker User Guide.pdf in chapter "Using the Linker" section "Command-Line Options" -> "Estimating Stack effect".

 

The compiler is generating the relevant information automatically so you do not have to care about it in ANSI C source files.

 

If you have an assembly source file and if you want to provide the appropriate information to the linker you need to add the pragma in your assembly source file.

 

You find some information on that in the StarCore Assembler User Guide.pdf chapter "Assembler Directives" section "Pragmas" -> "STACK_EFFECT"

 

 

CrasyCat

0 Kudos

805 Views
kanu__
Contributor III

 

Thank you very much. Now i got some idea , and am on the track.

 

I have some more doubts.

 

My sample application look like this.

 

---------------------------------------------------------------------------------------------------------------------------------------------------- 

File name: main.c


#include<stdio.h>
int add(int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int);

int main()

{

int a = add(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0);

printf("The sum is = %d\n",a);

return 0;

}
int add(int a,int b,int c,int d,int e,int f,int g,int h,int i,int j,int k,int l,int m,int n,int o,int p,int q,int r,int s,int t)

{

 int sum = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t;sum = sum+t+s+o+j;sum = add_asm(sum,g,0,0,0);sum = sum+f+g+h+i+j+k+l+m+n+o;

return sum;

}

 

File name : assembly.asm

 

        SECTION .text

        global  _add_asm


_add_asm

;pragma stack_effect _add_asm,2   ==> commented stack_effect directive  (i just put 2 as the value, i donno how to set that value)

add d0,d1,d0

rts

---------------------------------------------------------------------------------------------------------------------------------------------------------------

     

 

 

 

1) Given " -enable-stack-effect " option in the C/C++ linker .

2) successfully build the above test project.

3) viewed the output  .map file 

4) There is no stack effect entry for my _add_asm function, but all the C function routines have the same.

5) Why the assembly routines didn't had the stack_effect option even if it is explicitly given in the assembly file itself.

6) Also , should the linker will take the ";pragma stack_effect" (It is commented right?)  or not?

7) Also how can give the stack size in the above ;pragma sentence ?

8) I referred all of the above sentence you have mentioned. But i havn't got any details of stack effect , just a one page explanation.

9) Should i need to give any extra options to enable stack effect entry in map file  for my own assembly functions?

10) How can i realize the effect of this stack_effect ;pragma by debugging

11) Can you please give me XXX value in the the ;pragma stack_effect _add_asm ,XXX , and how you calculated that?

 

 

Expecting your detailed reply

 

/Kanu__

 

0 Kudos

805 Views
kanu__
Contributor III

 

 

Sorry , on trial and error method some of my above points get solved.

 

The points are ,

 

4) There is no stack effect entry for my _add_asm function, but all the C function routines have the same. --solved.

 

b'z i changed the assembly function routine to 

IF 1        

SECTION .text        

global  _add_asm
_add_asm TYPE func

pragma stack_effect _add_asm,2

add d0,d1,d0

rts

ENDSEC        

ENDIF

 

that is added TYPE func  and changed to pragma stack_effect _add_asm,2 .

 

After build ,Now i can view my assembly function routine stack effect value in map file . ie stack effect value as 2

 

Butby commenting the pragma line to 

;pragma stack_effect _add_asm,2 and tried but the map file is not showing any stack effect value (eg: given value 2)

 

But actually the pragma should be commented or not? (confused with your sentence commented pragma stack effect directive )


In assembly file it is commented or not? If it is get commented then how the compiler **bleep** linker take that line?

 

9) Should i need to give any extra options to enable stack effect entry in map file  for my own assembly functions?--solved

 

 

Please give some inputs on my remaining points 

 

/Kanu__

0 Kudos