1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-21 02:17:08 +00:00

Further use rotl/r.

This commit is contained in:
Thomas Harte
2025-04-25 22:53:11 -04:00
parent e13dbc03da
commit 4977c9bc4c
2 changed files with 7 additions and 24 deletions
@@ -12,6 +12,7 @@
#include "InstructionSets/M68k/ExceptionVectors.hpp"
#include <algorithm>
#include <bit>
#include <cassert>
#include <cmath>
@@ -417,21 +418,11 @@ void rotate(const uint32_t source, IntT &destination, Status &status, FlowContro
switch(operation) {
case Operation::ROLb: case Operation::ROLw: case Operation::ROLl:
if(shift) {
destination = IntT(
(destination << shift) |
(destination >> (size - shift))
);
}
destination = std::rotl<IntT>(destination, shift);
status.carry_flag = Status::FlagT(destination & 1);
break;
case Operation::RORb: case Operation::RORw: case Operation::RORl:
if(shift) {
destination = IntT(
(destination >> shift) |
(destination << (size - shift))
);
}
destination = std::rotr<IntT>(destination, shift);
status.carry_flag = Status::FlagT(destination & Numeric::top_bit<IntT>());
break;
}
@@ -10,6 +10,8 @@
#include "InstructionSets/x86/AccessType.hpp"
#include <bit>
namespace InstructionSet::x86::Primitive {
template <typename IntT, typename ContextT>
@@ -159,12 +161,7 @@ void rol(
// TODO: is this 8086-specific? i.e. do the other x86s also exit without affecting flags when temp_count = 0?
return;
}
if(temp_count) {
destination = IntT(
(destination << temp_count) |
(destination >> (Numeric::bit_size<IntT>() - temp_count))
);
}
destination = std::rotl<IntT>(destination, temp_count);
context.flags.template set_from<Flag::Carry>(destination & 1);
context.flags.template set_from<Flag::Overflow>(
@@ -211,12 +208,7 @@ void ror(
// TODO: is this 8086-specific? i.e. do the other x86s also exit without affecting flags when temp_count = 0?
return;
}
if(temp_count) {
destination = IntT(
(destination >> temp_count) |
(destination << (Numeric::bit_size<IntT>() - temp_count))
);
}
destination = std::rotr<IntT>(destination, temp_count);
context.flags.template set_from<Flag::Carry>(destination & Numeric::top_bit<IntT>());
context.flags.template set_from<Flag::Overflow>(