Skip to content

Commit

Permalink
Merge pull request #487 from SpyCheese/master
Browse files Browse the repository at this point in the history
Fix emulate_not in func
  • Loading branch information
EmelyanenkoK authored Oct 12, 2022
2 parents 585c5d5 + 91580e7 commit 701fc6a
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions crypto/func/builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,25 @@ int emulate_xor(int a, int b) {
}

int emulate_not(int a) {
if ((a & VarDescr::ConstZero) == VarDescr::ConstZero) {
return VarDescr::ConstTrue;
}
if ((a & VarDescr::ConstTrue) == VarDescr::ConstTrue) {
return VarDescr::ConstZero;
}
int a2 = a;
int f = VarDescr::_Even | VarDescr::_Odd;
if ((a & f) && (~a & f)) {
a ^= f;
if ((a2 & f) && (~a2 & f)) {
a2 ^= f;
}
f = VarDescr::_Pos | VarDescr::_Neg;
if ((a & f) && (~a & f)) {
a ^= f;
a2 &= ~(VarDescr::_Zero | VarDescr::_NonZero | VarDescr::_Bit | VarDescr::_Pos | VarDescr::_Neg);
if ((a & VarDescr::_Neg) && (a & VarDescr::_NonZero)) {
a2 |= VarDescr::_Pos;
}
a &= ~(VarDescr::_Zero | VarDescr::_NonZero | VarDescr::_Bit);
return a;
if (a & VarDescr::_Pos) {
a2 |= VarDescr::_Neg;
}
return a2;
}

int emulate_lshift(int a, int b) {
Expand Down

0 comments on commit 701fc6a

Please sign in to comment.