14 #ifndef CPPRISC16_CPPRISC16_CPPEXTENDEDRISC16_HPP_ 15 #define CPPRISC16_CPPRISC16_CPPEXTENDEDRISC16_HPP_ 26 #define x_branch(label) { \ 27 ++cpprisc16::nb_executed; \ 45 x_add32(
unsigned int a2,
unsigned int a1,
unsigned int b2,
unsigned int b1,
46 unsigned int tmp1,
unsigned int tmp2,
unsigned int tmp3);
55 x_addc(
unsigned int a,
unsigned int b,
56 unsigned int tmp1,
unsigned int tmp2,
unsigned int tmp3);
63 x_and_to(
unsigned int result,
unsigned int a,
unsigned int b);
72 x_inc32(
unsigned int a2,
unsigned int a1);
80 x_is_lower_to(
unsigned int result,
unsigned int a,
unsigned int b,
129 unsigned int tmp1,
unsigned int tmp2,
unsigned int tmp3);
164 x_mov(
unsigned int result,
unsigned int a);
177 x_mul(
unsigned int a,
unsigned int b,
178 unsigned int tmp1,
unsigned int tmp2,
unsigned int tmp3,
179 unsigned int tmp4,
unsigned int tmp5);
193 unsigned int tmp1,
unsigned int tmp2,
unsigned int tmp3,
194 unsigned int tmp4,
unsigned int tmp5);
209 x_mul8_to(
unsigned int result,
unsigned int a,
unsigned int b,
210 unsigned int tmp1,
unsigned int tmp2);
217 x_neg(
unsigned int a);
224 x_not(
unsigned int a);
231 x_not_to(
unsigned int result,
unsigned int a);
242 x_or_to(
unsigned int result,
unsigned int a,
unsigned int b);
254 unsigned int tmp1,
unsigned int tmp2);
266 unsigned int tmp1,
unsigned int tmp2);
279 unsigned int resultb,
unsigned int b,
280 unsigned int tmp1,
unsigned int tmp2,
unsigned int tmp3);
292 unsigned int tmp1,
unsigned int tmp2,
318 x_sqr(
unsigned int a,
unsigned int result2,
319 unsigned int tmp1,
unsigned int tmp2,
unsigned int tmp3,
320 unsigned int tmp4,
unsigned int tmp5);
335 x_sqr8_to(
unsigned int result,
unsigned int a,
336 unsigned int tmp1,
unsigned int tmp2,
unsigned int tmp3);
350 x_sub_to(
unsigned int result,
unsigned int a,
unsigned int b);
357 x_swap(
unsigned int a,
unsigned int b,
unsigned int tmp);
362 #endif // CPPRISC16_CPPRISC16_CPPEXTENDEDRISC16_HPP_ void x_mask0x8000(unsigned int a, unsigned int tmp)
R[a] <– R[a] & 0x8000 (== R[a] & 0b1000000000000000 == R[a] & 32768)
void x_neg(unsigned int a)
R[a] <– -R[a] (two's complement)
void x_not_to(unsigned int result, unsigned int a)
R[result] <– ~R[a].
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_lshift(unsigned int a)
R[a] <– R[a] << 1 (== R[a]*2)
void x_sqr8_to(unsigned int result, unsigned int a, unsigned int tmp1, unsigned int tmp2, unsigned int tmp3)
R[result] <– R[a] * R[a].
void x_mul8_to(unsigned int result, unsigned int a, unsigned int b, unsigned int tmp1, unsigned int tmp2)
R[result] <– R[a] * R[b].
void x_set0x8000(unsigned int a)
R[result] <– 0x8000 (== 0b1000000000000000 == 32768)
void x_inc32(unsigned int a2, unsigned int a1)
R[a2]:R[a1] <– R[a2]:R[a1] + 1.
void x_not(unsigned int a)
R[a] <– ~R[a].
void x_mov(unsigned int result, unsigned int a)
R[result] <– 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.
void x_rshift_8_to(unsigned int result, unsigned int a, unsigned int tmp1, unsigned int tmp2)
R[result] <– R[a] >> 8 (== R[a]/256)
void x_and_to(unsigned int result, unsigned int a, unsigned int b)
R[result] <– R[a] & R[b].
void x_add32(unsigned int a2, unsigned int a1, unsigned int b2, unsigned int b1, unsigned int tmp1, unsigned int tmp2, unsigned int tmp3)
R[a2]:R[a1] <– R[a2]:R[a1] + R[b2]:R[b1].
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...
void x_addc(unsigned int a, unsigned int b, unsigned int tmp1, unsigned int tmp2, unsigned int tmp3)
R[b]:R[a] <– R[a] + R[b].
void x_lshift32(unsigned int a2, unsigned int a1, unsigned int tmp)
R[a2]:R[a1] <– (R[a2]:R[a1]) << 1 (== (R[a2]:R[a1])*2)
void x_rshift_8_duo_to(unsigned int result_a, unsigned int a, unsigned int result_b, unsigned int b, unsigned int tmp1, unsigned int tmp2, unsigned int tmp3)
R[resulta] <– R[a] >> 8 (== R[a]/256) R[resultb] <– R[b] >> 8.
void x_sub_to(unsigned int result, unsigned int a, unsigned int b)
R[result] <– R[a] - R[b].
Instructions set of RiSC16: 8 instructions i_* and 4 pseudo-instructions p_*.
void x_swap(unsigned int a, unsigned int b, unsigned int tmp)
R[a], R[b] <– R[b], R[a].
void x_lshift32_8(unsigned int a2, unsigned int a1, unsigned int tmp1, unsigned int tmp2, unsigned int tmp3)
R[a2]:R[a1] <– (R[a2]:R[a1]) << 8 (== (R[a2]:R[a1])*256)
void x_lshift_8(unsigned int a)
R[a] <– R[a] << 8 (== R[a]*256)
void x_rshift_to(unsigned int result, unsigned int a, unsigned int tmp1, unsigned int tmp2)
R[result] <– R[a] >> 1 (== R[a]/2)
void x_set0(unsigned int result)
R[a] <– 0.
void x_lshift_to(unsigned int result, unsigned int a)
R[result] <– R[a] << 1 (== R[a]*2)
void x_is_lower_to(unsigned int result, unsigned int a, unsigned int b, unsigned int tmp)
R[result] <– (positive value) if a < b, 0 else.
void x_sub_from(unsigned int a, unsigned int b)
R[a] <– -R[a] + R[b].
void x_lshift_8_to(unsigned int result, unsigned int a)
R[result] <– R[a] << 8 (== R[a]*256)
void x_or_to(unsigned int result, unsigned int a, unsigned int b)
R[result] <– R[a] | R[b].
void x_mask0x8000_to(unsigned int result, unsigned int a)
R[result] <– R[a] & 0x8000 (== R[a] & 0b1000000000000000 == R[a] & 32768)
void x_rshift_8_signed_to(unsigned int result, unsigned int a, unsigned int tmp1, unsigned int tmp2, unsigned int tmp3)
R[result] <– R[a] >> 8 with extension of the sign.