1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-12-19 14:18:05 +00:00

Take a swing at three-operand IMUL.

This commit is contained in:
Thomas Harte
2025-08-02 22:23:34 -04:00
parent b6aae65afd
commit 9dfe59a104
3 changed files with 12 additions and 5 deletions

View File

@@ -132,6 +132,7 @@ void imul(
modify_t<IntT> destination_high,
modify_t<IntT> destination_low,
read_t<IntT> source,
read_t<IntT> multiplicand,
ContextT &context
) {
/*
@@ -160,8 +161,8 @@ void imul(
FI;
*/
using sIntT = typename std::make_signed<IntT>::type;
destination_high = IntT((sIntT(destination_low) * sIntT(source)) >> (8 * sizeof(IntT)));
destination_low = IntT(sIntT(destination_low) * sIntT(source));
destination_high = IntT((sIntT(multiplicand) * sIntT(source)) >> (8 * sizeof(IntT)));
destination_low = IntT(sIntT(multiplicand) * sIntT(source));
const auto sign_extension = (destination_low & Numeric::top_bit<IntT>()) ? IntT(~0) : 0;
context.flags.template set_from<Flag::Overflow, Flag::Carry>(destination_high != sign_extension);