Solved! Go to Solution.
Hello
In fact the code you have provided is not correct. When mixing ANSI C and assembler or inline assembler you have to respect th eANSI C calling convention in your assembler source code. You find information around teh calling convention in the Manual_Compiler_HC12.pdf, chapter "Motorola HC12 Back End", section "Call Protocol and Calling Conventions".
Basically the last parameter is passed into register. You then have to save it on the stack and to make sure you do not loose it.
I would write the code as follows:
void defuzzification_function(const Fuzzy_Outputs *si,Fuzzy_Outputs *fi,const unsigned char n,unsigned short *result){
asm{
PSHD ; Push result
ldx si
ldy fi
ldab n
wav
ediv
PULX ; Pull result
sty 0,x
}
};
I hope this helps.
CrasyCat
Hello
In fact the code you have provided is not correct. When mixing ANSI C and assembler or inline assembler you have to respect th eANSI C calling convention in your assembler source code. You find information around teh calling convention in the Manual_Compiler_HC12.pdf, chapter "Motorola HC12 Back End", section "Call Protocol and Calling Conventions".
Basically the last parameter is passed into register. You then have to save it on the stack and to make sure you do not loose it.
I would write the code as follows:
void defuzzification_function(const Fuzzy_Outputs *si,Fuzzy_Outputs *fi,const unsigned char n,unsigned short *result){
asm{
PSHD ; Push result
ldx si
ldy fi
ldab n
wav
ediv
PULX ; Pull result
sty 0,x
}
};
I hope this helps.
CrasyCat