26 const unsigned int nb = 100000;
34 std::cout <<
"x_mul: standard algorithm --- ";
35 for (
unsigned int i = 0; i < nb; ++i) {
39 x_mul(1, 2, 3, 4, 5, 6, 7);
42 << std::lround(static_cast<double>(
nb_executed)/nb) << std::endl;
51 std::cout << std::endl
52 <<
"x_mul_karatsuba: Karatsuba algorithm --- ";
53 for (
unsigned int i = 0; i < nb; ++i) {
60 << std::lround(static_cast<double>(
nb_executed)/nb) << std::endl;
70 std::cout << std::endl
71 <<
"=== Squares ===" << std::endl
72 <<
"x_mul: standard algorithm --- ";
73 for (
unsigned int i = 0; i < nb; ++i) {
77 x_mul(1, 2, 3, 4, 5, 6, 7);
80 << std::lround(static_cast<double>(
nb_executed)/nb) << std::endl;
89 std::cout << std::endl
91 for (
unsigned int i = 0; i < nb; ++i) {
95 x_sqr(1, 2, 3, 4, 5, 6, 7);
98 << std::lround(static_cast<double>(
nb_executed)/nb) << std::endl;
void p_movi(unsigned int result, immed_t immed)
(MOV Immediate) R[result] <– immed
void clear_memory()
Reset to 0 all memory items and mark them as not used.
void x_sqr(unsigned int a, unsigned int result2, unsigned int tmp1, unsigned int tmp2, unsigned int tmp3, unsigned int tmp4, unsigned int tmp5)
R[result2]:R[a] <– R[a]*R[a].
void x_mul_karatsuba(unsigned int a, unsigned int b, unsigned int tmp1, unsigned int tmp2, unsigned int tmp3, unsigned int tmp4, unsigned int tmp5)
R[b]:R[a] <– R[a] * R[b] by Karatsuba algorithm: https://en.wikipedia.org/wiki/Karatsuba_algorithm.
word16_t registers[8]
Registers.
void x_mul(unsigned int a, unsigned int b, unsigned int tmp1, unsigned int tmp2, unsigned int tmp3, unsigned int tmp4, unsigned int tmp5)
R[b]:R[a] <– R[a] * R[b] by standard algorithm: https://en.wikipedia.org/wiki/Multiplication_algorit...
Instructions set of RiSC16: 8 instructions i_* and 4 pseudo-instructions p_*.
uint64_t nb_executed
Number of instructions executed.
void clear_registers()
Reset to 0 all registers.
void println_all()
Print infos, registers and memory (if used).
void clear_nb_executed()
Reset the number of executed instructions.
Extended instructions set: some extra operations x_* implemented with RiSC16.