This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Division by non-power-of-2 hits into exception

Hi there,

I was using Codewarrior targeting Cortex-R4 CPU to build Firmware. When doing a division coprocessor was used and caused exception.

Here is the division in C:

u8 i, j = 8;

i = j / 3;

Disassembly:

(u8 i, j = 8;)

mov r5, #0x8

(i = j / 3;)

mov r1, #0x3

mov r0, r5

mrc p6, 1, r0, c0, c1, 4

and r4, r0, #0xff

When running mrc, exception occurred.

Does anybody have any idea why it happens? Anyway to disable coprocessor in this operation?

Thanks.

Parents
  • Can you check what compiler flags you are using?

    The "mrc p6, 1, r0, c0, c1, 4" is interesting, as it's an access to coprocessor 6.  There isn't (AFAIK) a coprocessor 6 on the Cortex-R4, and accessing a non-existent coprocessor does cause an Undef exception.

    If it's a custom coprocessor on that SoC it may need to be enabled, check with the silicon provider.  Otherwise (and this seems more likely) you might be building for the wrong part - where the part you're building for had the coprocessor and this one doesn't.

Reply
  • Can you check what compiler flags you are using?

    The "mrc p6, 1, r0, c0, c1, 4" is interesting, as it's an access to coprocessor 6.  There isn't (AFAIK) a coprocessor 6 on the Cortex-R4, and accessing a non-existent coprocessor does cause an Undef exception.

    If it's a custom coprocessor on that SoC it may need to be enabled, check with the silicon provider.  Otherwise (and this seems more likely) you might be building for the wrong part - where the part you're building for had the coprocessor and this one doesn't.

Children
No data