void test_add_bigint(void){
	bigint_t a, b, c;
	printf_P(PSTR("\nadd test\n"));
	for (;;) {
		printf_P(PSTR("\nenter a:"));
		if (bigint_read_hex_echo(&a, 512)) {
			printf_P(PSTR("\n end add test"));
			return;
		}
		printf_P(PSTR("\nenter b:"));
		if (bigint_read_hex_echo(&b, 512)) {
			free(a.wordv);
			printf_P(PSTR("\n end add test"));
			return;
		}
		printf_P(PSTR("\n "));
		bigint_print_hex(&a);
		printf_P(PSTR(" + "));
		bigint_print_hex(&b);
		printf_P(PSTR(" = "));
		memset(&c, 0, sizeof(c));
		bigint_add_u(&c, &a, &b);
		bigint_print_hex(&c);
		cli_putstr_P(PSTR("\r\n"));
		free(a.wordv);
		free(b.wordv);
		bigint_free(&c);
	}
}
示例#2
0
void test_simple(void){
	bigint_t a, b, c;
	uint8_t a_b[1], b_b[1], c_b[2];
	a.wordv=a_b;
	b.wordv=b_b;
	c.wordv=c_b;
	a.length_B = 1;
	b.length_B = 1;
	a_b[0] = 1;
	b_b[0] = 2;
	bigint_add_u(&c, &a, &b);
	cli_putstr_P(PSTR("\r\n 1+2="));
	bigint_print_hex(&c);
}