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
  • I don't know about the Cortex-R4 myself but

    Divide and Conquer

    indicates it supports divide in Thumb mode but not ARM mode

    It is worth checking you actually are compiling for Cortex-R4 if it was supposed to be ARM mode code. You can disable div as a temporary fix by saying you're compiling that routine for a Cortex-A8 but I'd fix the root cause, temporary things seem to get a zombie life of their own.

    I'd have thought there was a bug there somewhere as one should not be seeing an mrc so you should send in a bug report with a short bit of code to reproduce it. I tend to the bug first investigate afterwards crowd myself even if it may later turn out to be something silly.. Hopefully some ARM person will advise you better here about that.

Reply
  • I don't know about the Cortex-R4 myself but

    Divide and Conquer

    indicates it supports divide in Thumb mode but not ARM mode

    It is worth checking you actually are compiling for Cortex-R4 if it was supposed to be ARM mode code. You can disable div as a temporary fix by saying you're compiling that routine for a Cortex-A8 but I'd fix the root cause, temporary things seem to get a zombie life of their own.

    I'd have thought there was a bug there somewhere as one should not be seeing an mrc so you should send in a bug report with a short bit of code to reproduce it. I tend to the bug first investigate afterwards crowd myself even if it may later turn out to be something silly.. Hopefully some ARM person will advise you better here about that.

Children
No data