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.

More questions in this forum