Basic doubts in assembly programming

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Basic doubts in assembly programming

1,754件の閲覧回数
createdon2003
Contributor I
I am programming on msc8144, sc3000 architecture.

    In assembly programming can someone explain stack based calling convention?
Mainly  I would like to know how offsets (from stack pointer) for input arguments and local variables is computed.

void f1()
{
 word16 ar1[ ];
 word16 ar2[ ];
word16 ar3[ ];
word16 i,j,k;
/* function body*/
f2(ar1[ ], ar2[ ], ar3[ ], i, j ,k);
/* function body*/
}

f2(word16 a1[ ], word16 a2[ ], word16 a3[ ], word16 i, word16 j, word16 k)
{
 word16 b1[ ];
word16 b2[ ];
word16 b3[ ];

/*function body*/
}

Now if I want to write function f2 in assembly, how to create memory to store temporary arrays b1, b2, b3.
how to access input arguments to the function.

It would be helpful if someone can provide resource links, where assembly programming examples are given.

Thank you
Naveen

ラベル(1)
0 件の賞賛
1 返信

212件の閲覧回数
CrasyCat
Specialist III
Hello
 
For StarCore there is a ABI defining how parameters should be passed to a function.
 
Please look at {Install}\Help\PDF\MNSC100ABI.pdf chapter "1.6 Function Calling Sequence".
 
Around allocating space for local variable, you need to reserve some space on the stack.
I would recommend you to check "Keep .sl File" check box in the Compiler panel and to look at how the compiler is managing the local variables.
 
Alternatively you can write your function in inline assembly. Please refer to {Install}\Help\PDF\StarCore_C_Compiler_User_Guide.pdf chapter "Mixing C, Assembly Code".
 
I hope this helps.
 
CrasyCat
0 件の賞賛