AnsweredAssumed Answered

Assembly and C can they live together?

Question asked by Anastasios Moraitis on Feb 25, 2006
Latest reply on Feb 27, 2006 by Anastasios Moraitis
Hello all (again :smileyhappy: ),

I want to write a function in c that looks like this

void defuzzification_function(const Fuzzy_Outputs *si,Fuzzy_Outputs *fi,const unsigned char n,unsigned short *result){

asm{
ldx si
ldy fi
ldab n
wav
ediv
sty result //PROBLEM HERE
}

};

And this is how i call her:

//the definitions of variables

const Fuzzy_outputs Output_Membership_Function={...};
Fuzzy_outputs FO;
const unsigned char outputlabels=5;
static unsigned short Qipercent;

void main(){
defuzzification_function(&Output_Membership_Function,&FO,outputlabels,&Qipercent);
}

logically the result of the ediv should be stored at Qipercent but this doesn't happen and Idon't know where it is stored. The generated assembly looks fine :

(Output_Membership_Function 35377
FO 2056
Qipercent 2071)

LDD #35377
PUSHD
LDX #2056
PUSHX
LDAB #5
PUSHB
LDD #2071
JSR SOMEPLACE

SOMEPLACE:
PUSHD
LDX 7,SP
LDY 5,SP
LDAB 4,SP
WAV
EDIV
STY 0,SP //this should do the job
LEAS 2,SP
RTS
--------
Any Ideas on what is happening here?

Thank you in advance

Anastasios

Outcomes