Fred Talbot

Illegal Instruction on MCF52235

Discussion created by Fred Talbot on Oct 6, 2008
Latest reply on Oct 12, 2008 by Mark Butcher
Hi there, I'm having a "Illegal instruction" on the following function.

int decode_unsigned32(const uint8_t * apdu, uint32_t * value) {
    if (value) {
        *value = ((uint32_t)((((uint32_t)apdu[0]) << 24) & 0xff000000));
        *value |= ((uint32_t)((((uint32_t)apdu[1]) << 16) & 0x00ff0000));
        *value |= ((uint32_t)((((uint32_t)apdu[2]) << 8) & 0x0000ff00));
        *value |= ((uint32_t)(((uint32_t)apdu[3]) & 0x000000ff));

    return 4;

The problem is that I'm having the "Illegal instruction", I'm changing part of the code that have nothing to do with this function (like removing a printf function in another function), and the problem is gone, but when I'm changing some printing code elsewhere, the problem come back. When I'm looking at the assembler instruction that cause de problem, it's not always the same instruction, but always is this function.