Hi,
I have implemented a method to compute multi-precision subtraction of two multi-precision integers using c64x+ intrinsics. Unfortunately i get different results on my device(beagleboard) compared to the CCS5.1 simulator.
This code which works correctly in the simulator:
uint32_t a[7], b[7], c[7], i;
int8_t borrow;
uint40_t result;
a[0] = 0xc8266031; a[1] = 0xc603009c; a[2] = 0x0d7eb877; a[3] = 0x0caed702; a[4] = 0xcf9d18d3; a[5] = 0x14b1ba1a; a[6] = 0x1;
b[0] = 0xffffffff; b[1] = 0xffffffff; b[2] = 0xfffffffe; b[3] = 0xffffffff; b[4] = 0xffffffff; b[5] = 0xffffffff; b[6] = 0x0;
borrow = 0;
for(i = 0; i < 6; i++)
{
result = (uint40_t)a[i] - (uint40_t)b[i] - borrow;
c[i] = _loll(result);
borrow = _hill(result);
}
This code is working correctly on the device(Note the changed sign in front of the borrow variable in the line where the value for variable "result" is computed):
uint32_t a[7], b[7], c[7], i;
int8_t borrow;
uint40_t result;
a[0] = 0xc8266031; a[1] = 0xc603009c; a[2] = 0x0d7eb877; a[3] = 0x0caed702; a[4] = 0xcf9d18d3; a[5] = 0x14b1ba1a; a[6] = 0x1;
b[0] = 0xffffffff; b[1] = 0xffffffff; b[2] = 0xfffffffe; b[3] = 0xffffffff; b[4] = 0xffffffff; b[5] = 0xffffffff; b[6] = 0x0;
borrow = 0;
for(i = 0; i < 6; i++)
{
result = (uint40_t)a[i] - (uint40_t)b[i] + borrow;
c[i] = _loll(result);
borrow = _hill(result);
}
regards,
fabian