예제 #1
0
/*
 * Determine the Syndrome Vector. Note that in s[0] we return the OR of
 * all of the syndromes; this allows for an easy check for the no - error
 * condition.
 */
static void syndrome(uint8_t c[ECC_CAPACITY], uint8_t s[7])
{
	s[0] = 0;
	for (int i = 1; i < ECC_OFFSET + 1; i++)
	{
		s[i] = evalpoly(c, e2v[i]);
		s[0] |= s[i];
	}
}
예제 #2
0
static int
get_factor(void)
{
	int i, j, h;
	int a0, an, na0, nan;

	if (verbosing) {
		push(zero);
		for (i = 0; i <= expo; i++) {
			push(polycoeff[i]);
			push(X);
			push_integer(i);
			power();
			multiply();
			add();
		}
		POLY = pop();
		//////printf("POLY=");
		print(POLY);
		//////printf("\n");
	}

	h = tos;

	an = tos;
	push(polycoeff[expo]);

	divisors_onstack();

	nan = tos - an;

	a0 = tos;
	push(polycoeff[0]);
	divisors_onstack();
	na0 = tos - a0;

	if (verbosing) {
		////printf("divisors of base term");
		for (i = 0; i < na0; i++) {
			////printf(", ");
			print(stack[a0 + i]);
		}
		////printf("\n");
		////printf("divisors of leading term");
		for (i = 0; i < nan; i++) {
			////printf(", ");
			print(stack[an + i]);
		}
		////printf("\n");
	}

	// try roots

	for (i = 0; i < nan; i++) {
		for (j = 0; j < na0; j++) {

			A = stack[an + i];
			B = stack[a0 + j];

			push(B);
			push(A);
			divide();
			negate();
			Z = pop();

			evalpoly();

			if (verbosing) {
				////printf("try A=");
				print(A);
				////printf(", B=");
				print(B);
				////printf(", root ");
				print(X);
				////printf("=-B/A=");
				print(Z);
				////printf(", POLY(");
				print(Z);
				////printf(")=");
				print(Q);
				////printf("\n");
			}

			if (iszero(Q)) {
				tos = h;
				return 1;
			}

			push(B);
			negate();
			B = pop();

			push(Z);
			negate();
			Z = pop();

			evalpoly();

			if (verbosing) {
				////printf("try A=");
				print(A);
				////printf(", B=");
				print(B);
				////printf(", root ");
				print(X);
				////printf("=-B/A=");
				print(Z);
				////printf(", POLY(");
				print(Z);
				////printf(")=");
				print(Q);
				////printf("\n");
			}

			if (iszero(Q)) {
				tos = h;
				return 1;
			}
		}
	}

	tos = h;

	return 0;
}