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

Modulus calculation large numbers

Having trouble calculating modulus keep end up in DAbt_Handler. Is there issue with large numbers here?

U32 result calc_mod (U32 *a, U32 *b){

   return *a % *b;
}

typical values for a=0x496f6e77 and b = 0x3c

Using RTX maybe significant.

Any ideas or pointers thanks?

best regards
Darren

Parents
  • Large numbers? Yes, probably in numbers larger than one byte.

    I'm not sure I follow what you are saying here:
    "a=0x496f6e77 and b = 0x3c"

    Does the pointer a has the value 0x496f6e77, or does it point to an integer of such value?

    You must make sure that the pointers a and b points to aligned data. Depending on what memory controller your chip has, you must also make sure that they point to readable memory :)

    Byt why do you use pointers in the first place? The pointer is 32-bit - the same size as the integer values - so you will not gain any speed or code size to select pointers. All you do is to move the "read time" a number of clock cycles later since the actual memory access will happen inside the function instead of by being done by the caller.

Reply
  • Large numbers? Yes, probably in numbers larger than one byte.

    I'm not sure I follow what you are saying here:
    "a=0x496f6e77 and b = 0x3c"

    Does the pointer a has the value 0x496f6e77, or does it point to an integer of such value?

    You must make sure that the pointers a and b points to aligned data. Depending on what memory controller your chip has, you must also make sure that they point to readable memory :)

    Byt why do you use pointers in the first place? The pointer is 32-bit - the same size as the integer values - so you will not gain any speed or code size to select pointers. All you do is to move the "read time" a number of clock cycles later since the actual memory access will happen inside the function instead of by being done by the caller.

Children
  • Hi Thanks for the feedback

    It was a bad pointer causing the fault, i did post reply seems to have gone missing :-)

    Yes "a" points to an integer of such a value, seems to be ok now with these large numbers provided you ensure you are actually pointing at them :-{ my mistake.

    ok about the pointer and int being the same size, new to ARM, been using 8 bit previously need to reset my mindset.

    Thanks for the reply and hints though.
    Darren