S12X compiler behaviour

Showing results for 
Search instead for 
Did you mean: 

S12X compiler behaviour

Contributor III

Dear All,

The configuration is as follows:

Development board: EVB9S12XF512E
Target Processor: MC9S12XF512MLM
Operating system: Windows 10
Debug Protocol: Full chip simulation Code warrior IDE

Please find attached two folders containing same code for hash function as follows:

1. Normal C: contains source and header file which can be compiled with any IDE (CLion or Visual studio), C90 compatible.

2. CodeWarrior project (Full - chip simulation )


While debugging with Full Chip Simulation, the while statement in line number 485 in file 'picohash.h' is never evaluated to false, because a member of struct (s->bufferOffset) resets to zero. It seems the variable is overflowing and maybe it becomes zero. Hence the program does not come out of the while loop.


For convenience of testing by tech support, i have written a statement at line number 490 of 'picohash.h' to put a breakpoint while debugging in Full Chip simulation and monitor the status of (s->bufferOffset).


The same program (attached as Normal C) runs as required in other IDE. I understand the memory allocation for variables maybe dependent on IDE and machines, but I am not able to figure out what I am missing here.


Any help is much appreciated. Thank you for your time.


Best regards,


0 Kudos
2 Replies

Senior Contributor IV

It's so sweet to blame someone else, right? 

typedef unsigned int uint32_t;


0 Kudos

NXP TechSupport
NXP TechSupport


I feel this is a programmer mistake.

In a past I was asking you. Have you stepped the code through assembler or shorter steps than function and check whether you have what you want to have in given address, variable, area, memory space....?

Look at the picture what is written to the memory. I have used data = 0x55 to see where I am....
b[s->bufferOffset] = 0x55;
// b[s->bufferOffset] = data;

You use and see 0x00 as a clearing but it is data you write to the address.
You should check your definition of sizes Picohash_Sh1_BlockLength is 64 with number of repatings of a write cycle with the size of block where you write data.
When the bufferoffset is 49 it writes to a bufferoffset space in the structure "s" (at the line b[s->bufferOffset] = data;) and rewrites it to zero (you use a value 0x00 as data to write)
This is my first opinion.....

You are using complex pointers logic. Ok, this is your approach to solution. But in this case it is necessary to be sure where and what you write.
Please correct me if I am wrong and the program logic does something different.

Best regards,



0 Kudos