From b65fa2f79f685ca8702fe8a8b4f333914293d7b7 Mon Sep 17 00:00:00 2001 From: edwin Date: Tue, 6 Jul 2021 10:43:26 +0200 Subject: [PATCH] work on = problem. NEEDS TO BE TESTED --- .../example_project/utils/BitField.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CPP/register_modeling/example_project/utils/BitField.hpp b/CPP/register_modeling/example_project/utils/BitField.hpp index 9dc87d8..aef84a6 100644 --- a/CPP/register_modeling/example_project/utils/BitField.hpp +++ b/CPP/register_modeling/example_project/utils/BitField.hpp @@ -47,10 +47,21 @@ struct BitField */ BitField& operator =(T v) { + + // this step can be optimised for systems that support bitbandalias + T mask = ((1ULL << SIZE)-1) << START; + _raw &= ~mask; + _raw |= ((v & ((1ULL << SIZE)-1)) << START); + return *this; + + + + #ifdef old //TODO: test = problem with |= instead of = // mask creation for v : https://stackoverflow.com/questions/1392059/algorithm-to-generate-bit-mask _raw |= ((v & ((1ULL << SIZE)-1)) << START) ; return *this; + #endif } /**