Hi,
I know C program can solve most tasks excellently by careful programming and optimizations. My job needs some knowledge at assembly code. On page 198, spru187t.pdf, I am not clear about its item 4 (shown below). I do not understand especially this line:
This step is needed only in assembly programs that were not compiled from C/C++ code.
In the simple small asm function, I do not see any stack operation in the asm and C file. I also write a same C function (add 4 to input parameter I) with that of asm. I do not see any difference in asm and C in disassembly lines.
I use CCS v5. CGT is 7.4.0B2
Thanks.
..................
.global asmfunc
.global gvar
asmfunc: .asmfunc
LDW *+b14(gvar),A3
NOP 4
ADD a3, a4, a3
STW a3, *b14(gvar)
MV a3, a4
B b3
NOP 5
.endasmfunc
............................
extern int asmfunc(int a); /* declare external as function */
int gvar = 4; /* define global variable */
int
void main(void) {
int I = 5;
I = asmfunc(I);
}
4. Upon returning, the caller reclaims any stack space needed for arguments by adding to the stack
pointer. This step is needed only in assembly programs that were not compiled from C/C++ code. This
is because the C/C++ compiler allocates the stack space needed for all calls at the beginning of the
function and deallocates the space at the end of the function.


