S12X fuzzy MEM instruction mixed with C

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12X fuzzy MEM instruction mixed with C

Jump to solution
668 Views
Rhapsody
Contributor III

Hello All,

I'm focusing myself on fuzzy logic instructions implemented into the S12X micro for solving problems of separating noisy data into sets.

 

I'm programming in C and now it came to implement a fuzzification routine with the MEM instruction (just as a first step).

After having read the Reference  Manual, the forums, the CodeWarrior manual about mixing C and ASM, I cannot get the fuzzification routine to work.

 

Here there is a snip of the code:

 

const uchar membership_functions[] = {       //P1    P2   slp1  slp2 0x40, 0xD0, 0x08, 0x04};#pragma NO_ENTRYvoid ASM_fuzzify_test(char * mfs, char * sis) {  __asm {    TFR  D,Y    LDX  3,SP    LDAA #$70    MEM  }}

Since the ASM_fuzzify_test routine is called using CALL, I have to get mfs by accessing 3,SP and not 2,SP as stated when using the JSR.

As it can be seen, what I do is to set a single membership function and testing the 0x70 value against it, expecting to have in 0,Y the fuzzy input, that in this case should be 0xFF.

 

For checking that, before calling the ASM_fuzzify_test I clear the array  that I'm going to pass to the routine with 0xAA, and after having called it I print it on the serial console.

 

What I get is that the just called routine never modifies the output array values, they remain as I've set them before calling ASM_fuzzify_test (all to 0xAA).

 

This is how I call the routine:

 

// global buffer in default, non banked RAMuchar nb_generic_buffer[1536];

 

for (i = 0; i < 1536; i++) nb_generic_buffer[i] = 0xAA;ASM_fuzzify_test(membership_functions, nb_generic_buffer);for (i = 0; i < 1536; i++) SCI_printf(SCI_1, "%.2X ", nb_generic_buffer[i]);

 

In the for loop I expect to have the first value set to 0xFF, and not to 0xAA.

Anyone can help me in finding where I'm mistaken?

 

Thanks a lot to anyone who can contribute on this..

 

Ale

Labels (1)
0 Kudos
1 Solution
436 Views
Rhapsody
Contributor III

I've seen that the MEM instruction has been replaced by a TRAP instruction, meaning that the MEM is not implemented. I'm using the S12XEP100-MAG. Is it true that the MEM has been removed? Is there any alternative?

View solution in original post

0 Kudos
2 Replies
436 Views
Rhapsody
Contributor III

In addition to my previous post, I can say that Y dos not get incremented as expected by the MEM instruction.

0 Kudos
437 Views
Rhapsody
Contributor III

I've seen that the MEM instruction has been replaced by a TRAP instruction, meaning that the MEM is not implemented. I'm using the S12XEP100-MAG. Is it true that the MEM has been removed? Is there any alternative?

0 Kudos