Asembly & C

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Asembly & C

1,779 次查看
Franky_TJ_
Contributor I
i've been told that there some things that could go wrong when mixing asembly and C. I'm usign CW and i created a function that has 3 input parameters and no return value but the entire body is assembly. And one problem that i'm worried about is that before code generated by the compiller adds a PSH before i use any of the paraneters...My question is  . Is this the reason that my function works some of the time but runs into  trouble when call it consecutivle?... and if so is there any document that could help me on how to succesfully mix ASM & C in CodeWarrior
标签 (1)
0 项奖励
回复
3 回复数

511 次查看
CrasyCat
Specialist III
Hello
As far as I could check the file you attached to this post contains an ANSI C function containing only inline assembly code.
So basically you are invoking an ANSI C function from an ANSI C module.
 
So parameter passing will be done appropriately and there should be no problem.
The PSH you are seeing at the beginning of the function is some entry code added by the compiler. There is probably a corresponding POP instruction at the end of the function.
 
CrayCat
0 项奖励
回复

511 次查看
CompilerGuru
NXP Employee
NXP Employee
The push is done to put the register parameter on the stack, where the assembly code
is reading it later. So it is necessary for the current assembly code. If you want full control, you can disable all the compiler stuff with some #pragmas, but then you have to follow the compiler calling convention on your own, this way the compiler takes care of that.
Daniel
0 项奖励
回复

511 次查看
Franky_TJ_
Contributor I
thanks for the replys..Cat and Guru... I guess i wont mess with that part i'll try to see what  i'm do wrong on other parts of the proyect .. tahnks again
0 项奖励
回复